'Spacy' Names Undetected

Viewed 23

I have the following code below that should identify names in a string, but it does not seem to identify all the names.

import spacy
nlp = spacy.load('en_core_web_sm')
text = "Elon Musk 889-888-8888 elonpie@tessa.net Jeff Bezos (345)123-1234 bezzi@zonbi.com Reshma Saujani example.email@email.com 888-888-8888 Barkevious Mingo"
doc = nlp(text)
print([ent for ent in doc.ents if ent.label_ == 'PERSON'])

Output is as follows:

['Elon Musk 889-888-8888', 'Jeff Bezos']

The expected output would be:

['Elon Musk', 'Jeff Bezos', 'Reshma Saujani', 'Barkevious Mingo']

Is there a different package that may be useful, perhaps?

1 Answers

Try following;

  • You can load the medium or large version of same model from spacy & try, "en_core_web_md" or "en_core_web_lg" respectively. These are computationally expensive but have better accuracy.
  • Try with hugging face's pre-trained algos.. They are good... https://huggingface.co/models?sort=downloads search for your problem statement...
Related