Skip to content

Commit

Permalink
Changes to reflect simplier method of dataset instantiation
Browse files Browse the repository at this point in the history
Updated class IVFLookup to support instantiation of dataset indexes
from the property metamaplite.index.directory.  Scripts, config files,
and README file where also updated to reflect change.

removed duplicate class IVFTermInfoLookup
  • Loading branch information
willjrogers committed Apr 23, 2020
1 parent 9accb3b commit 5490413
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 251 deletions.
18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,8 @@ These properties can be set using a System property
### Configuration properties

| metamaplite.excluded.termsfile | cui/terms pairs that are exclude from results (default: data/specialterms.txt)
| metamaplite.index.directory | the directory the indexes resides (sets the following properties)
| metamaplite.ivf.cuiconceptindex | cui/concept/preferredname index
| metamaplite.ivf.cuisourceinfoindex | cui/sourceinfo index
| metamaplite.ivf.cuisemantictypeindex | cui/semantictype index

| opennlp.models.directory | the directory the models resides (sets the following properties. default: data/models)
| metamaplite.index.directory | the directory the indexes reside
| opennlp.models.directory | the directory the models reside (sets the following properties. default: data/models)
| opennlp.en-pos.bin.path | (default: data/models/en-pos-maxent.bin)
| opennlp.en-token.bin.path | (default: data/models/en-token.bin)
| opennlp.en-sent.bin.path | (default: data/models/en-sent.bin)
Expand Down Expand Up @@ -484,11 +480,7 @@ Use the --indexdir=<directory> option:

Or modify the configuration file config/metamap.properties:

metamaplite.ivf.cuiconceptindex: <ivfdir>/indices/cuiconcept
metamaplite.ivf.cuisourceinfoindex: <ivfdir>/indices/cuisourceinfo
metamaplite.ivf.cuisemantictypeindex: <ivfdir>/indices/cuist
metamaplite.ivf.varsindex: <ivfdir>/indices/vars
metamaplite.ivf.meshtcrelaxedindex: <ivfdir>/indices/meshtcrelaxed
metamaplite.index.directory: <ivfdir>

## Adding custom input document formats

