Spaces:
Running
on
Zero
Running
on
Zero
Update scoring_calculation_system.py
Browse files- scoring_calculation_system.py +18 -21
scoring_calculation_system.py
CHANGED
|
@@ -1305,11 +1305,9 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
| 1305 |
user_prefs.space_for_play,
|
| 1306 |
breed_info.get('Exercise Needs', 'Moderate')
|
| 1307 |
)
|
| 1308 |
-
print(f"
|
| 1309 |
-
print(f"使用參數 - Size: {breed_info['Size']}, Living Space: {user_prefs.living_space}")
|
| 1310 |
except Exception as e:
|
| 1311 |
print(f"空間分數計算錯誤: {str(e)}")
|
| 1312 |
-
print(f"錯誤詳情: {traceback.format_exc()}")
|
| 1313 |
raise
|
| 1314 |
|
| 1315 |
try:
|
|
@@ -1317,11 +1315,9 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
| 1317 |
breed_info.get('Exercise Needs', 'Moderate'),
|
| 1318 |
user_prefs.exercise_time
|
| 1319 |
)
|
| 1320 |
-
print(f"
|
| 1321 |
-
print(f"使用參數 - Exercise Needs: {breed_info.get('Exercise Needs', 'Moderate')}, Time: {user_prefs.exercise_time}")
|
| 1322 |
except Exception as e:
|
| 1323 |
print(f"運動分數計算錯誤: {str(e)}")
|
| 1324 |
-
print(f"錯誤詳情: {traceback.format_exc()}")
|
| 1325 |
raise
|
| 1326 |
|
| 1327 |
try:
|
|
@@ -1330,11 +1326,9 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
| 1330 |
user_prefs.grooming_commitment.lower(),
|
| 1331 |
breed_info['Size']
|
| 1332 |
)
|
| 1333 |
-
print(f"
|
| 1334 |
-
print(f"使用參數 - Grooming Needs: {breed_info.get('Grooming Needs', 'Moderate')}, Commitment: {user_prefs.grooming_commitment}")
|
| 1335 |
except Exception as e:
|
| 1336 |
print(f"美容分數計算錯誤: {str(e)}")
|
| 1337 |
-
print(f"錯誤詳情: {traceback.format_exc()}")
|
| 1338 |
raise
|
| 1339 |
|
| 1340 |
try:
|
|
@@ -1343,32 +1337,30 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
| 1343 |
user_prefs.experience_level,
|
| 1344 |
breed_info.get('Temperament', '')
|
| 1345 |
)
|
| 1346 |
-
print(f"
|
| 1347 |
-
print(f"使用參數 - Care Level: {breed_info.get('Care Level', 'Moderate')}, Experience: {user_prefs.experience_level}")
|
| 1348 |
except Exception as e:
|
| 1349 |
print(f"經驗分數計算錯誤: {str(e)}")
|
| 1350 |
-
print(f"錯誤詳情: {traceback.format_exc()}")
|
| 1351 |
raise
|
| 1352 |
|
| 1353 |
try:
|
| 1354 |
-
|
| 1355 |
-
|
| 1356 |
-
print(f"
|
| 1357 |
except Exception as e:
|
| 1358 |
print(f"健康分數計算錯誤: {str(e)}")
|
| 1359 |
-
print(f"錯誤詳情: {traceback.format_exc()}")
|
| 1360 |
raise
|
| 1361 |
|
| 1362 |
try:
|
| 1363 |
-
noise_score = calculate_noise_score(
|
| 1364 |
-
|
| 1365 |
-
|
|
|
|
|
|
|
| 1366 |
except Exception as e:
|
| 1367 |
print(f"噪音分數計算錯誤: {str(e)}")
|
| 1368 |
-
print(f"錯誤詳情: {traceback.format_exc()}")
|
| 1369 |
raise
|
| 1370 |
|
| 1371 |
-
#
|
| 1372 |
scores = {
|
| 1373 |
'space': space_score,
|
| 1374 |
'exercise': exercise_score,
|
|
@@ -1378,6 +1370,11 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
| 1378 |
'noise': noise_score
|
| 1379 |
}
|
| 1380 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1381 |
# 首先處理極端情況
|
| 1382 |
def check_critical_issues(scores: dict, breed_info: dict) -> float:
|
| 1383 |
"""
|
|
|
|
| 1305 |
user_prefs.space_for_play,
|
| 1306 |
breed_info.get('Exercise Needs', 'Moderate')
|
| 1307 |
)
|
| 1308 |
+
print(f"空間分數計算結果: {space_score}")
|
|
|
|
| 1309 |
except Exception as e:
|
| 1310 |
print(f"空間分數計算錯誤: {str(e)}")
|
|
|
|
| 1311 |
raise
|
| 1312 |
|
| 1313 |
try:
|
|
|
|
| 1315 |
breed_info.get('Exercise Needs', 'Moderate'),
|
| 1316 |
user_prefs.exercise_time
|
| 1317 |
)
|
| 1318 |
+
print(f"運動分數計算結果: {exercise_score}")
|
|
|
|
| 1319 |
except Exception as e:
|
| 1320 |
print(f"運動分數計算錯誤: {str(e)}")
|
|
|
|
| 1321 |
raise
|
| 1322 |
|
| 1323 |
try:
|
|
|
|
| 1326 |
user_prefs.grooming_commitment.lower(),
|
| 1327 |
breed_info['Size']
|
| 1328 |
)
|
| 1329 |
+
print(f"美容分數計算結果: {grooming_score}")
|
|
|
|
| 1330 |
except Exception as e:
|
| 1331 |
print(f"美容分數計算錯誤: {str(e)}")
|
|
|
|
| 1332 |
raise
|
| 1333 |
|
| 1334 |
try:
|
|
|
|
| 1337 |
user_prefs.experience_level,
|
| 1338 |
breed_info.get('Temperament', '')
|
| 1339 |
)
|
| 1340 |
+
print(f"經驗分數計算結果: {experience_score}")
|
|
|
|
| 1341 |
except Exception as e:
|
| 1342 |
print(f"經驗分數計算錯誤: {str(e)}")
|
|
|
|
| 1343 |
raise
|
| 1344 |
|
| 1345 |
try:
|
| 1346 |
+
# 修正:加入 user_prefs 參數
|
| 1347 |
+
health_score = calculate_health_score(breed_info.get('Breed', ''), user_prefs)
|
| 1348 |
+
print(f"健康分數計算結果: {health_score}")
|
| 1349 |
except Exception as e:
|
| 1350 |
print(f"健康分數計算錯誤: {str(e)}")
|
|
|
|
| 1351 |
raise
|
| 1352 |
|
| 1353 |
try:
|
| 1354 |
+
noise_score = calculate_noise_score(
|
| 1355 |
+
breed_info.get('Breed', ''),
|
| 1356 |
+
user_prefs.noise_tolerance
|
| 1357 |
+
)
|
| 1358 |
+
print(f"噪音分數計算結果: {noise_score}")
|
| 1359 |
except Exception as e:
|
| 1360 |
print(f"噪音分數計算錯誤: {str(e)}")
|
|
|
|
| 1361 |
raise
|
| 1362 |
|
| 1363 |
+
# 整合所有分數到字典中
|
| 1364 |
scores = {
|
| 1365 |
'space': space_score,
|
| 1366 |
'exercise': exercise_score,
|
|
|
|
| 1370 |
'noise': noise_score
|
| 1371 |
}
|
| 1372 |
|
| 1373 |
+
print("\n=== 所有基礎分數 ===")
|
| 1374 |
+
for category, score in scores.items():
|
| 1375 |
+
print(f"{category}: {score}")
|
| 1376 |
+
|
| 1377 |
+
|
| 1378 |
# 首先處理極端情況
|
| 1379 |
def check_critical_issues(scores: dict, breed_info: dict) -> float:
|
| 1380 |
"""
|