Chatbot.py 文件源码

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

项目:AIZooService 作者: zhanglbjames 项目源码 文件源码
def __get_model_answer(self, question):
        tag1 = jieba.analyse.extract_tags(question, 3)
        tag2 = jieba.analyse.textrank(question, 3)
        keywords = []

        for tag in tag1:
            keywords.append(tag)
        for tag in tag2:
            if tag not in tag1:
                keywords.append(tag)

        tr4w = TextRank4Keyword()
        tr4w.analyze(text=question, lower=True, window=2)
        for item in tr4w.get_keywords(20, word_min_len=1):
            if item.word not in keywords:
                keywords.append(item.word)

        kstr = ""
        for k in keywords:
            if len(k) != 1:
                kstr = kstr + "AND" + k
            else:
                if k not in kstr:
                    kstr = kstr + "AND" + k
                    # print(k)
        estr = kstr[3:]
        print (estr)
        q = self.__parser.parse(estr)
        results = self.__searcher.search(q)
        return results
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号