From 66cfd2b0bfbbe06994ba2cae463de0abd0a54cd8 Mon Sep 17 00:00:00 2001 From: Andrew Wen Date: Tue, 3 Sep 2024 15:50:32 -0500 Subject: [PATCH] Dynamically resolve section --- pom.xml | 2 +- .../java/org/ohnlp/medtagger/fit/Main.java | 28 ++++++++++++++++++- .../MedTaggerIEAggregateTAE.xml | 7 ----- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 59bb63b..34f1bb5 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.ohnlp.medtagger medtagger - 1.0.73 + 1.0.74 The MedTagger biomedical information extraction pipeline diff --git a/src/main/java/org/ohnlp/medtagger/fit/Main.java b/src/main/java/org/ohnlp/medtagger/fit/Main.java index b6f446e..7ac456e 100644 --- a/src/main/java/org/ohnlp/medtagger/fit/Main.java +++ b/src/main/java/org/ohnlp/medtagger/fit/Main.java @@ -5,8 +5,11 @@ import org.apache.uima.collection.CollectionReaderDescription; import org.apache.uima.fit.factory.AnalysisEngineFactory; import org.apache.uima.fit.factory.CollectionReaderFactory; +import org.apache.uima.fit.factory.ExternalResourceFactory; import org.apache.uima.fit.pipeline.SimplePipeline; +import org.apache.uima.resource.impl.FileLanguageResource_impl; import org.apache.uima.resource.metadata.ConfigurationParameterSettings; +import org.apache.uima.resource.metadata.ResourceManagerConfiguration; import org.ohnlp.medtagger.cr.FileSystemReader; import org.ohnlp.medtagger.ie.cc.MedTatorWriter; @@ -22,6 +25,10 @@ public static void main(String[] args) throws Exception { Path inputDirPath = Paths.get(args[0]); Path outputDirPath = Paths.get(args[1]); Path ruleDirPath = Paths.get(args[2]); + Path sectionPath = null; + if (args.length > 3) { + sectionPath = Paths.get(args[4]); + } CollectionReaderDescription reader = CollectionReaderFactory.createReaderDescription( @@ -31,10 +38,29 @@ public static void main(String[] args) throws Exception { System.out.println("Input Dir:\t" + inputDirPath.toAbsolutePath().toString()); System.out.println("Output Dir:\t" + outputDirPath.toAbsolutePath().toString()); System.out.println("IE Rules:\t" + ruleDirPath.toAbsolutePath().toUri().toString()); + if (sectionPath != null) { + System.out.println("Section Rules:\t" + sectionPath.toAbsolutePath().toUri().toString()); + } AnalysisEngineDescription descMedTaggerTAE = createEngineDescription( "desc.medtaggeriedesc.aggregate_analysis_engine.MedTaggerIEAggregateTAE"); - + if (sectionPath != null) { + ResourceManagerConfiguration rmConfig = descMedTaggerTAE.getResourceManagerConfiguration(); + rmConfig.addExternalResource( + ExternalResourceFactory.createExternalResourceDescription( + "section_map", + "file:" + sectionPath.toFile().getAbsolutePath() + ) + ); + } else { + ResourceManagerConfiguration rmConfig = descMedTaggerTAE.getResourceManagerConfiguration(); + rmConfig.addExternalResource( + ExternalResourceFactory.createExternalResourceDescription( + "section_map", + "file:medtaggerieresources/pad/Radiology_Section" + ) + ); + } AnalysisEngineMetaData metadata = descMedTaggerTAE.getAnalysisEngineMetaData(); ConfigurationParameterSettings settings = metadata.getConfigurationParameterSettings(); diff --git a/src/main/resources/desc/medtaggeriedesc/aggregate_analysis_engine/MedTaggerIEAggregateTAE.xml b/src/main/resources/desc/medtaggeriedesc/aggregate_analysis_engine/MedTaggerIEAggregateTAE.xml index c9c626e..6b0a281 100644 --- a/src/main/resources/desc/medtaggeriedesc/aggregate_analysis_engine/MedTaggerIEAggregateTAE.xml +++ b/src/main/resources/desc/medtaggeriedesc/aggregate_analysis_engine/MedTaggerIEAggregateTAE.xml @@ -140,13 +140,6 @@ - - section_map - - - file:medtaggerieresources/pad/Radiology_Section - - openclass