ontoRootGazetteer 的重新初始化方法不起作用
re-init method of ontoRootGazetteer is not working
我是 GATE NLP 的新手。我正在开发一个适用于 GATE NLP
的应用程序。
所以,我创建了一个管道,我通过创建单例对象在应用程序中只加载它一次。因此,由于应用程序的性能有所提高,但是当我在 ontology 或地名词典中进行任何更改并重新 运行 应用程序时,它不会考虑新添加的单词,因为我将我的对象设为单例通过我正在加载我的管道,因此它考虑以前加载的地名词典和 ontology.So,
我使用了以下代码,它正在更新地名词典,但不是 ontology.
application = CorpusControllerSingleton.getInstance(gapFilePath).getApplicationObject();
Iterator<ProcessingResource> it = application.getPRs().iterator();
if(isReload){
System.out.println("processing resources------>"+it.next());
while(it.hasNext()){
ProcessingResource pr = it.next();
if(pr.getName().equals("RzCIS") || pr.getName().equals("RzCs")) {
System.out.println("PR initialization--->" +pr.getFeatures());
pr.reInit();
}
}
}
任何人都可以向我解释如何重新初始化 ontology 吗?
我用过Flexible_Gazetteer
,所以它有参数gazetteerInst
,它只不过是一个处理资源OntoRootGazetteer
。因此,首先您需要获取您在管道中使用的所有处理资源。迭代它并从中提取 OntoRootGazetteer。在那之后 OntoRootGazetteer
有一个 属性 gazetterInst
其值实际是 ontology
。因此,您只需要更新 ontology 或将 ontology 的路径提供给它。然后对从 flexibleGazettteer
.
中提取的 ontoRootGazettter
使用 reinit
方法
通过编码-
application = CorpusControllerSingleton.getInstance(gapFilePath).getApplicationObject();
Iterator<ProcessingResource> it = application.getPRs().iterator();
while (it.hasNext()) {
ProcessingResource pr = it.next();
if(pr.getName().equals(FLEXIBLE_GAZETTEER)){
onto_Root_gazetteer = (ProcessingResource) pr.getParameterValue(ONTOROOT_PROPERTY);
onto_Root_gazetteer.setParameterValue(ONTOROOT_PARAMETER, OntoLoader.getInstance().getOntology());
onto_Root_gazetteer.init();
}
if(pr.getName().equals(ANNIE_GAZETTEER_CASEINSENSITIVE)) {
pr.reInit();
}
if(pr.getName().equals(ANNIE_GAZETTEER_CASESENSITIVE)) {
pr.reInit();
}
}
这里
private static final String ONTOROOT_PROPERTY = "gazetteerInst";
private static final String ONTOROOT_PARAMETER = "ontology";
使用这个,将解决您的问题。
我是 GATE NLP 的新手。我正在开发一个适用于 GATE NLP
的应用程序。
所以,我创建了一个管道,我通过创建单例对象在应用程序中只加载它一次。因此,由于应用程序的性能有所提高,但是当我在 ontology 或地名词典中进行任何更改并重新 运行 应用程序时,它不会考虑新添加的单词,因为我将我的对象设为单例通过我正在加载我的管道,因此它考虑以前加载的地名词典和 ontology.So,
我使用了以下代码,它正在更新地名词典,但不是 ontology.
application = CorpusControllerSingleton.getInstance(gapFilePath).getApplicationObject();
Iterator<ProcessingResource> it = application.getPRs().iterator();
if(isReload){
System.out.println("processing resources------>"+it.next());
while(it.hasNext()){
ProcessingResource pr = it.next();
if(pr.getName().equals("RzCIS") || pr.getName().equals("RzCs")) {
System.out.println("PR initialization--->" +pr.getFeatures());
pr.reInit();
}
}
}
任何人都可以向我解释如何重新初始化 ontology 吗?
我用过Flexible_Gazetteer
,所以它有参数gazetteerInst
,它只不过是一个处理资源OntoRootGazetteer
。因此,首先您需要获取您在管道中使用的所有处理资源。迭代它并从中提取 OntoRootGazetteer。在那之后 OntoRootGazetteer
有一个 属性 gazetterInst
其值实际是 ontology
。因此,您只需要更新 ontology 或将 ontology 的路径提供给它。然后对从 flexibleGazettteer
.
ontoRootGazettter
使用 reinit
方法
通过编码-
application = CorpusControllerSingleton.getInstance(gapFilePath).getApplicationObject();
Iterator<ProcessingResource> it = application.getPRs().iterator();
while (it.hasNext()) {
ProcessingResource pr = it.next();
if(pr.getName().equals(FLEXIBLE_GAZETTEER)){
onto_Root_gazetteer = (ProcessingResource) pr.getParameterValue(ONTOROOT_PROPERTY);
onto_Root_gazetteer.setParameterValue(ONTOROOT_PARAMETER, OntoLoader.getInstance().getOntology());
onto_Root_gazetteer.init();
}
if(pr.getName().equals(ANNIE_GAZETTEER_CASEINSENSITIVE)) {
pr.reInit();
}
if(pr.getName().equals(ANNIE_GAZETTEER_CASESENSITIVE)) {
pr.reInit();
}
}
这里
private static final String ONTOROOT_PROPERTY = "gazetteerInst";
private static final String ONTOROOT_PARAMETER = "ontology";
使用这个,将解决您的问题。