Search code examples
nlpstanford-nlpgate

re-init method of ontoRootGazetteer is not working


I am new to GATE NLP. I am working on an application which works on GATE NLP. So, I have created a pipeline, and i am loading it only once in application by creating singleton object. So, Because of this performance of application has increased but when I make any changes in ontology or gazetteer and re-run the application then it is not considering the newly added words,because i made my object singleton through I am loading my pipeline so it considers previously loaded gazetteer and ontology.So, I used the following code using it it is taking updated Gazetteer, but not 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();
                    }
                }

            }

Can anyone explain me how to re-init ontology ?


Solution

  • I have used Flexible_Gazetteer so, it has the parameter gazetteerInst which is nothing but a Processing Resource OntoRootGazetteer. So First you need to get all the Processing Resources that you are using in your pipeline . Iterate over it and extract the OntoRootGazetteer from it. After that OntoRootGazetteer has a property gazetterInst whose value is actual a ontology. So, you just need to update that ontology or give the path of the ontology to it. Then use reinit method for ontoRootGazettterwhich you extracted from the flexibleGazettteer.

    Through coding -

    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();
                    }
                }
    

    Here

    private static final String ONTOROOT_PROPERTY = "gazetteerInst";
    private static final String ONTOROOT_PARAMETER = "ontology";
    

    use this, will solve your problem.