public int preprocess(int signal) throws MaltChainedException {
if (taskName.equals("init")) {
if (modeName.equals("learn") || modeName.equals("parse")) {
OptionManager.instance().overloadOptionValue(getOptionContainerIndex(), "singlemalt", "mode", modeName);
ConfigurationDir configDir = (ConfigurationDir)flowChartinstance.getFlowChartRegistry(org.maltparserx.core.config.ConfigurationDir.class, idName);
DataFormatManager dataFormatManager = configDir.getDataFormatManager();
if (modeName.equals("learn")) {
DataFormatInstance dataFormatInstance = null;
if (dataFormatManager.getInputDataFormatSpec().getDataStructure() == DataStructure.PHRASE) {
Set<Dependency> deps = dataFormatManager.getInputDataFormatSpec().getDependencies();
String nullValueStrategy = OptionManager.instance().getOptionValue(getOptionContainerIndex(), "singlemalt", "null_value").toString();
for (Dependency dep : dataFormatManager.getInputDataFormatSpec().getDependencies()) {
dataFormatInstance = dataFormatManager.getDataFormatSpec(dep.getDependentOn()).createDataFormatInstance(configDir.getSymbolTables(), nullValueStrategy);
configDir.addDataFormatInstance(dataFormatManager.getOutputDataFormatSpec().getDataFormatName(), dataFormatInstance);
}
String decisionSettings = OptionManager.instance().getOptionValue(getOptionContainerIndex(),"guide", "decision_settings").toString().trim();
StringBuilder newDecisionSettings = new StringBuilder();
if (!Pattern.matches(".*A\\.HEADREL.*", decisionSettings)) {
newDecisionSettings.append("+A.HEADREL");
}
if (!Pattern.matches(".*A\\.PHRASE.*", decisionSettings)) {
newDecisionSettings.append("+A.PHRASE");
}
if (!Pattern.matches(".*A\\.ATTACH.*", decisionSettings)) {
newDecisionSettings.append("+A.ATTACH");
}
if (newDecisionSettings.length() > 0) {
OptionManager.instance().overloadOptionValue(getOptionContainerIndex(), "guide", "decision_settings", decisionSettings+newDecisionSettings.toString());
}
} else {
dataFormatInstance = configDir.getDataFormatInstance(dataFormatManager.getInputDataFormatSpec().getDataFormatName());
}
singleMalt.initialize(getOptionContainerIndex(), dataFormatInstance, configDir, SingleMalt.LEARN);
} else if (modeName.equals("parse")) {
singleMalt.initialize(getOptionContainerIndex(),
configDir.getDataFormatInstance(dataFormatManager.getInputDataFormatSpec().getDataFormatName()), configDir, SingleMalt.PARSE);
} else {
return ChartItem.TERMINATE;
}
} else {
return ChartItem.TERMINATE;