Spaces:
Running
Running
Update scoring_calculation_system.py
Browse files- scoring_calculation_system.py +20 -25
scoring_calculation_system.py
CHANGED
@@ -792,24 +792,24 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
792 |
# 根據品種大小調整美容工作量
|
793 |
size_adjustments = {
|
794 |
"Giant": {
|
795 |
-
"low": -0.
|
796 |
-
"medium": -0.
|
797 |
-
"high": -0.10
|
798 |
-
},
|
799 |
-
"Large": {
|
800 |
-
"low": -0.25,
|
801 |
-
"medium": -0.15,
|
802 |
"high": -0.05
|
803 |
},
|
804 |
-
"
|
805 |
"low": -0.15,
|
806 |
-
"medium": -0.
|
807 |
"high": 0
|
808 |
},
|
809 |
-
"
|
810 |
"low": -0.10,
|
811 |
"medium": -0.05,
|
812 |
"high": 0
|
|
|
|
|
|
|
|
|
|
|
813 |
}
|
814 |
}
|
815 |
|
@@ -1016,13 +1016,13 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
1016 |
|
1017 |
# 嚴重健康問題 - 加重扣分
|
1018 |
severe_conditions = {
|
1019 |
-
'hip dysplasia': -0.
|
1020 |
-
'heart disease': -0.
|
1021 |
-
'progressive retinal atrophy': -0.
|
1022 |
-
'bloat': -0.
|
1023 |
-
'epilepsy': -0.
|
1024 |
-
'degenerative myelopathy': -0.
|
1025 |
-
'von willebrand disease': -0.
|
1026 |
}
|
1027 |
|
1028 |
# 中度健康問題 - 適度扣分
|
@@ -1280,16 +1280,11 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
1280 |
|
1281 |
# 計算環境適應性加成
|
1282 |
adaptability_bonus = calculate_environmental_fit(breed_info, user_prefs)
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
# if user_prefs.living_space == "apartment" and breed_info['Size'] in ["Giant", "Large"]:
|
1287 |
-
# final_score *= 0.7 # 大型犬在公寓環境下的顯著懲罰
|
1288 |
|
1289 |
if (breed_info.get('Exercise Needs') == "Very High" and
|
1290 |
user_prefs.living_space == "apartment" and
|
1291 |
user_prefs.exercise_time < 90):
|
1292 |
-
final_score *= 0.
|
1293 |
|
1294 |
# 整合最終分數和加成
|
1295 |
combined_score = (final_score * 0.9) + (adaptability_bonus * 0.1)
|
@@ -2147,11 +2142,11 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
2147 |
for metric, score in critical_failures:
|
2148 |
if metric in ['space', 'exercise']:
|
2149 |
# 降低空間和運動失敗的懲罰程度
|
2150 |
-
penalty = (critical_thresholds[metric] - score) * 0.
|
2151 |
space_exercise_penalty += penalty
|
2152 |
else:
|
2153 |
# 其他失敗的懲罰保持較高
|
2154 |
-
penalty = (critical_thresholds[metric] - score) * 0.
|
2155 |
other_penalty += penalty
|
2156 |
|
2157 |
# 計算總懲罰,但使用更溫和的方式
|
|
|
792 |
# 根據品種大小調整美容工作量
|
793 |
size_adjustments = {
|
794 |
"Giant": {
|
795 |
+
"low": -0.20, # 大型犬的美容工作量顯著增加
|
796 |
+
"medium": -0.10,
|
|
|
|
|
|
|
|
|
|
|
797 |
"high": -0.05
|
798 |
},
|
799 |
+
"Large": {
|
800 |
"low": -0.15,
|
801 |
+
"medium": -0.05,
|
802 |
"high": 0
|
803 |
},
|
804 |
+
"Medium": {
|
805 |
"low": -0.10,
|
806 |
"medium": -0.05,
|
807 |
"high": 0
|
808 |
+
},
|
809 |
+
"Small": {
|
810 |
+
"low": -0.05,
|
811 |
+
"medium": 0,
|
812 |
+
"high": 0
|
813 |
}
|
814 |
}
|
815 |
|
|
|
1016 |
|
1017 |
# 嚴重健康問題 - 加重扣分
|
1018 |
severe_conditions = {
|
1019 |
+
'hip dysplasia': -0.20, # 髖關節發育不良,影響生活品質
|
1020 |
+
'heart disease': -0.15, # 心臟疾病,需要長期治療
|
1021 |
+
'progressive retinal atrophy': -0.15, # 進行性視網膜萎縮,導致失明
|
1022 |
+
'bloat': -0.18, # 胃扭轉,致命風險
|
1023 |
+
'epilepsy': -0.15, # 癲癇,需要長期藥物控制
|
1024 |
+
'degenerative myelopathy': -0.15, # 脊髓退化,影響行動能力
|
1025 |
+
'von willebrand disease': -0.12 # 血液凝固障礙
|
1026 |
}
|
1027 |
|
1028 |
# 中度健康問題 - 適度扣分
|
|
|
1280 |
|
1281 |
# 計算環境適應性加成
|
1282 |
adaptability_bonus = calculate_environmental_fit(breed_info, user_prefs)
|
|
|
|
|
|
|
|
|
|
|
1283 |
|
1284 |
if (breed_info.get('Exercise Needs') == "Very High" and
|
1285 |
user_prefs.living_space == "apartment" and
|
1286 |
user_prefs.exercise_time < 90):
|
1287 |
+
final_score *= 0.85 # 高運動需求但條件不足的懲罰
|
1288 |
|
1289 |
# 整合最終分數和加成
|
1290 |
combined_score = (final_score * 0.9) + (adaptability_bonus * 0.1)
|
|
|
2142 |
for metric, score in critical_failures:
|
2143 |
if metric in ['space', 'exercise']:
|
2144 |
# 降低空間和運動失敗的懲罰程度
|
2145 |
+
penalty = (critical_thresholds[metric] - score) * 0.08
|
2146 |
space_exercise_penalty += penalty
|
2147 |
else:
|
2148 |
# 其他失敗的懲罰保持較高
|
2149 |
+
penalty = (critical_thresholds[metric] - score) * 0.20
|
2150 |
other_penalty += penalty
|
2151 |
|
2152 |
# 計算總懲罰,但使用更溫和的方式
|