if (scriptLocation == null) {
try {
String mainScriptPath = mainScript.replaceAll("\\.", "/") + SCRIPT_FILE_EXTENSION;
script = loadScriptIS(mainScriptPath);
} catch (IOException e) {
throw new AnalysisEngineProcessException(new FileNotFoundException("Script [" + mainScript
+ "] cannot be found at [" + collectionToString(scriptPaths)
+ "] or classpath with extension .ruta"));
} catch (RecognitionException e) {
throw new AnalysisEngineProcessException(new FileNotFoundException("Script [" + mainScript
+ "] cannot be found at [" + collectionToString(scriptPaths)
+ "] or classpath with extension .ruta"));
}
} else {
try {
script = loadScript(scriptLocation);
} catch (Exception e) {
throw new AnalysisEngineProcessException(e);
}
}
Map<String, RutaModule> additionalScriptsMap = new HashMap<String, RutaModule>();
Map<String, AnalysisEngine> additionalEnginesMap = new HashMap<String, AnalysisEngine>();
if (additionalUimafitEngines != null) {
for (String eachUimafitEngine : additionalUimafitEngines) {
AnalysisEngine eachEngine = null;
try {
@SuppressWarnings("unchecked")
// Class clazz = this.getClass().getClassLoader().loadClass(eachUimafitEngine) ;
Class<? extends AnalysisComponent> uimafitClass = (Class<? extends AnalysisComponent>) Class
.forName(eachUimafitEngine);
eachEngine = AnalysisEngineFactory.createEngine(uimafitClass);
} catch (ClassNotFoundException e) {
throw new AnalysisEngineProcessException(e);
} catch (ResourceInitializationException e) {
throw new AnalysisEngineProcessException(e);
}
try {
additionalEnginesMap.put(eachUimafitEngine, eachEngine);
String[] eachEngineLocationPartArray = eachUimafitEngine.split("\\.");
if (eachEngineLocationPartArray.length > 1) {
String shortEachEngineLocation = eachEngineLocationPartArray[eachEngineLocationPartArray.length - 1];
additionalEnginesMap.put(shortEachEngineLocation, eachEngine);
}
} catch (Exception e) {
throw new AnalysisEngineProcessException(e);
}
}
}
if (additionalEngines != null) {
for (String eachEngineLocation : additionalEngines) {
AnalysisEngine eachEngine;
String location = locate(eachEngineLocation, descriptorPaths, ".xml");
if (location == null) {
String locationIS = locateIS(eachEngineLocation, descriptorPaths, ".xml");
try {
eachEngine = engineLoader.loadEngineIS(locationIS, viewName);
} catch (InvalidXMLException e) {
throw new AnalysisEngineProcessException(new FileNotFoundException("Engine at ["
+ eachEngineLocation + "] cannot be found in ["
+ collectionToString(descriptorPaths)
+ "] with extension .xml (from mainScript=" + mainScript + " in "
+ collectionToString(scriptPaths)));
} catch (ResourceInitializationException e) {
throw new AnalysisEngineProcessException(new FileNotFoundException("Engine at ["
+ eachEngineLocation + "] cannot be found in ["
+ collectionToString(descriptorPaths)
+ "] with extension .xml (from mainScript=" + mainScript + " in "
+ collectionToString(scriptPaths)));
} catch (IOException e) {
throw new AnalysisEngineProcessException(new FileNotFoundException("Engine at ["
+ eachEngineLocation + "] cannot be found in ["
+ collectionToString(descriptorPaths)
+ "] with extension .xml (from mainScript=" + mainScript + " in "
+ collectionToString(scriptPaths)));
} catch (ResourceConfigurationException e) {
throw new AnalysisEngineProcessException(e);
} catch (URISyntaxException e) {
throw new AnalysisEngineProcessException(e);
}
} else {
try {
eachEngine = engineLoader.loadEngine(location, viewName);
} catch (Exception e) {
throw new AnalysisEngineProcessException(e);
}
}
try {
additionalEnginesMap.put(eachEngineLocation, eachEngine);
String[] eachEngineLocationPartArray = eachEngineLocation.split("\\.");
if (eachEngineLocationPartArray.length > 1) {
String shortEachEngineLocation = eachEngineLocationPartArray[eachEngineLocationPartArray.length - 1];
additionalEnginesMap.put(shortEachEngineLocation, eachEngine);
}
} catch (Exception e) {
throw new AnalysisEngineProcessException(e);
}
}
}
if (additionalScripts != null) {