Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #189: Avoid type system scanning when initializing uimaFIT annotators from a Ruta script #190

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import static java.util.Arrays.asList;
import static java.util.stream.Collectors.joining;
import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngineDescription;

import java.io.File;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -49,7 +50,6 @@
import org.apache.uima.UimaContextAdmin;
import org.apache.uima.analysis_component.AnalysisComponent;
import org.apache.uima.analysis_engine.AnalysisEngine;
import org.apache.uima.analysis_engine.AnalysisEngineDescription;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.Feature;
Expand All @@ -59,11 +59,11 @@
import org.apache.uima.cas.text.AnnotationIndex;
import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
import org.apache.uima.fit.descriptor.ConfigurationParameter;
import org.apache.uima.fit.factory.AnalysisEngineFactory;
import org.apache.uima.fit.internal.ResourceManagerFactory;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.resource.ResourceManager;
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.apache.uima.ruta.FilterManager;
import org.apache.uima.ruta.ReindexUpdateMode;
import org.apache.uima.ruta.RutaBasicUtils;
Expand Down Expand Up @@ -1094,8 +1094,9 @@ private void addUimafitAnalysisEngine(RutaModule script,
AnalysisEngine eachEngine = null;
try {
Class<? extends AnalysisComponent> uimafitClass = loadClass(eachUimafitEngine);
List<String> configurationData = script.getConfigurationData(eachUimafitEngine);
AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(uimafitClass,
var configurationData = script.getConfigurationData(eachUimafitEngine);
// We pass a null type-system to avoid that uimaFIT does a TS scan itself (which can be slow)
var aed = createEngineDescription(uimafitClass, (TypeSystemDescription) null,
configurationData.toArray());
eachEngine = UIMAFramework.produceAnalysisEngine(aed, resourceManager, null);
} catch (ClassNotFoundException | ResourceInitializationException e) {
Expand Down Expand Up @@ -1132,8 +1133,7 @@ private static <T> Class<T> loadClass(String className, ClassLoader... classLoad
+ classLoaderList + "]: " + errorList);
}

private <T> Class<T> loadClass(String className)
throws ClassNotFoundException {
private <T> Class<T> loadClass(String className) throws ClassNotFoundException {
ClassLoader extCl = resourceManager.getExtensionClassLoader();
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
ClassLoader local = getClass().getClassLoader();
Expand Down
Loading