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 details)

Uploaded Source

File details

Details for the file label_mapper-0.0.1.tar.gz.

File metadata

  • Download URL: label_mapper-0.0.1.tar.gz
  • Upload date:
  • Size: 1.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.5

File hashes

Hashes for label_mapper-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a00904bb4346a0841fcb72d100b93de0d20d4aa2a8efd65cf3513e7fc889f6da
MD5 2e5eee2d19f49cce7aed721c5a5d7ff2
BLAKE2b-256 9e8bc33e5ea4a590fda706dcb35f9c1ac5944434a3594b487b4df8fbb670cba6

See more details on using hashes here.

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