Spaces:
Sleeping
Sleeping
hardik-kanzariya
commited on
Commit
•
ea1035b
1
Parent(s):
f4460ff
Update app.py
Browse files
app.py
CHANGED
@@ -74,18 +74,21 @@ def getSentiment(idx):
|
|
74 |
|
75 |
# st.query_params(api_predict=api_predict)
|
76 |
|
77 |
-
#
|
78 |
-
|
79 |
-
text = query_params.get("text", [""])[0]
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
84 |
"prediction": getSentiment(prediction) + " Statement",
|
85 |
"confidence": f"{confidence_score * 100:.2f}%"
|
86 |
})
|
87 |
else:
|
88 |
-
# Normal Streamlit app interface
|
89 |
input_text = st.text_area("Enter Text for Sentiment Analysis")
|
90 |
if input_text:
|
91 |
prediction, confidence_score = getPrediction(input_text)
|
|
|
74 |
|
75 |
# st.query_params(api_predict=api_predict)
|
76 |
|
77 |
+
# Streamlit UI
|
78 |
+
st.title("Sentiment Analysis")
|
|
|
79 |
|
80 |
+
# Use st.query_params to get the 'text' parameter from the URL
|
81 |
+
query_text = st.query_params.get("text", [""])[0] # Accessing 'text' from query params
|
82 |
+
|
83 |
+
if query_text:
|
84 |
+
# If text is passed in the URL, process it
|
85 |
+
prediction, confidence_score = getPrediction(query_text)
|
86 |
+
st.json({
|
87 |
"prediction": getSentiment(prediction) + " Statement",
|
88 |
"confidence": f"{confidence_score * 100:.2f}%"
|
89 |
})
|
90 |
else:
|
91 |
+
# Normal Streamlit app interface for manual text entry
|
92 |
input_text = st.text_area("Enter Text for Sentiment Analysis")
|
93 |
if input_text:
|
94 |
prediction, confidence_score = getPrediction(input_text)
|