<reponame>guci314/Chatbot_CN<filename>Chatbot_KG/bot/Chatbot_graph.py
#-*- coding:utf-8 _*-  
""" 
@author:charlesXu
@file: Chatbot_graph.py 
@desc:
@time: 2019/03/15 
"""

from Question_classifier import *
from Question_parser import *
from Answer_search import *

'''问答类'''
class ChatBotGraph:
    def __init__(self):
        self.classifier = QuestionClassifier()
        self.parser = QuestionParser()
        self.searcher = AnswerSearcher()

    def chat_main(self, sent):
        answer = '您好，我是小笨医药智能助理，希望可以帮到您。如果没答上来，可联系https://liuhuanyong.github.io/。祝您身体棒棒！'
        res_classify = self.classifier.classify(sent)
        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()
    while 1:
        question = input('用户:')
        answer = handler.chat_main(question)
        print('小笨:', answer)
#-*- coding:utf-8 _*-  
""" 
@author:charlesXu
@file: Chatbot_graph.py 
@desc:
@time: 2019/03/15 
"""

from Question_classifier import *
from Question_parser import *
from Answer_search import *

'''问答类'''
class ChatBotGraph:
    def __init__(self):
        self.classifier = QuestionClassifier()
        self.parser = QuestionParser()
        self.searcher = AnswerSearcher()

    def chat_main(self, sent):
        answer = '您好，我是小笨医药智能助理，希望可以帮到您。如果没答上来，可联系https://liuhuanyong.github.io/。祝您身体棒棒！'
        res_classify = self.classifier.classify(sent)
        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()
    while 1:
        question = input('用户:')
        answer = handler.chat_main(question)
        print('小笨:', answer)
#-*- coding:utf-8 _*- @author:charlesXu @file: Chatbot_graph.py  @desc: @time: 2019/03/15 问答类