# def hello(): # print("hello") # # def bye(): # print("bye") # b={0:hello,1:bye} # # b[0]() # # exit() import sys import io import pandas as pd from pandas import Series, DataFrame from preprocess_data import Question # 创建问题处理对象,这样模型就可以常驻内存 que = Question() # Restore def enablePrint(): sys.stdout = sys.__stdout__ enablePrint() sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf8') #改变标准输出的默认编码 result = que.question_process(sys.argv[1]) if len(str(result).strip()) == 0: result = "我也不知道!" print(result)
import sys import web from preprocess_data import Question render = web.template.render('templates/') urls = ('/', 'index', '/add', 'add') app = web.application(urls, globals()) que = Question() print("create question object finish! ") # 主页显示类 class index: def GET(self): return render.index() def POST(self): text = web.input() print(text) raise web.seeother('/') # 处理问题类 class add: # get方式处理问题 def GET(self): pass # post方式处理问题
# # def hello(): # print("hello") # # def bye(): # print("bye") # b={0:hello,1:bye} # # b[0]() # # exit() import sys import pandas as pd from pandas import Series, DataFrame from preprocess_data import Question # 创建问题处理对象,这样模型就可以常驻内存 que = Question() # Restore def enablePrint(): sys.stdout = sys.__stdout__ enablePrint() result = que.question_process("章子怡演过哪些动作类的电影?") print(result)
# @Site : # @File : test.py # @Software: PyCharm # # def hello(): # print("hello") # # def bye(): # print("bye") # b={0:hello,1:bye} # # b[0]() # # exit() import sys import pandas as pd from pandas import Series, DataFrame from preprocess_data import Question # 创建问题处理对象,这样模型就可以常驻内存 que = Question() # Restore def enablePrint(): sys.stdout = sys.__stdout__ enablePrint() result = que.question_process("章子怡演过多少部电影") print(result)
#用来测试问题的正确性 import sys import pandas as pd from pandas import Series, DataFrame from preprocess_data import Question # 创建问题处理对象,这样模型就可以常驻内存 que = Question() # Restore def enablePrint(): sys.stdout = sys.__stdout__ enablePrint() result = que.question_process("王斌管理的公司") print(result)
import sys import pandas as pd from pandas import Series, DataFrame from preprocess_data import Question # 创建问题处理对象,这样模型就可以常驻内存 que=Question() # Restore def enablePrint(): sys.stdout = sys.__stdout__ enablePrint() result=que.question_process("What is the place of birth of Tom Hanks?") print(result)
# # def hello(): # print("hello") # # def bye(): # print("bye") # b={0:hello,1:bye} # # b[0]() # # exit() import sys import pandas as pd from pandas import Series, DataFrame from preprocess_data import Question # 创建问题处理对象,这样模型就可以常驻内存 que = Question() # Restore def enablePrint(): sys.stdout = sys.__stdout__ enablePrint() result = que.question_process("肝炎有哪些症状?") print(result)