Changing default values of ANNIE resources in GATE from Java code

In GATE, default values for ANNIE are set during initialization, but sometimes based on requirements they have to be changed.

My Requirement : I want to extract English sentences without considering the nextline character but considering full stop which gives correct sentences. For that, I need to change the default value of transducerURL in SentenceSplitter in ANNIE. This can be done in two ways:

  1. Using ANNIE_with_defaults.gapp - changing initparams value in Sentencesplitter and accessing from java:

     Gate.setGateHome(new File(Configuration.GATE_HOME));                        
     Gate.init();
     // Load ANNIE with defaults from the plug-ins folder
     File pluginsHome = Gate.getPluginsHome();
     File anniePlugin = new File(pluginsHome, ANNIEConstants.PLUGIN_DIR);
     File annieGapp = new File(anniePlugin, ANNIEConstants.DEFAULT_FILE);
     annieController = (CorpusController) PersistenceManager.loadObjectFromFile(annieGapp);
    

I am not being able to find where to change its value in gapp file.

  1. After initialising GATE, accessing ResourceData using CreoleRegister and changing the default value of parameter transducerURL as shown below:

     String resourceClassName = gate.creole.splitter.SentenceSplitter;
     ResourceData resData = Gate.getCreoleRegister().get(resourceClassName);
     //System.out.println(resData.getParameterList());
     ParameterList params = resData.getParameterList();
     ListListParameter param =  params.getInitimeParameters();
     System.out.println(param);
     //System.out.println(param.get(0));
     for(ListParameter plist : param)
     {
         for(Parameter pm : plist)
         {
             System.out.println(Name : +pm.getName()+, +pm.getDefaultValue());
         }
     }
    

But Parameter does not have setDefaultvalue method.

How can I fix this?

Topic java nlp

Category Data Science


I solved the issue by using creole.xml. I have tried with SentenceSplitter but it is giving me incorrect sentences. So, I am using RegexSentenceSplitter instead. Added few lines in creole.xml-

<RESOURCE>
    <CLASS>gate.creole.splitter.RegexSentenceSplitter</CLASS>
    <PARAMETER NAME="externalSplitListURL" DEFAULT="file:/C:/Program%20Files/GATE_Developer_8.1/plugins/ANNIE/resources/regex-splitter/external-split-patterns.txt" COMMENT="The URL to the custom external-split-patterns.txt" SUFFIXES="txt;text">java.net.URL</PARAMETER>
    <PARAMETER NAME="internalSplitListURL" DEFAULT="file:/C:/Program%20Files/GATE_Developer_8.1/plugins/ANNIE/resources/regex-splitter/internal-split-patterns.txt" COMMENT="The URL to the custom internal-split-patterns.txt" SUFFIXES="txt;text">java.net.URL</PARAMETER>
    <PARAMETER NAME="nonSplitListURL" DEFAULT="file:/C:/Program%20Files/GATE_Developer_8.1/plugins/ANNIE/resources/regex-splitter/non-split-patterns.txt" COMMENT="The URL to the custom non-split-patterns.txt" SUFFIXES="txt;text">java.net.URL</PARAMETER>
</RESOURCE>

Then loading ANNIE_with_defaults.gapp from backend code as shown in the question.

Hope it may be helpful.


For any of these situations the best approach is to construct the application as you need it using GATE Developer, "save application state" to create your own custom gapp file, then pass your new gapp to the PersistenceManager instead of loading the standard ANNIE_with_defaults.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.