Skip to main content

CPREx - Chemical Properties Relation Extraction

License python_version

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 pipeline to perform NER and RE.

The pipeline performs the following steps

flowchart LR
    crawler("`**crawler**
    fetch PDF articles
    from online archives`")
    parser("`**parser**
    Extract text
    from PDF`")
    crawler --> parser
    parser --> ner
    ner("`**NER**
    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*`")

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 and its extension 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 JDKs from 1.11 to 1.17.

Install via PyPI

You can install CPREx directly with pip:

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.

git clone git@github.com: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 and its extension 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

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

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 (NER) of chemical compounds and Relation Extraction (RE), CPREx requires some pretrained models. These models can be installed by running

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.

Release files for cprex 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cprex 0.3.0
File Size Uploaded
cprex-0.3.0.tar.gz 30.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cprex 0.3.0
File Interpreter ABI Platform
cprex-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 67.6 kB

Release files / cprex-0.3.0.tar.gz

Download URL cprex-0.3.0.tar.gz
Size 30.8 kB
Tags Source
SHA-256 checksum
How to use checksums
53a4ad9feec2cedd80160319c7be083604fd31c5d3d8753695d427da3a59f1ac
BLAKE2b-256 checksum
How to use checksums
c766ca61d1523e6392847b815e382c458fecd0b247abda1ea782e44888973dd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / cprex-0.3.0-py3-none-any.whl

Download URL cprex-0.3.0-py3-none-any.whl
Size 36.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae170a4fca8538dfaa7b02a23cb2aa265f272e25c7190d6669d9acdffed10852
BLAKE2b-256 checksum
How to use checksums
ebcfeb463bbec39f46cfc0ba1f0eb91133094d95d6ab3f2658c6bfcdb36113e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page