Spaces:
Sleeping
Sleeping
add checkPlus
Browse files
app.py
CHANGED
@@ -14,7 +14,7 @@ import unicodedata as ud
|
|
14 |
|
15 |
from underthesea import word_tokenize
|
16 |
|
17 |
-
|
18 |
|
19 |
# Load tokenizer
|
20 |
# fp = Path(__file__).with_name('tokenizer.pkl')
|
@@ -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,7 +93,13 @@ def judge(x):
|
|
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 |
return (result)
|
|
|
14 |
|
15 |
from underthesea import word_tokenize
|
16 |
|
17 |
+
from phoBERT import BERT_predict
|
18 |
|
19 |
# Load tokenizer
|
20 |
# fp = Path(__file__).with_name('tokenizer.pkl')
|
|
|
76 |
return p
|
77 |
pass
|
78 |
|
79 |
+
def judge(x, bert=False):
|
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 |
+
if bert == True:
|
97 |
+
bert_pred = BERT_predict(x)
|
98 |
+
result_bert = np.round(bert_pred, 2)
|
99 |
+
for i in range(6):
|
100 |
+
result.append((result_lstm[i]+result_gru[i]+result_bert[i])/3)
|
101 |
+
else:
|
102 |
+
for i in range(6):
|
103 |
+
result.append((result_lstm[i]+result_gru[i])/2)
|
104 |
|
105 |
return (result)
|
main.py
CHANGED
@@ -24,6 +24,12 @@ def check():
|
|
24 |
result = judge(comment)
|
25 |
return result
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
if __name__ == '__main__':
|
28 |
|
29 |
app.run(debug=False, threaded=True)
|
|
|
24 |
result = judge(comment)
|
25 |
return result
|
26 |
|
27 |
+
@app.route("/checkplus", methods=["POST"])
|
28 |
+
def checkPlus():
|
29 |
+
comment = request.json['comment']
|
30 |
+
result = judge(comment, True)
|
31 |
+
return result
|
32 |
+
|
33 |
if __name__ == '__main__':
|
34 |
|
35 |
app.run(debug=False, threaded=True)
|