Update app.py
Browse files
app.py
CHANGED
@@ -193,7 +193,7 @@ def classify_sentiment(text_input, reddit_url):
|
|
193 |
return f"[!] Prediction error: {str(e)}"
|
194 |
|
195 |
# Gradio UI
|
196 |
-
demo = gr.Interface(
|
197 |
fn=classify_sentiment,
|
198 |
inputs=[
|
199 |
gr.Textbox(
|
@@ -210,7 +210,67 @@ demo = gr.Interface(
|
|
210 |
outputs="text",
|
211 |
title="Sentiment Analyzer",
|
212 |
description="π Paste any text (including tweet content) OR a Reddit post URL to analyze sentiment.\n\nπ‘ Tweet URLs are not supported directly due to platform restrictions. Please paste tweet content manually."
|
213 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
|
215 |
demo.launch()
|
216 |
|
|
|
193 |
return f"[!] Prediction error: {str(e)}"
|
194 |
|
195 |
# Gradio UI
|
196 |
+
'''demo = gr.Interface(
|
197 |
fn=classify_sentiment,
|
198 |
inputs=[
|
199 |
gr.Textbox(
|
|
|
210 |
outputs="text",
|
211 |
title="Sentiment Analyzer",
|
212 |
description="π Paste any text (including tweet content) OR a Reddit post URL to analyze sentiment.\n\nπ‘ Tweet URLs are not supported directly due to platform restrictions. Please paste tweet content manually."
|
213 |
+
)'''
|
214 |
+
demo = gr.Blocks(theme=gr.themes.Soft(), css="footer {visibility: hidden}")
|
215 |
+
|
216 |
+
with demo:
|
217 |
+
gr.Markdown("""
|
218 |
+
# π Sentiment Analysis Tool
|
219 |
+
*Uncover the emotional tone behind text content and Reddit posts*
|
220 |
+
""")
|
221 |
+
|
222 |
+
with gr.Row():
|
223 |
+
with gr.Column():
|
224 |
+
gr.Markdown("## π₯ Input Options")
|
225 |
+
with gr.Tabs():
|
226 |
+
with gr.TabItem("π Text Content"):
|
227 |
+
text_input = gr.Textbox(
|
228 |
+
label="Paste Your Text Content",
|
229 |
+
placeholder="Enter tweet, comment, or any text here...",
|
230 |
+
lines=5,
|
231 |
+
elem_id="text-input"
|
232 |
+
)
|
233 |
+
with gr.TabItem("π Reddit Post"):
|
234 |
+
url_input = gr.Textbox(
|
235 |
+
label="Reddit Post URL",
|
236 |
+
placeholder="Paste Reddit post URL here (e.g., https://www.reddit.com/r/...)",
|
237 |
+
lines=1,
|
238 |
+
elem_id="url-input"
|
239 |
+
)
|
240 |
+
gr.Markdown("""
|
241 |
+
<div style="background: #fff3cd; padding: 15px; border-radius: 8px; margin-top: 10px;">
|
242 |
+
β οΈ Note: For Twitter analysis, please paste text content directly due to platform restrictions
|
243 |
+
</div>
|
244 |
+
""", elem_id="warning-box")
|
245 |
+
|
246 |
+
with gr.Column():
|
247 |
+
gr.Markdown("## π Analysis Results")
|
248 |
+
output_text = gr.Textbox(
|
249 |
+
label="Sentiment Assessment",
|
250 |
+
placeholder="Your analysis will appear here...",
|
251 |
+
interactive=False,
|
252 |
+
lines=5,
|
253 |
+
elem_id="result-box"
|
254 |
+
)
|
255 |
+
examples = gr.Examples(
|
256 |
+
examples=[
|
257 |
+
["Just had the most amazing dinner! The service was incredible!"],
|
258 |
+
["https://www.reddit.com/r/technology/comments/xyz123/new_ai_breakthrough"],
|
259 |
+
["Really disappointed with the latest update. Features are missing and it's so slow."]
|
260 |
+
],
|
261 |
+
inputs=[text_input],
|
262 |
+
label="π‘ Try These Examples"
|
263 |
+
)
|
264 |
+
|
265 |
+
gr.Markdown("""
|
266 |
+
<div style="text-align: center; margin-top: 20px; padding: 15px; background: #f8f9fa; border-radius: 8px;">
|
267 |
+
π Powered by Gradio & Hugging Face |
|
268 |
+
[Privacy Policy](#) |
|
269 |
+
[Terms of Service](#) |
|
270 |
+
[GitHub Repo](#)
|
271 |
+
</div>
|
272 |
+
""", elem_id="footer")
|
273 |
+
|
274 |
|
275 |
demo.launch()
|
276 |
|