-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Nicolay Rusnachenko edited this page Dec 27, 2024
·
14 revisions
For the given text:
texts = [
# Text example
{"text": "It was in July, 1805, and the speaker was the well-known Anna Pávlovna"},
# other texts
# ...
]
This is a simple example of API usage:
from bulk_ner.api import NERAnnotator
from bulk_ner.src.service_dynamic import dynamic_init
ner_model = dynamic_init(src_dir="models",
class_filepath="dp_130.py",
class_name="DeepPavlovNER")(model="ner_ontonotes_bert")
annotator = NERAnnotator(ner_model=ner_model, chunk_limit=128)
data_it = annotator.iter_annotated_data(data_dict_it=texts, prompt="{text}", batch_size=10)
for data in data_it:
# Handle your NER data here ...
print(data["result"])
# Output:
# ['It was in', ['July , 1805', 'DATE', 0], ', and the speaker was the well - known', ['Anna Pávlovna', 'PERSON', 1]]
We use the most accessible format and represent the output content as a list
.
Entries of list
types are refer to recognized Named Entities.
Such lists contain the following information:
- Value of the Named Entity
- Type of the named entity
- Index of the entity
Here is an example: