-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
170 lines (141 loc) · 4.79 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
"""
Routes and views for the flask application.
"""
from datetime import datetime
from flask import render_template, redirect, url_for, request, jsonify
from athena_App import app
from athena_App.formClass import QuestionForm
import time
#attention:
#this module include large word vector which need a lot of time to load
#turn it off when when you debugging other module
#
#from athena_App.data_process.es_QAsearch import *
#
#from athena_App.data_process.keywordCompare import Keyword_Compare, Answer
#from athena_App.data_process.word2vecCompareModel import *
#from athena_App.data_process.graph_query import *
#from athena_App.openlaw.graphOfcase_query_echart import *
#reconstruct series
#from athena_App.layer_frontInteracting.qa_module import answerFinder
print('{ + } view函数执行 问答模块')
#from athena_App.layer_frontInteracting.kg_module import knowledgeSearch
print('{ + } view函数执行 知识模块')
#from athena_App.layer_frontInteracting.case_module import caseQuery
print('{ + } view函数执行 案例模块')
#from athena_App.layer_frontInteracting.knife_module import knifeModule
print('{ + } view函数执行 助手模块')
#以下语句为尝试ltp在views里直接加载
#from athena_App.layer_dataOperating.ltp_module import ltpTools as Ltptool
#from athena_App.layer_dataOperating.textParse_module import TripleExtractor as tripleExtract
#实例化
#actualTool = Ltptool()
#tripleTool = tripleExtract(actualTool)
#print('{ + } 执行实例化!')
@app.route('/QAsearch', methods=['POST','GET'])
def QAsearch():
"""Renders the QAsearch page."""
question = ''
form = QuestionForm()
question = form.question.data
if form.validate_on_submit():
return redirect(url_for('answer',word=question))
return render_template(
'QAsearch.html',
title = 'QAsearch Page',
year = datetime.now().year,
form = form,
question = question
)
@app.route('/instruction')
def instruction():
"""Renders the instruction page."""
return render_template(
'instruction.html',
title='说明',
year=datetime.now().year,
message='编写中...'
)
@app.route('/about')
def about():
"""Renders the about page."""
return render_template(
'about.html',
title='关于我们',
year=datetime.now().year,
message='中国人民公安大学信息技术与网络安全学院\n '
)
@app.route('/answer/<word>')
def answer(word):
"""Renders the answer page"""
print(word)
start=time.clock()
finder=answerFinder()
answer=finder.findANDpack(word)
end=time.clock()
print(str(end-start))
return render_template(
'answer.html',
title='Answer',
answer=answer
)
@app.route('/main')
@app.route('/')
def main():
return render_template(
'newMain.html',
title = 'Welcome Page',
year = datetime.now().year
)
@app.route('/graph_search',methods=['get','post'])
def graph_search():
return render_template(
'graph_search.html',
title = 'Graph search page',
year = datetime.now().year)
@app.route('/knowledge_search',methods=['get','post'])
def knowledge_search():
#initialize graph search object
searchKnowledge=knowledgeSearch(actualTool)
des=request.args.get('description')
json_data=searchKnowledge.getTotalData_forKnowledgeSearch(des)
print(json_data)
return jsonify(json_data)
@app.route('/case_search_Test',methods=['get','post'])
def case_search_Test():
return render_template(
'case_search_Test.html',
title = 'Case search page',
year = datetime.now().year)
@app.route('/case_graph_search',methods=['get','post'])
def case_graph_search():
caseDes=request.args.get('caseDes')
#initialize graph search object
case_graph_result=caseQuery(caseDes, tripleTool)
pre_json_data=case_graph_result.getData()
print(pre_json_data)
return jsonify(pre_json_data)
@app.route('/knife',methods=['get','post'])
def knife():
return render_template(
'knife.html',
title = 'KNIFE SEARCH',
year = datetime.now().year
)
@app.route('/procedureSearch',methods=['get','post'])
def procedureSearch():
Des = request.args.get("des")
ctrlCode = request.args.get("code")
procedureKnife = knifeModule(Des, ctrlCode, actualTool)
return jsonify(procedureKnife.taskDistribute())
@app.route('/tools',methods=['get','post'])
def tools():
return render_template(
'login.html'
)
@app.route('/toolcenter',methods=['get','post'])
def toolcenter():
return render_template(
'tool_welcome.html'
)
#@app.route('')