Drug Named Entity Recognition
raw JSON → 2.0.9 verified Fri May 01 auth: no python
Drug Named Entity Recognition (NER) library to identify and resolve drug names in text, with entity linking to RxNorm and other drug databases. The current version is 2.0.9, supporting Python >=3.6. It provides pre-trained models for drug name extraction and normalization. The library is actively maintained with occasional releases.
pip install drug-named-entity-recognition Common errors
error ModuleNotFoundError: No module named 'scispacy' ↓
cause Missing scispacy dependency.
fix
Run:
pip install scispacy error OSError: [E050] Can't find model 'en_core_sci_sm'. ↓
cause The spaCy model required by scispacy is not installed or not found.
fix
Run:
pip install scispacy && python -m spacy download en_core_sci_sm error ValueError: DrugNER model not loaded. Try again later. ↓
cause The model download failed or is corrupted.
fix
Delete the cache directory (~/.drug_named_entity_recognition) and run again.
Warnings
gotcha The first run downloads a large model (~2GB). Ensure sufficient disk space and a stable internet connection. The model is cached afterwards. ↓
fix Pre-download the model using: `pip install drug-named-entity-recognition && python -c \"from drug_named_entity_recognition import DrugNER; DrugNER()\"`
breaking In version 2.0, the API changed from `DrugNER().get_entities(text)` to `DrugNER().find_entities(text)`. Old code will break. ↓
fix Use `find_entities()` instead of `get_entities()`.
deprecated The `DrugNER` constructor no longer accepts a `model_size` argument in 2.0.0+ (was `'small'`, `'medium'`, `'large'`). ↓
fix Remove the `model_size` argument. The model is now fixed.
Imports
- DrugNER
from drug_named_entity_recognition import DrugNER
Quickstart
from drug_named_entity_recognition import DrugNER
drug_ner = DrugNER()
text = "Patient was given 500mg of Paracetamol and 10mg of Diazepam."
entities = drug_ner.find_entities(text)
print(entities)
# Example output: [{'name': 'paracetamol', 'rxnorm': '161', 'start': 24, 'end': 35, ...}, ...]