-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
100 lines (85 loc) · 2.86 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
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, request, jsonify
from flask_cors import CORS
from dataManipulation import XMLDataframeParser
from normalize import Normalizer
from generateNetwork import NetworkGenerator as NG
app = Flask(__name__)
CORS(app)
# returns graph data where the edge weights are equal to the 2-grams count
@app.route("/count/<int:edgeCount>")
def getNodesByCount(edgeCount):
centrality = request.args.get("centrality")
groups = request.args.get("groups")
degree = False
closeness= False
getGroups = False
if centrality:
if centrality=="d":
degree=True
elif centrality=="c":
closeness= True
if groups=="y":
getGroups = True
data = NG().generate(edgeCount,False,0,degree,closeness,getGroups)
return jsonify(data)
# returns graph data where the edge weights are equal to the 2-grams tfidf
@app.route("/tfidf/<int:edgeCount>")
def getNodesByTfidf(edgeCount):
centrality = request.args.get("centrality")
groups = request.args.get("groups")
degree = False
closeness= False
getGroups = False
if centrality:
if centrality=="d":
degree=True
elif centrality=="c":
closeness= True
if groups=="y":
getGroups = True
data = NG().generate(edgeCount,True,0,degree,closeness,getGroups)
return jsonify(data)
# returns graph data where the edge weights are equal to the skipgrams count
@app.route("/count/skipgram/<int:edgeCount>")
def getSkipgramsByCount(edgeCount):
centrality = request.args.get("centrality")
groups = request.args.get("groups")
window_size = request.args.get('window_size')
degree = False
closeness= False
getGroups = False
if centrality:
if centrality=="d":
degree=True
elif centrality=="c":
closeness= True
if groups=="y":
getGroups = True
if window_size:
data = NG().generate(edgeCount,False,int(window_size),degree,closeness,getGroups)
else:
data = NG().generate(edgeCount,False,1,degree,closeness,getGroups)
return jsonify(data)
# returns graph data where the edge weights are equal to the skipgrams tfidf
@app.route("/tfidf/skipgram/<int:edgeCount>")
def getSkipgramsByTfidf(edgeCount):
centrality = request.args.get("centrality")
groups = request.args.get("groups")
window_size = request.args.get('window_size')
degree = False
closeness= False
getGroups = False
if centrality:
if centrality=="d":
degree=True
elif centrality=="c":
closeness= True
if groups=="y":
getGroups = True
if window_size:
data = NG().generate(edgeCount,True,int(window_size),degree,closeness,getGroups)
else:
data = NG().generate(edgeCount,True,1,degree,closeness,getGroups)
return jsonify(data)
if __name__ == "__main__":
app.run()