A
A
anya_hacker2021-11-15 19:15:43
Python
anya_hacker, 2021-11-15 19:15:43

How to find English surnames in the text?

There is a list of usernames in English. How to determine what is the name and surname?
With pymorphy2, but it only defines in Russian. And how to define English surnames?

import pymorphy2

name_list = ['Василий', 'Екатерина', 'Супер', 'Aleksandra', 'Bybee', 'William']

for name in name_list:
    print(any('Name' in p.tag for p in morph.parse(name)))

True
True
False
False
False
False

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Antonio Solo, 2021-11-15
@anya_hacker

pymorphy2 is a lexical analyzer for the Russian language.
use NLTK, spacy
ps with names/surnames in English text is a complete disaster - any name can be a surname

1
1 2, 2021-11-15
@weRifiCatoR

Do the opposite then. That is, if True is returned to you, you return False and vice versa.

M
Maxim K, 2021-11-15
@mkvmaks

It can make a dictionary of surnames and look for your own in it, if not, add it, and then re-search it, because Name can be any

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question