Expand Down Expand Up @@ -582,8 +574,8 @@ directory and specify that in servlet:
try {
this.properties = new Properties();
// default properties that can be overriden
this.properties.setProperty("metamaplite.ivf.cuiconceptindex","data/ivf/strict/indices/cuiconcept");
...
this.properties.setProperty("metamaplite.index.directory","data/ivf/strict");
...
// load user properties
this.properties.load(new FileReader(configPropertyFilename));
this.metaMapLiteInst = new MetaMapLite(this.properties);
Expand Down
6 changes: 1 addition & 5 deletions config/bioc.metamaplite.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
# metamaplite.varsindex: data/lucenedb/strict/vars

# irutils indexes
metamaplite.ivf.cuiconceptindex: data/ivf/strict/indices/cuiconcept
metamaplite.ivf.cuisourceinfoindex: data/ivf/strict/indices/cuisourceinfo
metamaplite.ivf.cuisemantictypeindex: data/ivf/strict/indices/cuist
metamaplite.ivf.varsindex: data/ivf/strict/indices/vars
metamaplite.ivf.meshtcrelaxedindex: data/ivf/strict/indices/meshtcrelaxed
metamaplite.index.directory=@@basedir@@/data/ivf/@@year@@/@@subset@@

# OpenNLP model files
opennlp.en-sent.bin.path:/net/indlx1/export/home/wjrogers/Projects/metamaplite/data/models/en-sent.bin
Expand Down
6 changes: 1 addition & 5 deletions config/metamaplite.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
# metamaplite.varsindex: data/lucenedb/strict/vars

# irutils indexes
metamaplite.ivf.cuiconceptindex: data/ivf/strict/indices/cuiconcept
metamaplite.ivf.cuisourceinfoindex: data/ivf/strict/indices/cuisourceinfo
metamaplite.ivf.cuisemantictypeindex: data/ivf/strict/indices/cuist
metamaplite.ivf.varsindex: data/ivf/strict/indices/vars
metamaplite.ivf.meshtcrelaxedindex: data/ivf/strict/indices/meshtcrelaxed
metamaplite.index.directory: data/ivf/strict

# default semantic.type.list: if not defined is empty (all semantic types)
# semantic type abbreviations separated by commas.
Expand Down
7 changes: 1 addition & 6 deletions config/metamaplite.properties.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ metamaplite.cuisemantictypeindex: @@basedir@@/data/lucenedb/cui_st
metamaplite.varsindex: @@basedir@@/data/lucenedb/vars

# Inverted Files
metamaplite.ivf.cuiconceptindex: @@basedir@@/data/ivf/@@year@@/@@subset@@/indices/cuiconcept
metamaplite.ivf.firstwordsofonewideindex: @@basedir@@/data/ivf/@@year@@/@@subset@@/indices/first_words_of_one_WIDE
metamaplite.ivf.cuisourceinfoindex: @@basedir@@/data/ivf/@@year@@/@@subset@@/indices/cuisourceinfo
metamaplite.ivf.cuisemantictypeindex: @@basedir@@/data/ivf/@@year@@/@@subset@@/indices/cuist
metamaplite.ivf.varsindex: @@basedir@@/data/ivf/@@year@@/@@subset@@/indices/vars
metamaplite.ivf.meshtcrelaxedindex: @@basedir@@/data/ivf/@@year@@/@@subset@@/indices/meshtcrelaxed
metamaplite.index.directory=@@basedir@@/data/ivf/@@year@@/@@subset@@

# default semantic.type.list: if not defined is empty (all semantic types)
# semantic type abbreviations separated by commas.
Expand Down
21 changes: 11 additions & 10 deletions metamaplite.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
::
echo off
:: A simplified metamaplite batch script using metamaplite standalone
:: jar, should work in Command Prompt and maybe PowerShell on Windows.

@echo off

set projectdir=%cd%

Expand All @@ -10,7 +13,7 @@ set CONFIGDIR=$PROJECTDIR/config

set MML_JVM_OPTS=-Xmx12g

set METAMAPLITE=%projectdir%/target/metamaplite-%MML_VERSION%%-standalone.jar
set METAMAPLITE=%projectdir%/target/metamaplite-%MML_VERSION%-standalone.jar

set JARSPATH=%METAMAPLITE%

Expand All @@ -24,13 +27,11 @@ set JVMOPTS=-Den-sent.bin.path=%OPENNLP_MODELS%/en-sent.bin ^
-Dlog4j.configurationFile=file:///%projectdir%/config/log4j2.xml ^
-Dmetamaplite.property.file=%CONFIGDIR%/metamaplite.properties ^
-Dmetamaplite.entitylookup.resultlength=1500 ^
-Dmetamaplite.ivf.cuiconceptindex=%projectdir%/data/ivf/strict/cuiconcept ^
-Dmetamaplite.ivf.firstwordsofonewideindex=%projectdir%/data/ivf/strict/first_words_of_one_WIDE ^
-Dmetamaplite.ivf.cuisourceinfoindex=%projectdir%/data/ivf/strict/cuisourceinfo ^
-Dmetamaplite.ivf.cuisemantictypeindex=%projectdir%/data/ivf/strict/cuist ^
-Dmetamaplite.ivf.varsindex=%projectdir%/data/ivf/strict/vars ^
-Dmetamaplite.ivf.meshtcrelaxedindex=$PROJECTDIR/data/ivf/strict/indices/meshtcrelaxed

java -cp %projectdir%/target/classes;%projectdir%/build/classes;%projectdir%/classes;%JARSPATH%;%CONFIGDIR% ^
-Dmetamaplite.index.directory=%projectdir%/data/ivf/2019AB/USAbase ^
-Dmetamaplite.excluded.termsfile=%projectdir%/data/specialterms.txt

java -cp %projectdir%/target/classes;%projectdir%/build/classes;%projectdir%/classes;%JARSPATH%;%projectdir% ^
%JVMOPTS% gov.nih.nlm.nls.ner.MetaMapLite %*



16 changes: 6 additions & 10 deletions metamaplite.bat.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ set CONFIGDIR=$PROJECTDIR/config

set MML_JVM_OPTS=-Xmx12g

set METAMAPLITE=%projectdir%/target/metamaplite-%MML_VERSION%%-standalone.jar
set METAMAPLITE=%projectdir%/target/metamaplite-%MML_VERSION%-standalone.jar

set JARSPATH=%METAMAPLITE%

set OPENNLP_MODELS=%projectdir%/data/models
set CONFIGDIR=%projectdir%/config
set CONFIGDIR=%projectdir%

set JVMOPTS=-Den-sent.bin.path=%OPENNLP_MODELS%/en-sent.bin ^
-Den-token.bin.path=%OPENNLP_MODELS%/en-token.bin ^
Expand All @@ -24,14 +24,10 @@ set JVMOPTS=-Den-sent.bin.path=%OPENNLP_MODELS%/en-sent.bin ^
-Dlog4j.configurationFile=file:///%projectdir%/config/log4j2.xml ^
-Dmetamaplite.property.file=%CONFIGDIR%/metamaplite.properties ^
-Dmetamaplite.entitylookup.resultlength=1500 ^
-Dmetamaplite.ivf.cuiconceptindex=%projectdir%/data/ivf/@@year@@/@@subset@@/indices/cuiconcept ^
-Dmetamaplite.ivf.firstwordsofonewideindex=%projectdir%/data/ivf/@@year@@/@@subset@@/first_words_of_one_WIDE ^
-Dmetamaplite.ivf.cuisourceinfoindex=%projectdir%/data/ivf/@@year@@/@@subset@@/cuisourceinfo ^
-Dmetamaplite.ivf.cuisemantictypeindex=%projectdir%/data/ivf/@@year@@/@@subset@@/cuist ^
-Dmetamaplite.ivf.varsindex=%projectdir%/data/ivf/@@year@@/@@subset@@/vars ^
-Dmetamaplite.ivf.meshtcrelaxedindex=$PROJECTDIR/data/ivf/@@year@@/@@subset@@/indices/meshtcrelaxed

java -cp %projectdir%/target/classes;%projectdir%/build/classes;%projectdir%/classes;%JARSPATH%;%CONFIGDIR% ^
-Dmetamaplite.index.directory=%projectdir%/data/ivf/2019AB/USAbase ^
-Dmetamaplite.excluded.termsfile=%projectdir%/data/specialterms.txt

java -cp %projectdir%/target/classes;%projectdir%/build/classes;%projectdir%/classes;%JARSPATH%;%projectdir% ^
%JVMOPTS% gov.nih.nlm.nls.ner.MetaMapLite %*


Expand Down
14 changes: 5 additions & 9 deletions metamaplite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# A simplified metamaplite bash script using metamaplite standalone
# jar, should work on MINGW bash (and GIT bash) on Windows.
#

PROJECTDIR=$(dirname $0)

MML_VERSION=3.6.2rc5
Expand All @@ -20,14 +19,11 @@ MMLPROPS="-Dopennlp.en-sent.bin.path=$OPENNLP_MODELS/en-sent.bin \
-Dopennlp.en-chunker.bin.path=$OPENNLP_MODELS/en-chunker.bin \
-Dlog4j.configurationFile=$PROJECTDIR/config/log4j2.xml \
-Dmetamaplite.entitylookup.resultlength=1500 \
-Dmetamaplite.ivf.cuiconceptindex=$PROJECTDIR/data/ivf/strict/indices/cuiconcept \
-Dmetamaplite.ivf.firstwordsofonewideindex=$PROJECTDIR/data/ivf/strict/indices/first_words_of_one_WIDE \
-Dmetamaplite.ivf.cuisourceinfoindex=$PROJECTDIR/data/ivf/strict/indices/cuisourceinfo \
-Dmetamaplite.ivf.cuisemantictypeindex=$PROJECTDIR/data/ivf/strict/indices/cuist \
-Dmetamaplite.ivf.varsindex=$PROJECTDIR/data/ivf/strict/indices/vars \
-Dmetamaplite.ivf.meshtcrelaxedindex=$PROJECTDIR/data/ivf/strict/indices/meshtcrelaxed \
-Dmetamaplite.index.directory=$PROJECTDIR/data/ivf/2019AB/USAbase \
-Dmetamaplite.excluded.termsfile=$PROJECTDIR/data/specialterms.txt"

CLASSPATH=$CONFIGDIR
java $MML_JVM_OPTS $MMLPROPS -cp $PROJECTDIR/target/metamaplite-${MML_VERSION}-standalone.jar gov.nih.nlm.nls.ner.MetaMapLite $*
MML_JAR=$PROJECTDIR/target/metamaplite-${MML_VERSION}-standalone.jar
MML_CLASSPATH=$PROJECTDIR/target/classes:$PROJECTDIR/build/classes:$PROJECTDIR/classes:$PROJECTDIR:$MML_JAR

java $MML_JVM_OPTS $MMLPROPS -cp $MML_CLASSPATH gov.nih.nlm.nls.ner.MetaMapLite $*

15 changes: 7 additions & 8 deletions metamaplite.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ MMLPROPS="-Dopennlp.en-sent.bin.path=$OPENNLP_MODELS/en-sent.bin \
-Dopennlp.en-chunker.bin.path=$OPENNLP_MODELS/en-chunker.bin \
-Dlog4j.configurationFile=$PROJECTDIR/config/log4j2.xml \
-Dmetamaplite.entitylookup.resultlength=1500 \
-Dmetamaplite.ivf.cuiconceptindex=$PROJECTDIR/data/ivf/@@year@@/@@subset@@/indices/cuiconcept \
-Dmetamaplite.ivf.firstwordsofonewideindex=$PROJECTDIR/data/ivf/@@year@@/@@subset@@/indices/first_words_of_one_WIDE \
-Dmetamaplite.ivf.cuisourceinfoindex=$PROJECTDIR/data/ivf/@@year@@/@@subset@@/indices/cuisourceinfo \
-Dmetamaplite.ivf.cuisemantictypeindex=$PROJECTDIR/data/ivf/@@year@@/@@subset@@/indices/cuist \
-Dmetamaplite.ivf.varsindex=$PROJECTDIR/data/ivf/@@year@@/@@subset@@/indices/vars \
-Dmetamaplite.ivf.meshtcrelaxedindex=$PROJECTDIR/data/ivf/@@year@@/@@subset@@/indices/meshtcrelaxed \
-Dmetamaplite.index.directory=$PROJECTDIR/data/ivf/@@year@@/@@subset@@ \
-Dmetamaplite.excluded.termsfile=$PROJECTDIR/data/specialterms.txt"

CLASSPATH=$CONFIGDIR
java $MML_JVM_OPTS $MMLPROPS -cp $PROJECTDIR/target/metamaplite-${MML_VERSION}-standalone.jar gov.nih.nlm.nls.ner.MetaMapLite $*
MML_CLASSPATH=$PROJECTDIR/target/classes:$PROJECTDIR/build/classes:$PROJECTDIR/classes:$PROJECTDIR:$MML_JAR

MML_JAR=$PROJECTDIR/target/metamaplite-${MML_VERSION}-standalone.jar
MML_CLASSPATH=$PROJECTDIR/target/classes:$PROJECTDIR/build/classes:$PROJECTDIR/classes:$PROJECTDIR:$MML_JAR

java $MML_JVM_OPTS $MMLPROPS -cp $MML_CLASSPATH gov.nih.nlm.nls.ner.MetaMapLite $*

12 changes: 12 additions & 0 deletions src/main/java/gov/nih/nlm/nls/metamap/lite/IVFLookup.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ public IVFLookup(Properties properties) {

// Implementation of gov.nih.nlm.nls.metamap.lite.DictionaryLookup

public static void expandIndexDir(Properties properties, String indexDirName) {
if (indexDirName != null) {
properties.setProperty("metamaplite.ivf.cuiconceptindex", indexDirName + "/indices/cuiconcept");
properties.setProperty("metamaplite.ivf.firstwordsofonewideindex", indexDirName + "/indices/first_words_of_one_WIDE");
properties.setProperty("metamaplite.ivf.cuisourceinfoindex", indexDirName + "/indices/cuisourceinfo");
properties.setProperty("metamaplite.ivf.cuisemantictypeindex", indexDirName + "/indices/cuist");
properties.setProperty("metamaplite.ivf.varsindex", indexDirName + "/indices/vars");
properties.setProperty("metamaplite.ivf.meshtcrelaxedindex", indexDirName + "/indices/meshtcrelaxed");
}
}

public void init(Properties properties) {
try {
Expand All @@ -84,6 +94,8 @@ public void init(Properties properties) {
Integer.parseInt(properties.getProperty("metamaplite.entitylookup3.maxtokensize",
Integer.toString(MAX_TOKEN_SIZE)));

// fill-in properties for individual indexes
expandIndexDir(properties, properties.getProperty("metamaplite.index.directory"));
this.mmIndexes = new MetaMapIvfIndexes(properties);
this.cuiPreferredNameCache = new CuiPreferredNameCache(this, properties);
this.cuiSemanticTypeSetIndex = new CuiSemanticTypeSetIndex(mmIndexes);
Expand Down
Loading

0 comments on commit 5490413

Please sign in to comment.