-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.py
More file actions
72 lines (64 loc) · 2.08 KB
/
hello.py
File metadata and controls
72 lines (64 loc) · 2.08 KB
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
from flask import *
import casty
app = Flask(__name__)
app.debug = True
@app.route('/', methods=['GET'])
def search():
return render_template('search.html')
@app.route('/find', methods=['GET'])
def dropdown():
fname = request.args.get('first_actor_name')
lname = request.args.get('last_actor_name')
algo = request.args.get('algo')
actors = casty.findActor(fname, lname)
return render_template('select.html', actors=actors, algo=algo)
@app.route('/actor', methods=['GET'])
def actor():
actor = request.args.get('actor')
algo = request.args.get('algo')
name = request.args.get('name')
if algo == "logreg":
predicts = casty.logreg(int(actor))
elif algo == "svm":
predicts = casty.svmc(int(actor))
elif algo == "jac":
predicts = casty.jaccard_sim(int(actor))
elif algo == "pcc":
predicts = casty.pearson_sim(int(actor))
else:
predicts = casty.cosine_sim(int(actor))
leng = predicts[0]
title = predicts[1]
prob = predicts[2]
clasf = predicts[3]
actual = predicts[4]
sums = predicts[5]
# for i in range(0, len(title)):
# print(title[i], prob[i])
return render_template('actor.html', name=name, actor_id=actor, algo=algo, titles=title, prob=prob, clasf=clasf, actual=actual, length=len(title), lengh=leng, sums = sums)
@app.route('/actor_more', methods=['GET'])
def actor_more():
actor = request.args.get('actor')
algo = request.args.get('algo')
name = request.args.get('name')
if algo == "logreg":
predicts = casty.logreg(int(actor), 1)
elif algo == "svm":
predicts = casty.svmc(int(actor), 1)
elif algo == "jac":
predicts = casty.jaccard_sim(int(actor), 1)
elif algo == "pcc":
predicts = casty.pearson_sim(int(actor), 1)
else:
predicts = casty.cosine_sim(int(actor), 1)
leng = predicts[0]
title = predicts[1]
prob = predicts[2]
clasf = predicts[3]
actual = predicts[4]
sums = predicts[5]
# for i in range(0, len(title)):
# print(title[i], prob[i])
return render_template('actor.html', name=name, actor_id=actor, algo=algo, titles=title, prob=prob, clasf=clasf, actual=actual, length=len(title), lengh=leng, sums = sums)
if __name__ == "__main__":
app.run()