Orawan commited on
Commit
1e2b810
·
1 Parent(s): 09c5b4d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
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
+