npayungkorapin-007 commited on
Commit
59bb5bc
1 Parent(s): 466646b

Create app_senti_65130701707.py

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