S
S
shynga2020-05-15 19:45:12
Python
shynga, 2020-05-15 19:45:12

Is it possible to check 2 texts in python for synonyms?

Good afternoon.
There are 2 fields in which text is entered.
Next, you need to check whether there is a match in the texts at the level of synonyms.
For example, you enter 'red apple' and 'burgundy apple' and 'match' is output.
And for example 'red apple' and 'green apple', 'inconsistency' is displayed.

As far as I understand, these are neural networks, that is, almost artificial intelligence.
Or is there a simpler solution to this problem?

It seems like there is a Pandas library, but it seems that such functionality is not possible with it.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
dmshar, 2020-05-15
@dmshar

As for me, 'red apple' and 'burgundy apple' are absolutely not synonymous. At least as different varieties as between red and green apples.
Are "red apple" and "red avocado" synonyms, for example? Yes? Not? Why?
And if these are synonyms for you, then make your own list of synonyms and use it. Just search this list. For a coincidence.
AI is not a magic wand. He must first be taught what you consider synonymous and what is not. And here the work is through the roof, you don’t know exactly what words it will take as input.

B
Bogdan2033, 2020-05-15
@Bogdan2033

Built-in libraries - you can not.
Using a ready-made or creating your own tool for this task is an option, but this is also not for a beginner.

A
Alexander, 2020-05-16
@sanya84

import re


def main():
    result_one = re.search(r'яблоко', input("Строка один: ")) #Красное яблоко
    result_two = re.search(r'груша', input("Строка два: "))   #Зелёная груша
    print(result_one)
    print(result_two)

    if result_one.group(0).lower() and result_two.group(0).lower() in ["яблоко", "груша"]:
        print("Строка один и строка два, содержат синонимы")

if __name__ == '__main__':
    main()

S
Sanya Hihi Haha, 2020-05-16
@ValarMayar

From here you can take a dictionary of synonyms and parse

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question