Skip to main content

This repository contains an easy and intuitive approach to few-shot NER using most similar expansion over spaCy embeddings.

Project description

Concise Concepts

When wanting to apply NER to concise concepts, it is really easy to come up with examples, but pretty difficult to train an entire pipeline. Concise Concepts uses few-shot NER based on word embedding similarity to get you going with easy!

Install

pip install concise-concepts

Quickstart

import spacy
from spacy import displacy
import concise_concepts

data = {
    "fruit": ["apple", "pear", "orange"],
    "vegetable": ["broccoli", "spinach", "tomato"],
    "meat": ["beef", "pork", "fish", "lamb"]
}

text = """
    Heat the oil in a large pan and add the Onion, celery and carrots. 
    Then, cook over a medium–low heat for 10 minutes, or until softened. 
    Add the courgette, garlic, red peppers and oregano and cook for 2–3 minutes.
    Later, add some oranges and chickens. """

nlp = spacy.load("en_core_web_lg")
nlp.add_pipe("concise_concepts", config={"data": data})
doc = nlp(text)


options = {"colors": {"fruit": "darkorange", "vegetable": "limegreen", "meat": "salmon"},
           "ents": ["fruit", "vegetable", "meat"]}

displacy.render(doc, style="ent", options=options)

example

use specific number of words to expand over

data = {
    "fruit": ["apple", "pear", "orange"],
    "vegetable": ["broccoli", "spinach", "tomato"],
    "meat": ["beef", "pork", "fish", "lamb"]
}

topn = [50, 50, 150]

assert len(topn) == len

nlp.add_pipe("concise_concepts", config={"data": data, "topn": topn})

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

concise-concepts-0.2.3.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

concise_concepts-0.2.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file concise-concepts-0.2.3.tar.gz.

File metadata

  • Download URL: concise-concepts-0.2.3.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.2 Windows/10

File hashes

Hashes for concise-concepts-0.2.3.tar.gz
Algorithm Hash digest
SHA256 5b17dc6047525eb397e546a07da3e1416f07d01f2850be88862f36c885f42409
MD5 e2d89efe804d457a4431c48ae624a3f7
BLAKE2b-256 90bfbd7e550384b07d439e721e18bcd4bb698655c2575ad8bbe1f64309ce8a39

See more details on using hashes here.

File details

Details for the file concise_concepts-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for concise_concepts-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3ed4c025fd9dffe6c75d3e07554911bce1e20f33130978d1a6659f706bb3f619
MD5 9779d306a3bfaed69322707a9d5f17b8
BLAKE2b-256 7fc8297f4c6acaa2285aea634904e8c5bd5a7389a3c5b52e517ced6937f37312

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