# 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);


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();
List<List<Parameter>> param =  params.getInitimeParameters();
System.out.println(param);
//System.out.println(param.get(0));
for(List<Parameter> 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?

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.

• Thanks for a quick reply @Ian. But I want this in production, no options of creating custom gapp file.
– Rana
Feb 28 '17 at 13:11
• @Rana my suggestion is for production. We always recommend you build your app in the GUI and load the saved state in your production code using PersistenceManager, it's much less error-prone than trying to construct the pipeline by hand in your code. Feb 28 '17 at 17:52
• Ok. Got it. Another good solution.
– Rana
Mar 15 '17 at 9:19

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>