Spaces:
Sleeping
Sleeping
jvroo
commited on
Commit
Β·
8ff291e
1
Parent(s):
f6feac2
Final UI Changes
Browse files
app.py
CHANGED
|
@@ -81,8 +81,8 @@ def analyze_sentiment(movie_name, review, mode):
|
|
| 81 |
result_text = f"Sentiment: {sentiment}, Confidence: {score:.2f}\n{model_info}"
|
| 82 |
|
| 83 |
# Extract movie description
|
| 84 |
-
movie_description = movie_info
|
| 85 |
-
|
| 86 |
# Enhanced plot
|
| 87 |
fig, ax = plt.subplots(figsize=(8, 5))
|
| 88 |
|
|
@@ -104,7 +104,23 @@ def analyze_sentiment(movie_name, review, mode):
|
|
| 104 |
textcoords="offset points",
|
| 105 |
ha='center', va='bottom')
|
| 106 |
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
# Enhanced CSS for a modern, clean look
|
| 110 |
custom_css = """
|
|
@@ -181,14 +197,13 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 181 |
|
| 182 |
with gr.Column(scale=2):
|
| 183 |
sentiment_output = gr.Textbox(label="π¨οΈ Sentiment Analysis Result", interactive=False)
|
| 184 |
-
movie_description_output = gr.
|
| 185 |
-
movie_info_output = gr.JSON(label="βΉοΈ Movie Information")
|
| 186 |
plot_output = gr.Plot(label="π Sentiment Score Graph")
|
| 187 |
|
| 188 |
analyze_button.click(
|
| 189 |
analyze_sentiment,
|
| 190 |
[movie_input, review_input, mode_input],
|
| 191 |
-
[sentiment_output, movie_description_output,
|
| 192 |
)
|
| 193 |
|
| 194 |
# Run the Gradio app
|
|
|
|
| 81 |
result_text = f"Sentiment: {sentiment}, Confidence: {score:.2f}\n{model_info}"
|
| 82 |
|
| 83 |
# Extract movie description
|
| 84 |
+
movie_description = format_movie_description(movie_info)
|
| 85 |
+
|
| 86 |
# Enhanced plot
|
| 87 |
fig, ax = plt.subplots(figsize=(8, 5))
|
| 88 |
|
|
|
|
| 104 |
textcoords="offset points",
|
| 105 |
ha='center', va='bottom')
|
| 106 |
|
| 107 |
+
# Return the Matplotlib figure directly to plot_output
|
| 108 |
+
return result_text, movie_description, fig
|
| 109 |
+
|
| 110 |
+
# Function to format movie information into a prettier display
|
| 111 |
+
def format_movie_description(movie_info):
|
| 112 |
+
if 'Error' in movie_info:
|
| 113 |
+
return f"**Error:** {movie_info['Error']}"
|
| 114 |
+
|
| 115 |
+
return f"""
|
| 116 |
+
**π¬ Title:** {movie_info['Title']}
|
| 117 |
+
**π
Year:** {movie_info['Year']}
|
| 118 |
+
**π¨βπ€ Actors:** {movie_info['Actors']}
|
| 119 |
+
**π₯ Director:** {movie_info['Director']}
|
| 120 |
+
**π Rating:** {movie_info['Rating']}
|
| 121 |
+
**π Genre:** {movie_info['Genre']}
|
| 122 |
+
**π Description:** {movie_info['Description']}
|
| 123 |
+
"""
|
| 124 |
|
| 125 |
# Enhanced CSS for a modern, clean look
|
| 126 |
custom_css = """
|
|
|
|
| 197 |
|
| 198 |
with gr.Column(scale=2):
|
| 199 |
sentiment_output = gr.Textbox(label="π¨οΈ Sentiment Analysis Result", interactive=False)
|
| 200 |
+
movie_description_output = gr.Markdown(label="π Movie Description")
|
|
|
|
| 201 |
plot_output = gr.Plot(label="π Sentiment Score Graph")
|
| 202 |
|
| 203 |
analyze_button.click(
|
| 204 |
analyze_sentiment,
|
| 205 |
[movie_input, review_input, mode_input],
|
| 206 |
+
[sentiment_output, movie_description_output, plot_output]
|
| 207 |
)
|
| 208 |
|
| 209 |
# Run the Gradio app
|