Skip to content

Commit

Permalink
Issue #189: Avoid type system scanning when initializing uimaFIT anno…
Browse files Browse the repository at this point in the history
…tators from a Ruta script

- Pass a null TS to avoid scanning
  • Loading branch information
reckart committed Dec 12, 2024
1 parent 3fd850f commit f61a748
Showing 1 changed file with 6 additions and 6 deletions.
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

0 comments on commit f61a748

Please sign in to comment.