Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,4 +8,25 @@ model = AutoModelForSequenceClassification.from_pretrained("nlptown/bert-base-mu
|
|
8 |
nlp = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
|
9 |
|
10 |
st.title("Sentiment Analysis App")
|
11 |
-
user_input = st.text_input("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
nlp = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
|
9 |
|
10 |
st.title("Sentiment Analysis App")
|
11 |
+
user_input = st.text_input("ป้อนประโยค:")
|
12 |
+
|
13 |
+
# ตรวจจับข้อความเมื่อผู้ใช้คลิกปุ่ม "ตรวจสแปม"
|
14 |
+
if st.button("ตรวจสแปม"):
|
15 |
+
if user_input:
|
16 |
+
# ใช้โมเดลในการตรวจจับสแปม
|
17 |
+
result = nlp(user_input)
|
18 |
+
label = result[0]['label']
|
19 |
+
score = result[0]['score']
|
20 |
+
|
21 |
+
# แสดงผลลัพธ์
|
22 |
+
st.write(f"ผลการตรวจสแปม: {label}")
|
23 |
+
st.write(f"คะแนนความเชื่อมั่น: {score:.4f}")
|
24 |
+
|
25 |
+
# ตรวจสแปมและแสดงข้อความเตือน
|
26 |
+
if label == "spam":
|
27 |
+
st.warning("ข้อความนี้ถูกตรวจสแปม")
|
28 |
+
else:
|
29 |
+
st.success("ข้อความนี้ไม่ใช่สแปม")
|
30 |
+
else:
|
31 |
+
st.warning("โปรดป้อนข้อความเพื่อตรวจสแปม")
|
32 |
+
|