Spaces:
Running
on
Zero
Running
on
Zero
Update breed_recommendation.py
Browse files- breed_recommendation.py +32 -22
breed_recommendation.py
CHANGED
|
@@ -189,28 +189,38 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
|
|
| 189 |
|
| 190 |
# 從描述中提取用戶偏好
|
| 191 |
user_prefs = UserPreferences(
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
final_recommendations = []
|
| 216 |
|
|
|
|
| 189 |
|
| 190 |
# 從描述中提取用戶偏好
|
| 191 |
user_prefs = UserPreferences(
|
| 192 |
+
living_space="apartment" if any(word in description.lower()
|
| 193 |
+
for word in ["apartment", "flat", "condo"]) else "house_small",
|
| 194 |
+
yard_access="no_yard" if any(word in description.lower()
|
| 195 |
+
for word in ["apartment", "flat", "condo"]) else "private_yard",
|
| 196 |
+
exercise_time=120 if any(word in description.lower()
|
| 197 |
+
for word in ["active", "exercise", "running", "athletic", "high energy"]) else 60,
|
| 198 |
+
exercise_type="active_training" if any(word in description.lower()
|
| 199 |
+
for word in ["training", "running", "jogging", "hiking"]) else "moderate_activity",
|
| 200 |
+
grooming_commitment="high" if any(word in description.lower()
|
| 201 |
+
for word in ["grooming", "brush", "maintain"]) else "medium",
|
| 202 |
+
experience_level="experienced" if any(word in description.lower()
|
| 203 |
+
for word in ["experienced", "trained", "professional"]) else "intermediate",
|
| 204 |
+
time_availability="flexible" if any(word in description.lower()
|
| 205 |
+
for word in ["time", "available", "flexible", "home"]) else "moderate",
|
| 206 |
+
has_children=any(word in description.lower()
|
| 207 |
+
for word in ["children", "kids", "family", "child"]),
|
| 208 |
+
children_age="school_age" if any(word in description.lower()
|
| 209 |
+
for word in ["school", "elementary"]) else "teenager" if any(word in description.lower()
|
| 210 |
+
for word in ["teen", "teenager"]) else "toddler" if any(word in description.lower()
|
| 211 |
+
for word in ["baby", "toddler"]) else None,
|
| 212 |
+
noise_tolerance="low" if any(word in description.lower()
|
| 213 |
+
for word in ["quiet", "peaceful", "silent"]) else "medium",
|
| 214 |
+
space_for_play=any(word in description.lower()
|
| 215 |
+
for word in ["yard", "garden", "outdoor", "space"]),
|
| 216 |
+
other_pets=any(word in description.lower()
|
| 217 |
+
for word in ["other pets", "cats", "dogs"]),
|
| 218 |
+
climate="moderate",
|
| 219 |
+
health_sensitivity="high" if any(word in description.lower()
|
| 220 |
+
for word in ["health", "medical", "sensitive"]) else "medium",
|
| 221 |
+
barking_acceptance="low" if any(word in description.lower()
|
| 222 |
+
for word in ["quiet", "no barking"]) else "medium"
|
| 223 |
+
)
|
| 224 |
|
| 225 |
final_recommendations = []
|
| 226 |
|