SpaCy annotator for Named Entity Recognition (NER) using ipywidgets.
Project description
spacy-annotator
spaCy annotator for Named Entity Recognition (NER) using ipywidgets. The annotator allows users to quickly assign custom labels to one or more entities in the text.
Features:
- The annotator supports pandas dataframe (see
pandas_annotations.py
): it adds annotations in a separate 'annotation' column of the dataframe; - If a spacy model is passed into the annotator, the model is used to identify entities in text.
This trick of pre-labelling the example using the current best model available allows for accelerated labelling - also known as of noisy pre-labelling; - The annotations adhere to spaCy format and are ready to serve as input to spaCy NER model.
No additional code required!
Note: not using pandas dataframe? No problem. You can always label entities from text stored in a simple python list (see list_annotations.py
).
Blog post: medium/enrico.alemani/spacy-annotator
Example code - pandas annotations
import pandas as pd
import re
from spacy_annotator.pandas_annotations import annotate as pd_annotate
# Data
df = pd.DataFrame.from_dict({'full_text' : ['New York is lovely but Milan is amazing!']})
# Annotations
pd_dd = pd_annotate(df,
col_text = 'full_text', # Column in pandas dataframe containing text to be labelled
labels = ['GPE', 'PERSON'], # List of labels
sample_size=1, # Size of the sample to be labelled
delimiter='~', # Delimiter to separate entities in GUI
model = None, # spaCy model for noisy pre-labelling
regex_flags=re.IGNORECASE # One (or more) regex flags to be applied when searching for entities in text
)
# Example output
pd_dd['annotations'][0]
Preview
Contributing
- Fork the repo on GitHub;
- Clone the project to your own machine;
- Commit changes to your own branch; and
- Push your work back up to your own fork;
- Submit a Pull request so that I can review your changes.
Version
ipywidgets: 7.5.1
re: 2.2.1
spacy: 2.2.4
References
spacy-annotator is based on spaCy and pigeon.
Many thanks to them for making their awesome libraries publicly available.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
spacy_annotator-1.1.tar.gz
(6.0 kB
view hashes)