Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
"
|
143 |
-
"
|
144 |
-
"
|
145 |
-
"
|
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:
|