Skip to content

Instantly share code, notes, and snippets.

@zabir-nabil
Created January 5, 2025 04:33
Show Gist options
  • Save zabir-nabil/609782f0b73b1adbd908ccc0a4ee748c to your computer and use it in GitHub Desktop.
Save zabir-nabil/609782f0b73b1adbd908ccc0a4ee748c to your computer and use it in GitHub Desktop.
Metamap Installation (Linux)

MetaMap Installation Tutorial

MetaMap is a tool developed by the National Library of Medicine for analyzing biomedical texts. Follow these steps to install and set up MetaMap on a Linux system.


Prerequisites

  1. Java Installation:

    • Ensure Java is installed:

      which java
      java -version

      The expected output should confirm an OpenJDK version, such as:

      openjdk version "1.8.0_275"
      OpenJDK Runtime Environment (build 1.8.0_275-b01)
      OpenJDK 64-Bit Server VM (build 25.275-b01, mixed mode)
      
    • If Java is not installed, install OpenJDK:

      sudo apt update
      sudo apt install openjdk-8-jdk
  2. Set the JAVA_HOME Environment Variable:

    • Find the Java path (if not already done):
      which java
    • Export the JAVA_HOME variable:
      export JAVA_HOME=/usr/bin/java
    • Verify:
      echo $JAVA_HOME

Step 1: Download MetaMap Files

  • Download the following files from the official MetaMap repository:
    1. public_mm_data_lite_usabase_2022aa.zip (data file)
    2. public_mm_linux_main_2020.tar.bz2 (main installation)
    3. public_mm_lite_3.6.2rc8_binaryonly.zip (optional MetaMap Lite)

Place the downloaded files in a directory of your choice, e.g., ~/metamap.


Step 2: Extract Files

  1. Extract Main Installation:

    bunzip2 -c public_mm_linux_main_2020.tar.bz2 | tar xvf -
  2. Extract Data Files: If needed, unzip the data files:

    unzip public_mm_data_lite_usabase_2022aa.zip

Step 3: Install MetaMap

  • Navigate to the bin directory of the extracted MetaMap files:
    cd ./bin
  • Run the installation script:
    ./install.sh

Step 4: Start Required Servers

MetaMap requires the following servers to run in the background:

  1. Start SKR/MedPost Part-of-Speech Tagger Server:

    ./bin/skrmedpostctl start

    Expected output:

    Starting skrmedpostctl:
    started.
    
  2. (Optional) Start the Word Sense Disambiguation (WSD) Server: If you plan to use the WSD feature (-y flag):

    ./bin/wsdserverctl start

Step 5: Verify the Installation

  • Run the following command to check if MetaMap is working:
    ./bin/metamap -V
    You should see the version details of MetaMap.

Step 6: Using MetaMap

MetaMap can now be used for text processing. For example:

./bin/metamap input.txt output.txt
  • Replace input.txt with your input file.
  • The results will be saved in output.txt.

Stopping the Servers

To stop the servers when done:

  1. Stop the SKR/MedPost Part-of-Speech Tagger Server:
    ./bin/skrmedpostctl stop
  2. Stop the WSD Server (if started):
    ./bin/wsdserverctl stop

Optional: Python Integration

For Python integration, you can follow this guide to interact with MetaMap through Python.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment