def check_phrase_similarity(self):
self.user_input = TextBlob(self.user_input.lower()).tags
self.input_len = len(self.user_input)
for phrase_type in PHRASE_TYPES:
for phrase in getattr(keywords, phrase_type):
score = float()
for word in self.user_input:
for n in phrase:
if word and n not in unimportant_words:
score += liquidmetal.score(n, word[0]) / self.input_len
if score >= 0.7: # Could be increased/ decreased through testing to find more optimal value
self.response = random.choice(getattr(responses, phrase_type))
return True
return False
评论列表
文章目录