Lingorithm Named Entity Recognition
Project description
Lingorithm Named Entity Recognition
This package is the core function for any NLP operation or pacakge used by lingorithm.
Installation
Use the package manager pip to install lner.
pip install lner
Usage
Data
Input data is a list of dict
entities = {
'countries': [
{values: ['Afghanistan'], key: 'AF'},
{values: ['Åland Islands'], key: 'AX'},
....
{values: ['Zimbabwe'], key: 'ZW'}
],
"colors": [
{
"key": "black",
"values": ["black"],
"meta": {
"rgba": [255,255,255,1],
"hex": "#000"
}
},
...
"meta": {
"rgba": [0,255,0,1],
"hex": "#0F0"
}
},
]
}
sentences = [
('Egypt\'s flag containes black, white and red.', [
(0, 5, 'countries'),
(23, 28, 'colors'),
(40, 43, 'colors')
])
.....
]
import lner
ner = lner('en', entities, sentences)
ner.process()
print(ner.data)
# list of Tuples
# [
# (['Green', ',', 'yellow', 'are', 'the', 'main', 'colors', 'for', 'Zimbabwe', '\'s' 'flag','.'],
# ['B-colors', 'O', 'B-colors', 'O', 'O', 'O', 'O', 'O', 'B-countries', 'O', 'O', 'O'])
# ]
ner.train(epochs=20, batch_size=8, model_name="countries_colors_v1")
entities, tokens = ner.recognize("yellow is the main colors for Northern Mariana Islands flag.")
print(entities)
# [
# [
# {
# 'key': 'yellow',
# 'meta': {
# 'rgba': [
# 255,
# 255,
# 0,
# 1
# ],
# 'hex': '#FF0'
# },
# 'value': 'yellow',
# 'entity': 'colors'
# },
# {
# 'key': 'MP',
# 'meta': None,
# 'value': 'Northern Mariana Islands',
# 'entity': 'countries'
# }
# ]
# ]
print(tokens)
# [['yellow', 'is', 'the', 'main', 'colors', 'for', 'Northern', 'Mariana', 'Islands', 'flag', '.']]
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lner-0.1.0.tar.gz
(2.7 kB
view details)
File details
Details for the file lner-0.1.0.tar.gz
.
File metadata
- Download URL: lner-0.1.0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e5e26d142917893c09aa5160aa24803eac1211e5fc67583301dceb944521c2b |
|
MD5 | 618adda7af927eef307da7cf6516fc53 |
|
BLAKE2b-256 | 10aa3fe17e116bddf3372f6ee2cd9eecaed03dd5ff1f0b5c61455e34b21dd5ad |