-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.py
100 lines (82 loc) · 2.94 KB
/
web.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
from flask import Flask
from flask import render_template
from flask import jsonify
from flask import request
from flask import redirect
import transcript
import scores
import scdb
import climate
from predict import predict_case
app = Flask(__name__)
climate.enable_default_logging()
@app.route("/case_info/<docket_number>")
def get_case_info(docket_number):
return jsonify(scdb.get_case_info(docket_number))
@app.route("/json_predict/<docket_number>")
def json_predict(docket_number):
return str(predict_case(docket_number))
@app.route("/")
def index():
return render_template('index.html', **locals())
@app.route("/methods/")
def methods():
return render_template('methods.html', **locals())
@app.route("/methods/parsing-the-transcript")
def parsing():
return render_template('parsing.html', **locals())
@app.route("/methods/identifying-features")
def features():
return render_template('identifying.html', **locals())
@app.route("/methods/network-training")
def training():
return render_template('training.html', **locals())
@app.route("/FAQ")
def faq():
return render_template('FAQ.html', **locals())
@app.route("/results")
def results():
return render_template('results.html', **locals())
@app.route("/references")
def refs():
return render_template('references.html', **locals())
@app.route("/predict/<docket_number>")
def predict(docket_number):
info = scdb.get_case_info(docket_number)
return render_template('predict.html', **locals())
@app.route("/inline_predict/<docket_number>")
def inline_predict(docket_number):
info = scdb.get_case_info(docket_number)
result = predict_case(docket_number)
resultint = int(round(result))
if resultint > 1:
resultint = 1
if resultint == 1:
winner = "Petitioner"
else:
winner = "Respondent"
if info["partyWinning"] == "1":
actual = "Petitioner"
elif info["partyWinning"] == "0":
actual = "Respondent"
else:
actual = "Unclear"
correct = False
if winner == actual:
correct = True
confidence_level = int(abs(result - 0.5)*100)
if confidence_level < 40:
low_confidence = True
return render_template('inline_predict.html', **locals())
@app.route("/bar_chart_data/<docket_number>")
def bar_chart_data(docket_number):
the_transcript = transcript.get_transcript_from_PDF("transcripts/" + docket_number + ".pdf")
petitioners, respondents = transcript.get_petitioners_and_respondents(the_transcript)
argument = transcript.get_argument(the_transcript)
arguments_by_advocate = transcript.get_arguments_by_advocate(petitioners, respondents, argument)
for petitioner, argument in arguments_by_advocate["petitioner"].iteritems():
statements = transcript.get_statements_in_argument(argument, petitioner)
return jsonify(scores.bar_chart_speaker(statements))
return {}
if __name__ == '__main__':
app.run(debug=app.config["DEBUG"], host='0.0.0.0',threaded=True)