wniwan commited on
Commit
e56d6d1
1 Parent(s): d18f8bb

Upload 2 files

Browse files
Files changed (2) hide show
  1. app_senti_65123456.py +36 -0
  2. requirements.txt +2 -0
app_senti_65123456.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ from transformers import pipeline
4
+
5
+ # Load the sentiment analysis model
6
+ model_name = "poom-sci/WangchanBERTa-finetuned-sentiment"
7
+ sentiment_analyzer = pipeline('sentiment-analysis', model=model_name)
8
+
9
+ # Streamlit app
10
+ st.title("Thai Sentiment Analysis App")
11
+
12
+ # Input text
13
+ text_input = st.text_area("Enter Thai text for sentiment analysis", "ขอความเห็นหน่อย... ")
14
+
15
+ # Button to trigger analysis
16
+ if st.button("Analyze Sentiment"):
17
+ # Analyze sentiment using the model
18
+ results = sentiment_analyzer([text_input])
19
+
20
+ # Extract sentiment and score
21
+ sentiment = results[0]['label']
22
+ score = results[0]['score']
23
+
24
+
25
+ # Display result as progress bars
26
+ st.subheader("Sentiment Analysis Result:")
27
+
28
+ if sentiment == 'pos':
29
+ st.success(f"Positive Sentiment (Score: {score:.2f})")
30
+ st.progress(score)
31
+ elif sentiment == 'neg':
32
+ st.error(f"Negative Sentiment (Score: {score:.2f})")
33
+ st.progress(score)
34
+ else:
35
+ st.warning(f"Neutral Sentiment (Score: {score:.2f})")
36
+ st.progress(score)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ transformers
2
+ torch