Skip to main content

This repository contains an easy and intuitive approach to zero-shot and few-shot NER using internal 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 word similarity based on few-shots to get you going with easy!

Install

pip install classy-classification

Quickstart

import spacy
import concise_concepts

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

text = """
    Heat the oil in a large pan and add the Onion, celery and carrots. 
    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)

print([(ent.text, ent.label_) for ent in doc.ents])
# Output:
#
# [('Onion', 'VEGETABLE'), ('Celery', 'VEGETABLE'), ('carrots', 'VEGETABLE'), 
#  ('garlic', 'VEGETABLE'), ('red peppers', 'VEGETABLE'), ('oranges', 'FRUIT'), 
#  ('chickens', 'MEAT')]

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.1.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

concise_concepts-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: concise-concepts-0.1.0.tar.gz
  • Upload date:
  • Size: 8.4 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.1.0.tar.gz
Algorithm Hash digest
SHA256 db6221fa3e317cb2485d7cbbb118ffe6e350502d0990eb3d7df131a52d5af751
MD5 f2e4193d473a839696153aa630e6a116
BLAKE2b-256 b3787d157fea5369d07c3ac258440ee2e11dbfedccbf49651852510fdc83c91d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concise_concepts-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 544396da221b13a9100c463f66098c23cb660567d7cc33754010e5599c563324
MD5 944b4b59130fb8e45032c77853832a55
BLAKE2b-256 693fa7cd68175c504657aff71b7719f73632d5639aefba579b487a2f77c1267b

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