Skip to content

Commit

Permalink
Add configurable dictionary execution options to backbone
Browse files Browse the repository at this point in the history
  • Loading branch information
qqndrew committed Feb 3, 2022
1 parent da301a9 commit f64088d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 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.22</version>
<version>1.0.23</version>
<description>The MedTagger biomedical information extraction pipeline</description>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.uima.util.InvalidXMLException;
import org.ohnlp.backbone.api.Transform;
import org.ohnlp.backbone.api.exceptions.ComponentInitializationException;
import org.ohnlp.medtagger.ae.AhoCorasickLookupAnnotator;
import org.ohnlp.medtagger.context.RuleContextAnnotator;
import org.ohnlp.medtagger.ie.ae.MedTaggerIEAnnotator;
import org.ohnlp.medtagger.type.ConceptMention;
Expand Down Expand Up @@ -95,7 +96,7 @@ public void init() throws IOException, InvalidXMLException, URISyntaxException,
switch (mode) {
case OHNLPTK_DEFINED: // Ruleset from a web service
throw new UnsupportedOperationException("Remote Served IE Rulesets not yet implemented");
case STANDALONE:
case STANDALONE: case STANDALONE_IE_ONLY: {
uri = MedTaggerPipelineFunction.class.getResource("/resources/" + this.resourceFolder).toURI();
Map<String, String> env = new HashMap<>();
env.put("create", "true");
Expand All @@ -106,6 +107,41 @@ public void init() throws IOException, InvalidXMLException, URISyntaxException,
}
ae.add(createEngineDescription("org.ohnlp.medtagger.ie.aes.MedTaggerIEAnnotatorAE", "Resource_dir", uri.toString()));
break;
}
case STANDALONE_DICT_ONLY: {
uri = MedTaggerPipelineFunction.class.getResource("/resources/" + this.resourceFolder).toURI();
Map<String, String> env = new HashMap<>();
env.put("create", "true");
try {
// Ensure it is created, ignore if not
FileSystem fs = FileSystems.newFileSystem(uri, env);
} catch (FileSystemAlreadyExistsException ignored) {
}
ae.add(createEngineDescription(AhoCorasickLookupAnnotator.class, "dict_file", uri.toString()));
break;
}
case STANDALONE_DICT_AND_IE: {
String[] parsed = this.resourceFolder.split("\\|");
uri = MedTaggerPipelineFunction.class.getResource("/resources/" + parsed[0]).toURI();
URI dictURI = null;
if (parsed.length > 1) {
dictURI = MedTaggerPipelineFunction.class.getResource("/resources/" + parsed[1]).toURI();
}
Map<String, String> env = new HashMap<>();
env.put("create", "true");
try {
// Ensure it is created, ignore if not
FileSystem fs = FileSystems.newFileSystem(uri, env);
} catch (FileSystemAlreadyExistsException ignored) {
}
ae.add(createEngineDescription("org.ohnlp.medtagger.ie.aes.MedTaggerIEAnnotatorAE", "Resource_dir", uri.toString()));
if (dictURI != null) {
ae.add(createEngineDescription(AhoCorasickLookupAnnotator.class, "dict_file", dictURI.toString()));
} else {
ae.add(createEngineDescription(AhoCorasickLookupAnnotator.class));
}
break;
}
case GENERAL_CLINICAL:
ae.add(createEngineDescription("desc.backbone.aes.MedTaggerDictionaryLookupAE"));
break;
Expand Down Expand Up @@ -196,7 +232,10 @@ private static JsonNode toJSON(

private enum RunMode {
OHNLPTK_DEFINED, // Retrieve from web-based middleware server
STANDALONE, // Embedded IE Ruleset
STANDALONE, // Embedded IE Ruleset (Legacy)
STANDALONE_IE_ONLY,
STANDALONE_DICT_ONLY,
STANDALONE_DICT_AND_IE,
GENERAL_CLINICAL // General Purpose SCT dictionary
}
}

0 comments on commit f64088d

Please sign in to comment.