Giter Site home page Giter Site logo

rockt / chemspot Goto Github PK

View Code? Open in Web Editor NEW
45.0 5.0 9.0 46.67 MB

ChemSpot is a named entity recognition tool for identifying mentions of chemicals in natural language texts, including trivial names, drugs, abbreviations, molecular formulas and IUPAC entities. Since the different classes of relevant entities have rather different naming characteristics, ChemSpot uses a hybrid approach combining a Conditional Random Field with a dictionary. ChemSpot is released under the Common Public License 1.0.

Home Page: https://www.informatik.hu-berlin.de/forschung/gebiete/wbi/resources/chemspot/chemspot/

License: Other

Java 99.45% Scala 0.55%

chemspot's Introduction

ChemSpot

ChemSpot 2.0 is a set of tools for named entity recognition and classification of chemicals in natural language texts, including trivial names, abbreviations, molecular formulas and IUPAC entities. Since the different classes of relevant entities have rather different naming characteristics, ChemSpot uses a combined approach of employing a Conditional Random Field and a dictionary, as well as pattern-based recognition, a classifier model and several methods for consolidating all annotations. ChemSpot also performs named entity normalization by assigning identifiers from several chemical databases. It achieves an F1 measure of 79.0% on the SCAI corpus.

ChemSpot is released under the Common Public License 1.0 (see LICENSE).

The warning message "Couldn't open cc.mallet.util.MalletLogger resources/logging.properties file." can be ignored.

Running ChemSpot:

  • Extract chemspot.zip into a directory
unzip chemspot.zip
  • To tag a sample text file, run
java -Xmx16G -jar chemspot.jar -t sample.txt -o predict.txt
  • To update the dictionary, run
java -Xmx5G -jar chemspot.jar -u

If you would like to reduce memory consumption and do not need ChemSpot to assign identifiers to chemicals, you can run it without the ids file. Note however that this will completely disable named entity normalization.

java -Xmx12G -jar chemspot.jar -t sample.txt -o predict.txt -i ""

If you would like to further reduce the memory footprint, you can run ChemSpot without the dictionary or multi-class model as well. Note however that this will result in worse NER performance.

java -Xmx7G -jar chemspot.jar -t sample.txt -o predict.txt -i "" -d ""
java -Xmx9G -jar chemspot.jar -t sample.txt -o predict.txt -i "" -M ""

Parameters

  • arguments:

    • -m path to a CRF model file (internal default model file will be used if not provided)
    • -s path to a OpenNLP sentence model file (internal default model file will be used if not provided)
    • -d path to a zipped set of brics dictionary automata (parameter defaults to 'dict.zip' if not provided)"
    • -i path to a zipped tab-separated text file representing a map of terms to ids (parameter defaults to 'ids.zip' if not provided)
    • -M path to a multi-class model file (parameter defaults to 'multiclass.bin' if not provided)
  • flags:

    • -e if this flag is set, the performance of ChemSpot on an IOB gold-standard corpus (cf. -c) is evaluated"
    • -u if this flag is set, ChemSpot will update the dictionary and ids file
    • -T number of threads to create when processing a document collection
  • input control:

    • -c path to a directory containing corpora in IOB format
    • -g path to a directory containing gzipped text files
    • -t path to a text file
    • -f path to a directory of text files
  • output control:

    • -o path to output file
    • -I if this flag is set, the output will be converted into the IOB format

Using ChemSpot in your Code

ChemSpot tagger = ChemSpotFactory.createChemSpot("dict.zip", "ids.zip", "multiclass.bin");
String text = "The abilities of LHRH and a potent LHRH agonist ([D-Ser-(But),6, " +
  "des-Gly-NH210]LHRH ethylamide) inhibit FSH responses by rat " +
  "granulosa cells and Sertoli cells in vitro have been compared.";

for (Mention mention : tagger.tag(text)) {
  System.out.printf("%d\t%d\t%s\t%s\t%s,\t%s%n", 
    mention.getStart(), mention.getEnd(), mention.getText(), 
    mention.getCHID(), mention.getSource(), mention.getType().toString());
}

Reproducing our Results

  • Download the SCAI corpus (chemicals-test-corpus-27-04-2009-v3.iob.gz) and put it in the same directory
  • To reproduce our results, run
java -Xmx16G -jar chemspot.jar -c chemicals-test-corpus-27-04-2009-v3.iob.gz -o predict.txt -e

Acknowledgements

We would like to thank Daniel Lowe and Philippe Thomas for many valuable suggestions.

chemspot's People

Contributors

rockt avatar thuber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

chemspot's Issues

Improve match expansion

In addition to #15, improve match expansion in order to not expand matches for terms such as "non-cholesterol"

Fix application parameter settings

Certain parameter combinations for the ChemSpot main application produce a strange and somewhat arbitrary behavior. This should be changed so that all parameters work as expected.

Maven deployment

ChemSpot can be installed via Maven, but it would also be nice to automatically create a runnable jar, copy all required files and optionally tar/compress them

Improve normalization

Find more (offline) sources to retrieve IDs for chemicals from and integrate them into ChemSpot

