-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to relate the entity to it place in the text? #12
Labels
documentation
Improvements or additions to documentation
Comments
Hi @ali3assi, import spacy
nlp = spacy.blank('en')
nlp.add_pipe('sentencizer')
nlp.add_pipe('dbpedia_spotlight')
doc = nlp("This is an example text. Let's mention Natural Language Processing")
for ent in doc.ents:
print(ent.text, ent.start_char-ent.sent.start_char, ent.end_char-ent.sent.start_char, ent.label_)
# Natural Language Processing 14 41 DBPEDIA_ENT Or in alternative load one of the models that already load the sentencizer: import spacy
# this needs to be installed https://spacy.io/models/en#en_core_web_sm
nlp = spacy.load('en_core_web_sm')
# then the following is the same
nlp.add_pipe('dbpedia_spotlight')
doc = nlp("This is an example text. Let's mention Natural Language Processing")
for ent in doc.ents:
print(ent.text, ent.start_char-ent.sent.start_char, ent.end_char-ent.sent.start_char, ent.label_)
# Natural Language Processing 14 41 DBPEDIA_ENT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Once I get the annotation of the entities how can get the starting position and ending position in the text. So I want to relate the text to its corresponding entity.
I do the following:
But I get the following exception:
The text was updated successfully, but these errors were encountered: