-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.py
48 lines (35 loc) · 1.33 KB
/
app.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
import pickle
from flask import Flask, request, url_for, redirect, render_template
import PredictForRawSentence as pr
from ensembleonepredict import get_predictlist
import ensembleOne
from ensembleonepredict import get_model
app = Flask(__name__)
global tokenizer
global opt
global model
@app.route('/', methods=["GET", "POST"])
def index():
return render_template('index.html')
@app.route('/result',methods=["POST"])
def result():
# if request.method == 'POST':
text = request.form.get('string') # access the data inside
petitioner = request.form.get('pet_members')
defendant = request.form.get('def_members')
result_list =list()
print(petitioner)
print(defendant)
sentence, pet_dict, def_dict, pet_overall, def_overall = ensembleOne.pred(text,petitioner,defendant,models_list, opt_list, tokenizer,loaded_model)
result_list.append(text)
result_list.append(pet_dict)
result_list.append(def_dict)
result_list.append(pet_overall)
result_list.append(def_overall)
result=result_list
return render_template('result.html',result=result)
if __name__ == '__main__':
models = ["bert_spc", 'bert_atae_lstm', "gcn_bert", "ram_bert", "lcf_bert"]
loaded_model = pickle.load(open('finalized_model.sav', 'rb'))
models_list, opt_list, tokenizer = get_model(models)
app.run(debug=True)