Spaces:
Runtime error
Runtime error
Commit
•
68b6b17
1
Parent(s):
b72368a
updated sentiment classification
Browse files
app.py
CHANGED
@@ -1,9 +1,72 @@
|
|
1 |
import pandas as pd
|
2 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
st.title("NLP use cases")
|
5 |
|
6 |
with st.sidebar:
|
7 |
st.title("NLP tasks")
|
8 |
-
st.selectbox(label="Select task from drop down menu",
|
9 |
options=['Detect Sentiment','Zero Shot Classification'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import pandas as pd
|
2 |
import streamlit as st
|
3 |
+
from sentiment import classify_sentiment
|
4 |
+
|
5 |
+
st.set_page_config( # Alternate names: setup_page, page, layout
|
6 |
+
layout="wide", # Can be "centered" or "wide". In the future also "dashboard", etc.
|
7 |
+
initial_sidebar_state="auto", # Can be "auto", "expanded", "collapsed"
|
8 |
+
page_title='None', # String or None. Strings get appended with "• Streamlit".
|
9 |
+
)
|
10 |
+
# padding_top = 0
|
11 |
+
# st.markdown(f"""
|
12 |
+
# <style>
|
13 |
+
# .reportview-container .main .block-container{{
|
14 |
+
# padding-top: {padding_top}rem;
|
15 |
+
# }}
|
16 |
+
# </style>""",
|
17 |
+
# unsafe_allow_html=True,
|
18 |
+
# )
|
19 |
+
|
20 |
+
def set_page_title(title):
|
21 |
+
st.sidebar.markdown(unsafe_allow_html=True, body=f"""
|
22 |
+
<iframe height=0 srcdoc="<script>
|
23 |
+
const title = window.parent.document.querySelector('title') \
|
24 |
+
|
25 |
+
const oldObserver = window.parent.titleObserver
|
26 |
+
if (oldObserver) {{
|
27 |
+
oldObserver.disconnect()
|
28 |
+
}} \
|
29 |
+
|
30 |
+
const newObserver = new MutationObserver(function(mutations) {{
|
31 |
+
const target = mutations[0].target
|
32 |
+
if (target.text !== '{title}') {{
|
33 |
+
target.text = '{title}'
|
34 |
+
}}
|
35 |
+
}}) \
|
36 |
+
|
37 |
+
newObserver.observe(title, {{ childList: true }})
|
38 |
+
window.parent.titleObserver = newObserver \
|
39 |
+
|
40 |
+
title.text = '{title}'
|
41 |
+
</script>" />
|
42 |
+
""")
|
43 |
+
|
44 |
+
|
45 |
+
set_page_title('NLP use cases')
|
46 |
+
|
47 |
+
# Hide Menu Option
|
48 |
+
hide_streamlit_style = """
|
49 |
+
<style>
|
50 |
+
#MainMenu {visibility: hidden;}
|
51 |
+
footer {visibility: hidden;}
|
52 |
+
</style>
|
53 |
+
"""
|
54 |
+
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
55 |
+
|
56 |
|
57 |
st.title("NLP use cases")
|
58 |
|
59 |
with st.sidebar:
|
60 |
st.title("NLP tasks")
|
61 |
+
select_task=st.selectbox(label="Select task from drop down menu",
|
62 |
options=['Detect Sentiment','Zero Shot Classification'])
|
63 |
+
|
64 |
+
|
65 |
+
if select_task=='Detect Sentiment':
|
66 |
+
st.header("You are now performing Sentiment Analysis")
|
67 |
+
input_texts = st.text_input(label="Input texts separated by comma")
|
68 |
+
|
69 |
+
if input_texts!='':
|
70 |
+
sentiments = classify_sentiment(input_texts)
|
71 |
+
for i,t in enumerate(input_texts.split(',')):
|
72 |
+
st.write("** " + t + f"--> This statement is {sentiments[i]}")
|