Pranav0111 commited on
Commit
3fd18b2
·
verified ·
1 Parent(s): 2573724

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -18
app.py CHANGED
@@ -123,12 +123,7 @@ class JournalCompanion:
123
 
124
  def analyze_entry(self, entry_text):
125
  if not entry_text.strip():
126
- return {
127
- "message": "Please write something in your journal entry.",
128
- "sentiment": "",
129
- "prompts": "",
130
- "affirmation": ""
131
- }
132
 
133
  try:
134
  # Attempt to perform sentiment analysis
@@ -138,12 +133,12 @@ class JournalCompanion:
138
  except Exception as e:
139
  # Print the error to the console for debugging
140
  print("Error during sentiment analysis:", e)
141
- return {
142
- "message": "An error occurred during analysis. Please try again.",
143
- "sentiment": "Error",
144
- "prompts": "Could not generate prompts due to an error.",
145
- "affirmation": "Could not generate affirmation due to an error."
146
- }
147
 
148
  entry_data = {
149
  "text": entry_text,
@@ -158,12 +153,7 @@ class JournalCompanion:
158
  sentiment_percentage = f"{sentiment_score * 100:.1f}%"
159
  message = f"Entry analyzed! Sentiment: {sentiment} ({sentiment_percentage} confidence)"
160
 
161
- return {
162
- "message": message,
163
- "sentiment": sentiment,
164
- "prompts": "\n\n".join(prompts),
165
- "affirmation": affirmation
166
- }
167
 
168
  def get_monthly_insights(self):
169
  if not self.entries:
 
123
 
124
  def analyze_entry(self, entry_text):
125
  if not entry_text.strip():
126
+ return ("Please write something in your journal entry.", "", "", "")
 
 
 
 
 
127
 
128
  try:
129
  # Attempt to perform sentiment analysis
 
133
  except Exception as e:
134
  # Print the error to the console for debugging
135
  print("Error during sentiment analysis:", e)
136
+ return (
137
+ "An error occurred during analysis. Please try again.",
138
+ "Error",
139
+ "Could not generate prompts due to an error.",
140
+ "Could not generate affirmation due to an error."
141
+ )
142
 
143
  entry_data = {
144
  "text": entry_text,
 
153
  sentiment_percentage = f"{sentiment_score * 100:.1f}%"
154
  message = f"Entry analyzed! Sentiment: {sentiment} ({sentiment_percentage} confidence)"
155
 
156
+ return message, sentiment, "\n\n".join(prompts), affirmation
 
 
 
 
 
157
 
158
  def get_monthly_insights(self):
159
  if not self.entries: