HMPhuoc commited on
Commit
aa87a91
1 Parent(s): f5d4e06

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +105 -1
main.py CHANGED
@@ -1,8 +1,11 @@
1
  from flask import Flask, request
2
- from app import judge, judgePlus, judgeBert
 
3
  from flask_cors import CORS
4
  import threading
5
 
 
 
6
  app = Flask(__name__)
7
  CORS(app)
8
 
@@ -36,6 +39,107 @@ def checkBert():
36
  result = judgeBert(comment)
37
  return result
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  if __name__ == '__main__':
40
 
41
  app.run(debug=False, threaded=True)
 
1
  from flask import Flask, request
2
+ from app import judge, judgePlus, judgeBert, tokenize, lstm_predict, gru_predict
3
+ from phoBERT import BERT_predict
4
  from flask_cors import CORS
5
  import threading
6
 
7
+ import time
8
+
9
  app = Flask(__name__)
10
  CORS(app)
11
 
 
39
  result = judgeBert(comment)
40
  return result
41
 
42
+ @app.route("/check_time")
43
+ def time():
44
+ l10 = []
45
+ l100 = []
46
+ l200 = []
47
+
48
+ t_lstm_10 = []
49
+ t_lstm_100 = []
50
+ t_lstm_200 = []
51
+
52
+ t_gru_10 = []
53
+ t_gru_100 = []
54
+ t_gru_200 = []
55
+
56
+ t_bert_10 = []
57
+ t_bert_100 = []
58
+ t_bert_200 = []
59
+
60
+ #LSTM
61
+ for com in l10:
62
+ com = tokenize(com)
63
+ t1 = time.time()
64
+ lstm_predict(com)
65
+ t2 = time.time()
66
+ t = t2-t1
67
+ t_lstm_10.append(t)
68
+
69
+ for com in l100:
70
+ com = tokenize(com)
71
+ t1 = time.time()
72
+ lstm_predict(com)
73
+ t2 = time.time()
74
+ t = t2-t1
75
+ t_lstm_100.append(t)
76
+
77
+ for com in l200:
78
+ com = tokenize(com)
79
+ t1 = time.time()
80
+ lstm_predict(com)
81
+ t2 = time.time()
82
+ t = t2-t1
83
+ t_lstm_200.append(t)
84
+
85
+ #GRU
86
+ for com in l10:
87
+ com = tokenize(com)
88
+ t1 = time.time()
89
+ gru_predict(com)
90
+ t2 = time.time()
91
+ t = t2-t1
92
+ t_gru_10.append(t)
93
+
94
+ for com in l100:
95
+ com = tokenize(com)
96
+ t1 = time.time()
97
+ gru_predict(com)
98
+ t2 = time.time()
99
+ t = t2-t1
100
+ t_gru_100.append(t)
101
+
102
+ for com in l200:
103
+ com = tokenize(com)
104
+ t1 = time.time()
105
+ gru_predict(com)
106
+ t2 = time.time()
107
+ t = t2-t1
108
+ t_gru_200.append(t)
109
+
110
+ #BERT
111
+ for com in l10:
112
+ com = tokenize(com)
113
+ t1 = time.time()
114
+ BERT_predict(com)
115
+ t2 = time.time()
116
+ t = t2-t1
117
+ t_bert_10.append(t)
118
+
119
+ for com in l100:
120
+ com = tokenize(com)
121
+ t1 = time.time()
122
+ BERT_predict(com)
123
+ t2 = time.time()
124
+ t = t2-t1
125
+ t_bert_100.append(t)
126
+
127
+ for com in l200:
128
+ com = tokenize(com)
129
+ t1 = time.time()
130
+ BERT_predict(com)
131
+ t2 = time.time()
132
+ t = t2-t1
133
+ t_bert_200.append(t)
134
+
135
+ return 'ok'
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
  if __name__ == '__main__':
144
 
145
  app.run(debug=False, threaded=True)