Skip to main content

A library to train Named Entity Recognition on Spacy-based easily and quickly.

Project description

QuickEntity: Named Entity Recognition Training Module on Spacy-Based

Simple is better than complex

QuickEntity is a python module designed to help you train your own Named Entity Recognition (NER) model quickly and easily. With quick NER, you can customize model your NER model by providing your own list of named entities.

Features

  • Easy-to-use API for training NER models
  • Ability to set language and load custom named entity lists
  • Automatic saving of trained model to disk

Dependencies

QuickEntity requires:

  • spacy (>= 3.5.0)
  • nltk (>=3.7)

Installation

You can install QuickEntity by runing the following command:

pip install quickentity

Usage

Setting Up

To use QuickEntity, you need to import the QuickEntity module

from quickentity import QuickEntity

Initialize the QuickEntity object

Then, you need to create an instance of the QuickEntity class:

phrase = "Steve played a pivotal role in the development of Apple, the company responsible for creating innovative products such as the iPad"

QE = QuickEntity(language="en", phrase=phrase, save_model=False)

The language parameter specifies the language of the text you want to train the model on (default is "en"). The phrase parameter is an exemple text phrase used to create a Doc object for training. The save_model parameter specifies whether to save the treined model to disk or not (default is True).

Reading Named Entity Lists

Before training the model, you need to load entity list using the read_json

ent_list = QE.read_json("entities.json")

The named entity list should be a JSON file with a dictionary of entities and their labels with prefix B-. Here's an example:

{ "Apple":"B-ORG", "Steve":"B-PERSON", "iPad":"B-PRODUCT" }

Process a text with the loaded entities

Next, process your text data using the process_text method to obtain the list of words, spaces, and entity labels. Look how to do it:

model = QE.process_text(ent_list)

Training the dat

Once you've processed your text data, you should train the model using the train method:

QE.train(model)

Display the annotated text

Visualize the results of your model using the show method:

QE.show()

Complete example

`from quickentity import QuickEntity

words = "Steve played a pivotal role in the development of Apple, the company responsible for creating innovative products such as the iPad."

config the QuickEntity, phrase is requerid,language is "en" by default, save_model is True by default.

QE = QuickEntity(language="en",phrase=words, save_model=True)

#load entities file in json format ent_list = QE.read_json("ent_list.json")

process the text data to associate entities labels

model = QE.process_text(ent)

train de model

QE.train(model)

output :

file ./train.spacy saved on disk

view in a jupyter-based notebook.

QE.show() `

Here's the result:

Example quickentity

API Reference

QuickEntity(language, phrase, save_model)

Create an instance of the QuickEntity class.

Parameters

  • language (string): Language for the NER model. Default is "en".
  • phrase (string): Example text used for training.
  • save_model (bool): Whether to save the treined model to disk. Default is True

Methods

set_language(language): Set the language of the NER model.

Parameters

  • language (string): Language for NER model.

Methods

read_json(file): Load named entities from a JSON file.

Parameters

  • file(string): Path to JSON file containing named entities.

Methods

process_text(text): Process the entities obtained from the read_json to obtain the list of words, spaces, and entity labels.

Parameters

  • text(object): Object processed with read_json method.

Methods

train(model): Train the NER model using the processed training data.

Parameters

  • model(object) : Object obtained from the process_text method.

Methods

show() : Visualize the results of the trained model.

Parameters

  • None.

Help and Support

Comunication

License

This project is licensed under the MIT License

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

quickentity-0.0.1.tar.gz (25.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quickentity-0.0.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for quickentity-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d307f22a1f8674e86bdf2644e8f900ea43dae8cb5296532fe04bb06db6997290
MD5 967900fd58cdd69ef41a81b8d356e646
BLAKE2b-256 5d7311e03e28a4d232625dd53eb338101c6e222818e9225c04929f7900024f6c

See more details on using hashes here.

File details

Details for the file quickentity-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: quickentity-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for quickentity-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a1d54e968cae4d3323ae24072ec881952aaeb1d3e42a6b309a019635bfe6fe13
MD5 19ce0d47f1aaf53f2e14df8ff2221bfb
BLAKE2b-256 45411d4f55247f26da0d15fb62527bd1536580e2b1bc2bc27a9b58c10728c0b2

See more details on using hashes here.

Supported by

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