Skip to content

Commit

Permalink
Dynamically resolve section
Browse files Browse the repository at this point in the history
  • Loading branch information
qqndrew committed Sep 3, 2024
1 parent abe2c0a commit 66cfd2b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.ohnlp.medtagger</groupId>
<artifactId>medtagger</artifactId>
<version>1.0.73</version>
<version>1.0.74</version>
<description>The MedTagger biomedical information extraction pipeline</description>


Expand Down
28 changes: 27 additions & 1 deletion src/main/java/org/ohnlp/medtagger/fit/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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(
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,6 @@
</fileResourceSpecifier>
</externalResource>

<externalResource>
<name>section_map</name>
<description/>
<fileResourceSpecifier>
<fileUrl>file:medtaggerieresources/pad/Radiology_Section</fileUrl>
</fileResourceSpecifier>
</externalResource>

<externalResource>
<name>openclass</name>
Expand Down

0 comments on commit 66cfd2b

Please sign in to comment.