test_eol.py 文件源码

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

项目:Personal_AI_Assistant 作者: PratylenClub 项目源码 文件源码
def choose_best_action(self, list_of_words):
        min_distance = 3
        best_matching_action = None
        tf_idf_shelve = shelve.open(self.tf_idf_shelve_file_name)
        current_sentence_centroid = self.compute_list_of_words_centroid(list_of_words)
        for action,centroid in tf_idf_shelve[CENTROID].iteritems():
            distance = cosine(centroid,current_sentence_centroid)
            print action,distance
            if distance <= min_distance:
                min_distance = distance
                best_matching_action = action
        tf_idf_shelve.close()
        return current_sentence_centroid, best_matching_action, min_distance
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号