есть ли способ найти значение строки схожим или нет ,, даже если слова в строке дифференцированы
До сих пор я пробовал нечеткие-нечеткие, левенштейновское расстояние, косинусное сходствочтобы соответствовать строке, но все совпадают со словами, а не со значением слов
Str1 = "what are types of negotiation"
Str2 = "what are advantages of negotiation"
Str3 = "what are categories of negotiation"
Ratio = fuzz.ratio(Str1.lower(),Str2.lower())
Partial_Ratio = fuzz.partial_ratio(Str1.lower(),Str2.lower())
Token_Sort_Ratio = fuzz.token_sort_ratio(Str1,Str2)
Ratio1 = fuzz.ratio(Str1.lower(),Str3.lower())
Partial_Ratio1 = fuzz.partial_ratio(Str1.lower(),Str3.lower())
Token_Sort_Ratio1 = fuzz.token_sort_ratio(Str1,Str3)
print("fuzzywuzzy")
print(Str1," ",Str2," ",Ratio)
print(Str1," ",Str2," ",Partial_Ratio)
print(Str1," ",Str2," ",Token_Sort_Ratio)
print(Str1," ",Str3," ",Ratio1)
print(Str1," ",Str3," ",Partial_Ratio1)
print(Str1," ",Str3," ",Token_Sort_Ratio1)
print("levenshtein ratio")
Ratio = levenshtein_ratio_and_distance(Str1,Str2,ratio_calc = True)
Ratio1 = levenshtein_ratio_and_distance(Str1,Str3,ratio_calc = True)
print(Str1," ",Str2," ",Ratio)
print(Str1," ",Str3," ",Ratio)
output:
fuzzywuzzy
what are types of negotiation what are advantages of negotiation 86
what are types of negotiation what are advantages of negotiation 76
what are types of negotiation what are advantages of negotiation 73
what are types of negotiation what are categories of negotiation 86
what are types of negotiation what are categories of negotiation 76
what are types of negotiation what are categories of negotiation 73
levenshtein ratio
what are types of negotiation what are advantages of negotiation
0.8571428571428571
what are types of negotiation what are categories of negotiation
0.8571428571428571
expected output:
"what are the types of negotiation skill?"
"what are the categories in negotiation skill?"
output:similar
"what are the types of negotiation skill?"
"what are the advantages of negotiation skill?"
output:not similar