Difflib Вопрос детектора Sequence_Matcher ошибка или глюк?
Я использовал этот код, который я нашел при обнаружении вопросов, так как я боролся с ним. Когда я попробовал код, я получил какой-то вывод, которого я не ожидал. Иногда я получал ожидаемый результат, но не все.
Вот мой код (который я скопировал):
from difflib import *
Sample_Questions = [...]
value = 'why does it rain'
for Ran_Question in Sample_Questions:
Question_Matcher = SequenceMatcher(None, Ran_Question, value).ratio()
if Question_Matcher > 0.5:
print (Question_Matcher)
print ("Similar to Question: "+Ran_Question)
print ("likely a Question")
else:
print("Ran into some error... :(")
После этого я получаю странный вывод...:
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
0.529411764706
Similar to Question: why do you hate me
likely a Question
Ran into some error... :(
Ran into some error... :(
0.512820512821
Similar to Question: what do i do in an hour
likely a Question
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
0.536585365854
Similar to Question: who does all the shipping
likely a Question
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
0.55
Similar to Question: where did you say it was
likely a Question
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
0.540540540541
Similar to Question: does it hurt everyday
likely a Question
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
Ran into some error... :(
Это было сумасшествие, и теперь мне интересно, почему это такая смешанная порода ответов. Любая помощь в этом будет оценена. Если вы можете найти, как это исправить, опубликуйте это в блоке ответов. Спасибо.
PS Иногда это даже не дает какой-то вывод, только заявление об ошибке.