1

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 ?

ganesh
  • 43
  • 6
  • Good question. Afters some searches it seems to me that it is actually not possible to reload a ontology :-( – dedek Nov 29 '16 at 10:38
  • You can try to call `cleanup()` and `init()` on the ontology, but I'm giving no guarantee it will work... – dedek Nov 29 '16 at 10:52
  • Hey , @dedek This problem can be solved by doing -Iterator 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(); } – ganesh Dec 06 '16 at 08:15
  • post it as answer if it works for you, I will up-vote ;-) – dedek Dec 06 '16 at 15:54

1 Answers1

1

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.

ganesh
  • 43
  • 6
  • I'm curious about the `OntoLoader.getInstance().getOntology()`, what does it do? Where the `OntoLoader` class comes from? – dedek Dec 07 '16 at 06:51
  • 1
    Hey It is created by me . You just have to give the ontology their.That method is just returning the ontology. – ganesh Dec 07 '16 at 07:34