jvroo commited on
Commit
8ff291e
Β·
1 Parent(s): f6feac2

Final UI Changes

Browse files
Files changed (1) hide show
  1. app.py +21 -6
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.get('Description', 'N/A')
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
- return result_text, movie_description, movie_info, fig # Return the Matplotlib figure directly
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.Textbox(label="πŸ“ƒ Movie Description", interactive=False)
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, movie_info_output, plot_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