Metamap is a tool to recognize the UMLS concepts in a text. For using Metamap, a UMLS license is needed. Sign up for a license at https://www.nlm.nih.gov/research/umls/ .
- Metamap full version
- For windows version, please download Metamap 2013 or Metamap 2014
- Download link: https://metamap.nlm.nih.gov/MainDownload.shtml
- Metamap Java Api
- Download link: https://metamap.nlm.nih.gov/JavaApi.shtml
- Download corresponding version to Metamap full version.
- Java Runtime Environment (JRE) 1.8 or later
-
After Metamap full version and Java Api downloaded, two archives, for example public_mm_win32_javaapi_2014.zip and public_mm_win32_main_2014.zip, would be obtained.
In the directory where you extracted the Public Metamap (for example: public_mm_win32_javaapi_2014.zip) (the directory containing the public_mm directory) extract the javaapi archive.
-
Click install metamap.bat in the directory of public_mm:
Make sure the Metamap directory is correct.
-
Next:
Copy and paste the directory of JRE installed in your PC.
-
Next: If nothing wrong, you will have a following window:
The Metamap server (mmserver) must first be running to use the Java API. Before running mmserver, skrmedpostctl_start and wsdserverctl_start(optional) should be running.
In a command prompt window use the following :
\public_mm> bin\skrmedpostctl_start.bat
If you wish to the Word Sense Disambiguation (WSD) Server (optional), start it also.
\public_mm> bin/wsdserverctl_start.bat
Then start the MetaMap server:
\public_mm> bin/mmserver14.bat
Note: All the servers should be running in seperate cmd windows.
If you use eclipse, there are two jar files you should add in libarary path.
./public_mm/src/javaapi/dist/MetaMapApi.jar
./public_mm/src/javaapi/dist/prologbeans.jar
Here is a sample for using Metamap java Api. For more usage please check JavaDoc Documentation for the MetaMap Java API.
import java.util.List;
import gov.nih.nlm.nls.metamap.Ev;
import gov.nih.nlm.nls.metamap.Mapping;
import gov.nih.nlm.nls.metamap.MetaMapApi;
import gov.nih.nlm.nls.metamap.MetaMapApiImpl;
import gov.nih.nlm.nls.metamap.Negation;
import gov.nih.nlm.nls.metamap.PCM;
import gov.nih.nlm.nls.metamap.Result;
import gov.nih.nlm.nls.metamap.Utterance;
public class MetaMapDemo {
public static void main(String[] args) throws Exception{
String input = "high blood pressure";
MetaMapApi api = new MetaMapApiImpl();
System.out.println("api instanciated");
List<Result> resultList = api.processCitationsFromString(input);
Resultresult = resultList.get(0);
List<Negation> negations = result.getNegationList();
for(Negation negation : negations){
System.out.println("conceptposition:"+ negation.getConceptPositionList());
System.out.println("concept pairs:"+ negation.getConceptPairList());
System.out.println("trigger positions: "+ negation.getTriggerPositionList());
System.out.println("trigger: "+ negation.getTrigger());
System.out.println("type: "+ negation.getType());
}
for(Utterance utterance : result .getUtteranceList()) {
System.out.println("Utterance:");
System.out.println(" Id: "+ utterance.getId());
System.out.println(" Utterance text: "+ utterance.getString());
System.out.println(" Position: "+ utterance.getPosition());
for(PCM pcm : utterance .getPCMList()) {
System.out.println("Mappings:");
for(Mapping map : pcm .getMappingList()) {
System.out.println("Phrase:");
System.out.println(" Map Score: "+ map.getScore());
for(Ev mapEv : map .getEvList()) {
System.out.println(" Score: "+ mapEv.getScore());
System.out.println(" Concept Id: "+ mapEv.getConceptId());
System.out.println(" Concept Name: "+ mapEv.getConceptName());
System.out.println(" Preferred Name: "+ mapEv.getPreferredName());
System.out.println(" Matched Words: "+ mapEv.getMatchedWords());
System.out.println(" Semantic Types: "+ mapEv.getSemanticTypes());
System.out.println(" MatchMap: "+ mapEv.getMatchMap());
System.out.println(" MatchMap alt. repr.: "+ mapEv.getMatchMapList());
System.out.println(" is Head?: "+ mapEv.isHead());
System.out.println(" is Overmatch?: "+ mapEv.isOvermatch());
System.out.println(" Sources: "+ mapEv.getSources());
System.out.println(" Positional Info: "+ mapEv.getPositionalInfo());
}
}
}
}
}
}
Here is the resutl:
api instanciated
Utterance:
Id: 00000000.tx.1
Utterance text: high blood pressure
Position: (0, 19)
Mappings:
Phrase:
Map Score: -1000
Score: -1000
Concept Id: C0020538
Concept Name: Blood Pressure, High
Preferred Name: Hypertensive disease
Matched Words: [high, blood, pressure]
Semantic Types: [dsyn]
MatchMap: [[[1, 3], [1, 3], 0]]
MatchMap alt. repr.: [[[phrase start: 1, phrase end: 3], [concept start: 1, concept end: 3], lexical variation: 0]]
is Head?: true
is Overmatch?: false
Sources: [AOD, MSH, MTH, NCI, NLMSubSyn, OMIM, SNM, SNMI, SNOMEDCT_US]
Positional Info: [(0, 19)]
Phrase:
Map Score: -1000
Score: -1000
Concept Id: C2926615
Concept Name: High blood pressure
Preferred Name: Ever told by doctor or nurse that you have high blood pressure:Finding:Point in time:^Patient:Ordinal
Matched Words: [high, blood, pressure]
Semantic Types: [clna]
MatchMap: [[[1, 3], [1, 3], 0]]
MatchMap alt. repr.: [[[phrase start: 1, phrase end: 3], [concept start: 1, concept end: 3], lexical variation: 0]]
is Head?: true
is Overmatch?: false
Sources: [LNC, NLMSubSyn]
Positional Info: [(0, 19)]