009-Personal-Alexa-like-Speech-Service / 009---Personal-Alexa-like-Speech-Service

BAA Projekt
0 stars 1 forks source link

Spacy function named entity recognition #25

Open kimmrz opened 3 years ago

kimmrz commented 3 years ago

https://spacy.io/api/entityrecognizer that link might help?

kimmrz commented 3 years ago

https://spacy.io/usage/linguistic-features#named-entities and this one

kimmrz commented 3 years ago
import spacy

nlp = spacy.load("en_core_web_sm")
doc = nlp("San Francisco considers banning sidewalk delivery robots")

# document level
ents = [(e.text, e.start_char, e.end_char, e.label_) for e in doc.ents]
print(ents)

# token level
ent_san = [doc[0].text, doc[0].ent_iob_, doc[0].ent_type_]
ent_francisco = [doc[1].text, doc[1].ent_iob_, doc[1].ent_type_]
print(ent_san)  # ['San', 'B', 'GPE']
print(ent_francisco)  # ['Francisco', 'I', 'GPE']

we can try to start with this sample code from spacy