A spaCy extension to map NER labels.
Project description
Label Mapper is a spaCy factory that can receive a mapping dictionary that changes the labels for entities. It should come at the end of the pipeline or after the NER or EntityRuler.
Installation
pip install label-mapper
Usage
nlp = spacy.load("en_core_web_sm")
label_map = {"GPE": "LOC"}
nlp.add_pipe(
"label_fixer",
last=True,
config={"label_map": label_map}
)
doc = nlp("We went into Yellowstone Park in Wyoming.")
for ent in doc.ents:
print(ent.text, ent.label_)
Output:
Yellowstone Park LOC
Wyoming LOC
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
label_mapper-0.0.1.tar.gz
(1.7 kB
view hashes)