named_entity_recogniser is a program for running named entity recognition on
input text using fine-tuned, BERT-based models.
named_entity_recogniser is written in Python (version 3.13 recommended). Downloads for Python can be found at https://www.python.org/downloads/.
Dependencies can be found in requirements.txt. To install them, run the command:
pip install -r requirements.txtInstalling dependencies in a virtual environment such as venv or using a package
manager such as conda is recommended.
Make sure that NER_MODEL_NAME in .env is set to the path of a BERT-variant
fine-tuned for NER on Hugging Face, and then set the environment variables.
For example, in bash:
set -a
. .env
set +aTo run inference on an input text, run the following command:
python -m src.app.main "Emmanuel Macron is the president of France."Output will be a list of tuples, with one tuple for each classified token from
the input text. The first item in each tuple is the token and the second item is
a predicted label.
For example:
[('emmanuel', 'I-PER'), ('macro', 'I-PER'), ('##n', 'I-PER'), ('is', 'O'), ('the', 'O'), ('president', 'O'), ('of', 'O'), ('france', 'I-MISC'), ('.', 'O')]The logging level can be set in .env. For example:
LOG_LEVEL=INFOIf no LOG_LEVEL is set, the default logging level will be INFO.
Tests can be found in the src/tests directory. To run them (using pytest),
run the following command:
python -m pytest -v src