1 Star 0 Fork 9

wangxinwen / 医疗知识问答

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
chatbot_graph.py 2.17 KB
一键复制 编辑 原始数据 按行查看 历史
边城浪子 提交于 2021-04-16 11:18 . ip
from question_classifier import *
from question_parser import *
from answer_search import *
from flask import Flask, request, session, send_file
app = Flask(__name__,static_url_path='')
app.config['SECRET_KEY'] = 'qakb123456'
'''问答类'''
class ChatBotGraph:
def __init__(self):
# question_classifier.py里的 QuestionClassifier:
self.classifier = QuestionClassifier()
#question_paser.py里的 QuestionPaser:
self.parser = QuestionPaser()
#answer_search.py里的AnswerSearcher:
self.searcher = AnswerSearcher()
self.classify = {
"diseases": ["{}是什么","{}有什么症状","{}的原因","{}的并发症","{}能吃什么","{}不能吃什么","{}吃什么药","{}怎么预防","{}多长时间会好","{}怎么治疗","{}多大概率能治好","{}的易感人群","{}的检查项目","{}属于什么科"],
"food": ["吃{}有什么好处"],
"drug": ["吃{}治疗什么"],
"symptom": ["为什么会{}"]
}
# self.history_entity = None
# self.disease_classify = ["{}是什么","{}有什么症状","{}的原因","{}的并发症","{}能吃什么","{}不能吃什么","{}吃什么药","{}怎么预防","{}多长时间会好","{}怎么治疗","{}多大概率能治好","{}的易感人群","{}的检查项目","{}属于什么科"]
# self.food_classify = ["吃{}有什么好处"]
# self.drug_classify = ["吃{}治疗什么"]
# self.symptom_classify = ["为什么会{}"]
def chat_main(self, sent,session):
answer = '您好,我是医药智能助理,希望可以帮到您。目前问题还无法回答,请用更简洁的话来问哟~'
return answer
handler = ChatBotGraph()
@app.route('/',methods=['GET'])
def home():
return send_file("static/index.html")
@app.route('/input',methods=['POST'])
def hello_world():
text = request.form.get("text")
return {'send':'you','msg':handler.chat_main(text,session)}
if __name__ == '__main__':
app.run(port=10086)
# handler = ChatBotGraph()
# while 1:
# question = input('用户:')
# answer = handler.chat_main(question)
# print('小勇:', answer)
Python
1
https://gitee.com/wangxinwen/medical_knowledge_q__a.git
git@gitee.com:wangxinwen/medical_knowledge_q__a.git
wangxinwen
medical_knowledge_q__a
医疗知识问答
master

搜索帮助