Spaces:
Sleeping
Sleeping
Commit
·
69722dc
1
Parent(s):
e809d19
Update app.py
Browse files
app.py
CHANGED
@@ -5,19 +5,24 @@ model_path = "citizenlab/twitter-xlm-roberta-base-sentiment-finetunned"
|
|
5 |
|
6 |
st.set_page_config(page_title="Sentiment Analysis App")
|
7 |
|
8 |
-
|
9 |
sentiment_classifier = pipeline("text-classification", model=model_path, tokenizer=model_path)
|
10 |
|
11 |
st.title("Sentiment Analysis App")
|
12 |
|
13 |
-
user_input = st.text_area("Enter a message:")
|
14 |
|
15 |
if st.button("Analyze Sentiment"):
|
16 |
if user_input:
|
17 |
# Perform sentiment analysis
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
st.set_page_config(page_title="Sentiment Analysis App")
|
7 |
|
|
|
8 |
sentiment_classifier = pipeline("text-classification", model=model_path, tokenizer=model_path)
|
9 |
|
10 |
st.title("Sentiment Analysis App")
|
11 |
|
12 |
+
user_input = st.text_area("Enter a message:", height=150)
|
13 |
|
14 |
if st.button("Analyze Sentiment"):
|
15 |
if user_input:
|
16 |
# Perform sentiment analysis
|
17 |
+
st.markdown("---")
|
18 |
+
with st.spinner('Analyzing...'):
|
19 |
+
results = sentiment_classifier(user_input)
|
20 |
+
sentiment_label = results[0]["label"]
|
21 |
+
sentiment_score = results[0]["score"]
|
22 |
+
|
23 |
+
st.success("Analysis Complete!")
|
24 |
+
st.write("")
|
25 |
+
|
26 |
+
st.subheader("Sentiment Analysis Result")
|
27 |
+
st.write(f"**Sentiment:** {sentiment_label}")
|
28 |
+
st.write(f"**Confidence Score:** {sentiment_score:.2f}")
|