Spaces:
Running
Running
Update scoring_calculation_system.py
Browse files
scoring_calculation_system.py
CHANGED
@@ -1160,10 +1160,19 @@ def check_critical_matches(scores: dict, user_prefs: UserPreferences) -> dict:
|
|
1160 |
return critical_issues
|
1161 |
|
1162 |
def apply_critical_penalty(scores: dict, critical_issues: dict) -> dict:
|
1163 |
-
"""
|
|
|
|
|
|
|
|
|
1164 |
penalized_scores = scores.copy()
|
1165 |
-
penalty_factor = 0.6
|
1166 |
|
|
|
|
|
|
|
|
|
|
|
1167 |
for reason in critical_issues['reasons']:
|
1168 |
if reason == 'space_incompatible':
|
1169 |
penalized_scores['overall'] *= penalty_factor
|
@@ -1175,6 +1184,10 @@ def apply_critical_penalty(scores: dict, critical_issues: dict) -> dict:
|
|
1175 |
penalized_scores['overall'] *= penalty_factor
|
1176 |
penalized_scores['experience'] *= penalty_factor
|
1177 |
|
|
|
|
|
|
|
|
|
1178 |
return penalized_scores
|
1179 |
|
1180 |
def calculate_environmental_fit(breed_info: dict, user_prefs: UserPreferences) -> float:
|
|
|
1160 |
return critical_issues
|
1161 |
|
1162 |
def apply_critical_penalty(scores: dict, critical_issues: dict) -> dict:
|
1163 |
+
"""
|
1164 |
+
當發現關鍵不適配時,調整分數
|
1165 |
+
|
1166 |
+
首先計算基礎整體分數,然後根據不同的關鍵問題應用懲罰係數
|
1167 |
+
"""
|
1168 |
penalized_scores = scores.copy()
|
1169 |
+
penalty_factor = 0.6 # 基礎懲罰因子
|
1170 |
|
1171 |
+
# 先計算基礎整體分數(使用簡單平均)
|
1172 |
+
base_overall = sum(scores.values()) / len(scores)
|
1173 |
+
penalized_scores['overall'] = base_overall
|
1174 |
+
|
1175 |
+
# 根據不同的關鍵問題應用懲罰
|
1176 |
for reason in critical_issues['reasons']:
|
1177 |
if reason == 'space_incompatible':
|
1178 |
penalized_scores['overall'] *= penalty_factor
|
|
|
1184 |
penalized_scores['overall'] *= penalty_factor
|
1185 |
penalized_scores['experience'] *= penalty_factor
|
1186 |
|
1187 |
+
# 確保所有分數都在有效範圍內
|
1188 |
+
for key in penalized_scores:
|
1189 |
+
penalized_scores[key] = max(0.1, min(1.0, penalized_scores[key]))
|
1190 |
+
|
1191 |
return penalized_scores
|
1192 |
|
1193 |
def calculate_environmental_fit(breed_info: dict, user_prefs: UserPreferences) -> float:
|