Spaces:
Running
Running
add judgePlus
Browse files
app.py
CHANGED
@@ -76,7 +76,7 @@ def plot(result):
|
|
76 |
return p
|
77 |
pass
|
78 |
|
79 |
-
def judge(x
|
80 |
|
81 |
label = ['độc hại', 'cực kì độc hại', 'tục tĩu', 'đe dọa', 'xúc phạm', 'thù ghét cá nhân']
|
82 |
result = []
|
@@ -93,13 +93,33 @@ def judge(x, bert=False):
|
|
93 |
result_lstm = np.round(lstm_pred, 2)
|
94 |
result_gru = np.round(gru_pred, 2)
|
95 |
#result_bert = np.round(bert_pred, 2)
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
return (result)
|
|
|
76 |
return p
|
77 |
pass
|
78 |
|
79 |
+
def judge(x):
|
80 |
|
81 |
label = ['độc hại', 'cực kì độc hại', 'tục tĩu', 'đe dọa', 'xúc phạm', 'thù ghét cá nhân']
|
82 |
result = []
|
|
|
93 |
result_lstm = np.round(lstm_pred, 2)
|
94 |
result_gru = np.round(gru_pred, 2)
|
95 |
#result_bert = np.round(bert_pred, 2)
|
96 |
+
|
97 |
+
for i in range(6):
|
98 |
+
result.append((result_lstm[i]+result_gru[i])/2)
|
99 |
+
|
100 |
+
return (result)
|
101 |
+
|
102 |
+
def judgePlus(x):
|
103 |
+
|
104 |
+
label = ['độc hại', 'cực kì độc hại', 'tục tĩu', 'đe dọa', 'xúc phạm', 'thù ghét cá nhân']
|
105 |
+
result = []
|
106 |
+
judge_result = []
|
107 |
+
|
108 |
+
x = ud.normalize('NFKC', x)
|
109 |
+
|
110 |
+
lstm_pred = LSTM_predict(x)
|
111 |
+
gru_pred = GRU_predict(x)
|
112 |
+
bert_pred = BERT_predict(x)
|
113 |
+
#bert_pred = BERT_predict(x)
|
114 |
+
#print(result)
|
115 |
+
|
116 |
+
return_result = 'Result'
|
117 |
+
result_lstm = np.round(lstm_pred, 2)
|
118 |
+
result_gru = np.round(gru_pred, 2)
|
119 |
+
result_bert = np.round(bert_pred, 2)
|
120 |
+
#result_bert = np.round(bert_pred, 2)
|
121 |
+
|
122 |
+
for i in range(6):
|
123 |
+
result.append((result_lstm[i]+result_gru[i]+result_bert[i])/3)
|
124 |
|
125 |
return (result)
|
main.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
from flask import Flask, request
|
2 |
-
from app import judge
|
3 |
from flask_cors import CORS
|
4 |
import threading
|
5 |
|
@@ -27,7 +27,7 @@ def check():
|
|
27 |
@app.route("/checkplus", methods=["POST"])
|
28 |
def checkPlus():
|
29 |
comment = request.json['comment']
|
30 |
-
result =
|
31 |
return result
|
32 |
|
33 |
if __name__ == '__main__':
|
|
|
1 |
from flask import Flask, request
|
2 |
+
from app import judge, judgePlus
|
3 |
from flask_cors import CORS
|
4 |
import threading
|
5 |
|
|
|
27 |
@app.route("/checkplus", methods=["POST"])
|
28 |
def checkPlus():
|
29 |
comment = request.json['comment']
|
30 |
+
result = judgePlus(comment)
|
31 |
return result
|
32 |
|
33 |
if __name__ == '__main__':
|