Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasrenault committed Mar 8, 2024
1 parent 2c21286 commit da249bf
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 6 deletions.
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2024 Jonas Renault

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
85 changes: 79 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CPREx - Chemical Properties Relation Extraction

[![License](https://img.shields.io/badge/License-MIT-yellow)](LICENSE)
![python_version](https://img.shields.io/badge/Python-%3E=3.10-blue)

CPREx is an end to end tool for Named Entity Recognition (NER) and Relation Extraction (RE) specifically designed for chemical compounds and their properties. The goal of the tool is to identify, extract and link chemical compounds and their properties from scientific literature. For ease of use, CPREx provides a custom [spacy](https://spacy.io/) pipeline to perform NER and RE.

The pipeline performs the following steps
Expand All @@ -10,18 +13,88 @@ flowchart LR
fetch PDF articles
from online archives`")
parser("`**parser**
Extract text from PDF`")
Extract text
from PDF`")
crawler --> parser
parser --> ner
ner("`**NER**
extract named entities`")
ner --> chem[Chem] --> rel
ner --> prop[Property] --> rel
ner --> quantity[Value] --> rel
extract named
entities`")
ner --> chem["`**Chem**
*1,3,5-Triazine*
*Zinc bromide*
*C₃H₄N₂*`"] --> rel
ner --> prop["`**Property**
*fusion enthalpy*
*Tc*`"] --> rel
ner --> quantity["`**Value**
*169°C*
*21.49 kJ/mol*`"] --> rel
rel("`**Relation Extraction**
link entities`")
rel --> res
res("`**(Chem, Property, Value)**
*2,2'-Binaphthalene*, ΔHfus, 38.9 kJ/mol`")
*2,2'-Binaphthalene, ΔHfus, 38.9 kJ/mol*`")
```

## Installation

CPREx works with a recent version of python (**>=python 3.11**). Make sure to install CPREx in a virtual environment of your choice.

CPREx depends on [GROBID](https://github.com/kermitt2/grobid) and its extension [grobid-quantities](https://github.com/lfoppiano/grobid-quantities) for parsing PDF documents and extracting quantities from their text. In order to install and run GROBID, a JDK must also be installed on your machine. [GROBID currently supports](https://grobid.readthedocs.io/en/latest/Install-Grobid/) JDKs from **1.11 to 1.17**.

### Install via PyPI

You can install CPREx directly with pip:

```console
pip install cprex
```

### Install from github

This installation is recommended for users who want to customize the pipeline or train some models on their own dataset.

Clone the repository and install the project in your python environment.

```console
git clone [email protected]:jonasrenault/cprex.git
cd cprex
pip install --editable .
```

Any modifications you make to the cprex codebase will be immediatly reflected thanks to the `--editable` option.

### Install grobid and models

#### Installing and running grobid

CPREx depends on [GROBID](https://github.com/kermitt2/grobid) and its extension [grobid-quantities](https://github.com/lfoppiano/grobid-quantities) for parsing PDF documents and extracting quantities from their text.

For convenience, CPREx provides a command line interface (CLI) to install grobid and start a grobid server.

Run

```console
cprex install-grobid
```

to install a grobid server and the grobid-quantities extension (by default, grobid and models required by CPREx are installed in a `.cprex` directory in your home directory).

Run

```console
cprex start-grobid
```

to start a grobid server and enable parsing of PDF documents from CPREx.

#### Installing NER et REL models

To perform Named Entity Recognition of chemical compounds and Relation Extraction, CPREx requires some pretrained models. These models can be installed by running

```console
cprex install-models
```

This will install a PubmedBert model finetuned on the NLM-CHEM corpus for extraction of chemical named entities. This model was finetuned by the [BioCreative VII track](https://biocreative.bioinformatics.udel.edu/tasks/biocreative-vii/track-2/).

0 comments on commit da249bf

Please sign in to comment.