response.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:goose 作者: sexxis 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号