NLP Annotation Helpers
Project description
NLP Annotations
A simple python package for dealing with different nlp annotation styles. No dependencies, and is very fast due to only using regular expressions.
You can install it with:
pip3 install nlp-annotations
Annotation Types
The following are the annotation types we support and how to convert it to another type.
Markdown Links
(Used by Rasa, etc...), these are in the form:
The weather is [sunny](weather) and the sky is [blue](color).
To convert this to an entity list you can:
from nlp_annotations import markdown_links2entity_list
markdown_links2entity_list("The weather is [sunny](weather) and the sky is [blue](color).")
# ('The weather is sunny and the sky is blue.', {'entities': [(15, 20, 'weather'), (36, 40, 'color')]})
For other situations that you may wish to add extra logic, there is also a generator:
from nlp_annotations import markdown_string_link_generator
for link in markdown_string_link_generator("The weather is [sunny](weather) and the sky is [blue](color)."):
print(f"- word={link.word}, entity={link.entity}, start={link.start}, end={link.end}")
# - word=sunny, entity=weather, start=15, end=31
# - word=blue, entity=color, start=47, end=60
Entity List
(Used by Spacy, etc...), these are in the form:
('The weather is sunny and the sky is blue.', {'entities': [(15, 20, 'weather'), (36, 40, 'color')]})
To convert this to a markdown links string, you can:
from nlp_annotations import entity_list2markdown_links
entity_list2markdown_links("The weather is sunny and the sky is blue.", [(15, 20, 'weather'), (36, 40, 'color')])
# 'The weather is [sunny](weather) and the sky is [blue](color).'
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
Built Distribution
File details
Details for the file nlp-annotations-1.0.1.tar.gz
.
File metadata
- Download URL: nlp-annotations-1.0.1.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed264eabba322f45dc3d29eec174401758718def59da26fdd02d0b22db38ad9f |
|
MD5 | f56bba8fb59ff7103e195c128b42fe87 |
|
BLAKE2b-256 | 48f6cf67f81475469585882dba4820f28ad08fdc1cf6aaa97124f37152371d80 |
File details
Details for the file nlp_annotations-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: nlp_annotations-1.0.1-py3-none-any.whl
- Upload date:
- Size: 2.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7efa97860266d195d11b2061a8d4f9e81ca0a932c048d760e27d78e636e01108 |
|
MD5 | e143142b485002b3057c462ecd478e47 |
|
BLAKE2b-256 | c131b8f42d545a6f259e5cbd29868e5a8e5be3441a6745a8a5ca74ca27d9d684 |