|
|
|
|
|
import streamlit as st |
|
from transformers import pipeline |
|
|
|
|
|
model_name = "poom-sci/WangchanBERTa-finetuned-sentiment" |
|
sentiment_analyzer = pipeline('sentiment-analysis', model=model_name) |
|
|
|
|
|
st.title("Thai Sentiment Analysis App") |
|
|
|
|
|
text_input = st.text_area("Enter Thai text for sentiment analysis", "ขอความเห็นหน่อย... ") |
|
|
|
|
|
if st.button("Analyze Sentiment"): |
|
|
|
results = sentiment_analyzer([text_input]) |
|
|
|
|
|
sentiment = results[0]['label'] |
|
score = results[0]['score'] |
|
|
|
|
|
|
|
st.subheader("Sentiment Analysis Result:") |
|
|
|
if sentiment == 'pos': |
|
st.success(f"Positive Sentiment (Score: {score:.2f})") |
|
st.progress(score) |
|
elif sentiment == 'neg': |
|
st.error(f"Negative Sentiment (Score: {score:.2f})") |
|
st.progress(score) |
|
else: |
|
st.warning(f"Neutral Sentiment (Score: {score:.2f})") |
|
st.progress(score) |
|
|