1 Star 14 Fork 9

untilwty/chatbot-base-on-Knowledge-Graph

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
chatbot_graph.py 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
baiyang2464 提交于 2019-08-25 12:04 . 更新对话系统基本文件
# coding: utf-8
#from question_classifier import *
from question_parser import *
from answer_search import *
from question_analysis import *
'''问答类'''
class ChatBotGraph:
def __init__(self):
#self.classifier = QuestionClassifier()
self.classifier = question_ays()
self.parser = QuestionPaser()
self.searcher = AnswerSearcher()
def chat_main(self, sent):
answer = '您的问题我还不能理解,请换个问法'
res_classify = self.classifier.analysis(sent)
print(res_classify)
if not res_classify:
return answer
res_sql = self.parser.parser_main(res_classify)
final_answers = self.searcher.search_main(res_sql)
if not final_answers:
return answer
else:
return '\n'.join(final_answers)
if __name__ == '__main__':
handler = ChatBotGraph()
question= '##'
print('您好,我是医疗聊天机器人李雯φ(゜▽゜*)♪,请问您想了解什么,希望我的回答可以帮到您!')
while(question!="" and question!=" "):
question = input('用户:')
if question == "quit" or question=="" or question == " ":break
answer = handler.chat_main(question)
print('李雯:', answer)
print("再见!")
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/untilwty/chatbot-base-on-Knowledge-Graph.git
[email protected]:untilwty/chatbot-base-on-Knowledge-Graph.git
untilwty
chatbot-base-on-Knowledge-Graph
chatbot-base-on-Knowledge-Graph
master

搜索帮助