Skip to main content

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


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)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page