-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.py
More file actions
77 lines (53 loc) · 1.7 KB
/
Copy pathhome.py
File metadata and controls
77 lines (53 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import streamlit as st
import pandas as pd
import os
import nltk
@st.cache_resource
def download_vader():
nltk.download('vader_lexicon')
download_vader()
from loader import extract_score,sentiment_analyzer,vader_model,analyze
#######################################################################
st.title("Multi Model Sentiment Evaluation")
# Init state
if "default" not in st.session_state:
st.session_state["default"] = ""
text_options = [
"I love this product!",
"The service was terrible.",
"This movie is amazing!",
"Just had the best meal of my life!",
"The product arrived damaged.",
]
# Pills FIRST
selection = st.pills(
"Some Examples",
text_options,
selection_mode="single"
)
# Update state BEFORE text_area renders
if selection:
st.session_state["default"] = selection
st.write("Enter Something to proceed ....")
# Text area AFTER state update
txt = st.text_area(
label="Input Text",
label_visibility="collapsed",
placeholder="Enter something here...",
value=st.session_state["default"]
)
if st.button("Analyze sentiment 💠"):
vader_score = extract_score(vader_model,txt)
textblob_score = sentiment_analyzer(txt)
nb_score,rf_score,xgb_score = analyze(txt)
scores = [vader_score,textblob_score,nb_score,rf_score,xgb_score]
score_df = pd.DataFrame({
"Model " :["Vader Sentiment","Text Blob ","Gaussain NB","RandomForest","XGBoost"],
"Scores": scores
})
st.dataframe(score_df)
avg = sum(scores)/len(scores)
if avg > 0.5:
st.markdown("## Overall Review : Positive ")
else:
st.markdown("## Overall Review : Negative ")