Answer the question
In order to leave comments, you need to log in
How to compare names by their part (or derivative) in python?
I have 2 names and I need to compare them. The problem is that I don't know how these 2 names are spelled. There may be Dmitry and Dmitry, maybe Dimochka and Dimon, maybe one of the names will be misspelled. I need to compare them and make sure they are the same names (or not). To do this, I came up with the following algorithm:
Answer the question
In order to leave comments, you need to log in
If this is not an educational, but a practical task, then you unreasonably complicate the implementation. It's easier and more convenient to use a table of names. Not to mention that this is the only way to compare the same, but completely different sounding names, for example, Georgy and Zhora, Anna and Nyura.
To create a table of names, you can use an ordinary list. For example:
names = [
('Саша', 'Александр'),
('Георгий', 'Жора'),
('Лена', 'Леночка', 'Lena')
]
name1 = 'Жора'
name2 = 'Георгий'
for x in names:
if name1 in x and name2 in x:
print(name1, name2, 'same')
The best option is to find some library for comparisons. The first thing that the search found was https://antonz.ru/difflib-ratio/
From this question: how to understand that Dima \u003d Dmitry or Dim \u003d Dmitry?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question