Brics error when initializing ChemSpot

When calling ChemSpot from within a different Java project, the dictionary fails to load. Perhaps this problem is related to #22?

Failed initializing ChemSpot.
org.apache.uima.resource.ResourceInitializationException: Initialization of annotator class "de.berlin.hu.uima.ae.tagger.brics.BricsTagger" failed. (Descriptor: jar:file:/media/Data/workspaces/wbi/prototype/lib/chemspot.jar!/desc/ae/tagger/BricsTaggerAE.xml)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:254)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:158)
at org.uimafit.factory.AnalysisEngineFactory.createPrimitive(AnalysisEngineFactory.java:403)
at de.berlin.hu.chemspot.ChemSpot.(ChemSpot.java:118)
at ChemSpotRunner.main(ChemSpotRunner.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.apache.uima.resource.ResourceInitializationException
at de.berlin.hu.uima.ae.tagger.brics.BricsTagger.initialize(BricsTagger.java:59)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:252)
... 9 more
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:214)
at java.util.zip.ZipFile.(ZipFile.java:144)
at java.util.zip.ZipFile.(ZipFile.java:115)
at de.berlin.hu.uima.ae.tagger.brics.BricsMatcher.(BricsMatcher.java:42)
at de.berlin.hu.uima.ae.tagger.brics.BricsTagger.initialize(BricsTagger.java:55)
... 10 more

Tagging text is slow

934a481

    public List<Mention> tag(String text) throws UIMAException {
        JCas jcas = JCasFactory.createJCas(typeSystem);
        jcas.setDocumentText(text);
        PubmedDocument pd = new PubmedDocument(jcas);
        pd.setBegin(0);
        pd.setEnd(text.length());
        pd.setPmid("");
        pd.addToIndexes(jcas);
        return tag(jcas);
    }

This is slow since a jcas is initialized each time we want to tag a string. Instead, hold back one pre-intitialized jcas and reset it each time this method gets called.

Tagging text from command-line does not work

java -jar -Xmx9G chemspot.jar -m crf_model.bin -s sentence_model.bin.gz -d dict.zip -i ids.zip -t sample.txt -o predict.iob

Exception in thread "main" java.io.IOException: There are no corpora defined.
at de.berlin.hu.chemspot.App.promptForCorpus(App.java:146)
at de.berlin.hu.chemspot.App.main(App.java:270)

Suppress "Couldn't open edu.umass.cs.mallet.base.util.MalletLogger resources/logging.properties file" error

Grab the missing 'logging.properties' file at

https://github.com/clulab/banner/blob/master/src/main/java/edu/umass/cs/mallet/base/util/resources/logging.properties

Open the 'ChemSpot/chemspot-2.0/chemspot.jar' file using an archive manager (me, Ubuntu: Archive Manager); add the 'logging.properties' file to the following location:

cc.mallet.util.resources.logging.properties

[i.e., "/cc/mallet/util/resources/logging.properties"]

Improve recognition of short terms

A lot of false positives are produced by short terms like "IOP", "BMP", "CIA" or "SAM". Find a way to deal with these matches properly (and maybe separately, in a new component?).

Unable to access jarfile chemspot.jar

HI I have tried to follow the commands with some sample text but received the following error on Ubuntu 16.04.

Unable to access jarfile chemspot.jar

change scala version to 2.11.8

ChemSpot can be wonderful if we could use it with scala 2.11.8 in our NLP pipeline. However, we have encountered a problem that class file for scala.ScalaObject not found.
The reason is why de.berlin.hu.enumed.EntityTagger is using scala.ScalaObject and we could not change compiled code.
Is there any chance to get the source code of below maven dependency?

eumed
eumed-rg
1.0.0

If we can get the source code, we could update your ChemSpot code and can use it with state-of-art libraries.

Thanks.

Tagging 1000 documents

My question is not really an issue, I just want suggestions, if for example we want to annotate 1000 text files, how can I automate it?

java -Xmx16G -jar chemspot.jar -t sample.txt -o predict.txt
The above line tags one file but I want to tag 1000 files and I can't do it manually. What is the alternative to this?

Solve problem with abstract entities in CRAFT corpus

Find a graceful way to deal with the problem of more abstract entities such as "protein" or "molecule" in the CRAFT corpus, without just "removing unwanted entities" that ChemSpot doesn't find (wasn't designed to find)

Make ChemSpot configurable

Add option to load ChemSpot settings from configuration file. Particularly, it would be nice to also have parameters for turning certain components (e.g. SumTagger, CRF) on or off.

Loading resources from within the jar fails

It seems that some resources are not properly loaded from within the jar, i.e.,
resources/chebi/chebi_ontology_fulldepth.txt
resources/prefixes.txt
resources/phare.txt
resources/suffixes-filtered.txt

Use this.getClass().getClassLoader().getResource(PATH TO FILE) to access them.

Seeking description of the columns in the output

Hey, I can guess at what several of the columns in the output are, but have no idea for a number of them. Is there a data dictionary somewhere? E.g., col1 = 'this'; col2 = 'that', etc? Couldn't find such after a non-trivial search.

Thanks for the fabulous tool!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.