How lasigebiotm/bent works
Project type and purpose
• BENT is an open-source Python library and CLI tool that implements a biomedical entity extraction pipeline combining Named Entity Recognition (NER) and Named Entity Linking (NEL).
• Its primary use cases are: a) entity recognition, b) entity linking, or c) both in batch (files) or on strings.
Key components from the file tree & README
• CLI & orchestrator:
• bent/annotate.py – entry point for bt.annotate(...)
• bent/get_kbs.py, bent/get_data.sh, bent/get_kb_dicts.sh – scripts to download external KBs
• bent/setup_package.sh & wrapper – installer for non-Python dependencies and data
• Core modules (in bent/src):
• NER: bent/src/ner.py
• NEL: two interchangeable back-ends under bent/src/NILINKER and bent/src/REEL
• Abbreviation detection: bent/src/abbreviation_detector/run.py
• Utility modules: bent/src/utils.py, bent/src/cfg.py, bent/src/classes.py
• Dictionaries: bent/src/dicts – code to build/load knowledge-base dicts
• External dependencies: TensorFlow/PyTorch models (hidden), Java for REEL’s ppr_for_ned_all.java, plus large KB data (MEDIC, CHEBI, etc.)
1. CLI / API Layer (“bent.annotate”)
2. Configuration Loader (cfg.py)
3. Pre-processing & Abbrev Detector
4. NER Module
5. NEL Module (plugin interface)
– NILINKER sub-component
– REEL sub-component
6. Dictionary Manager (dicts/ generate_dicts.py & KB store)
7. Output Writer (annotation files)
8. External KB Data Repositories (ontologies, databases)
9. Setup / Data Download Scripts
• CLI → Config Loader → (Pre-processing → Abbrev Detector)
• Pre-processing → NER → NEL
• NEL → Dictionary Manager → External KB Data
• NEL → Output Writer → Annotation Files
• Setup Scripts → External KB Data → Dictionary Manager
c. Architectural patterns & principles
• Modular pipeline: clear stage separation (pre-process, NER, NEL, post-process)
• Plugin-style NEL: interchangeable NILINKER vs REEL back-ends
• Single responsibility: each script/module has a focused task
d. Key technologies
• Python packaging (setup.py, entry_points)
• Shell scripts for data management
• Java runtime for REEL’s graph-based linking
• Sphinx for documentation (docs/)
• Blue for core Python modules
• Green for data/KB components
• Orange for external scripts/runtimes
• Rectangles for code modules