Spaces:
Running
Running
Update scoring_calculation_system.py
Browse files- scoring_calculation_system.py +45 -56
scoring_calculation_system.py
CHANGED
@@ -33,7 +33,7 @@ class UserPreferences:
|
|
33 |
|
34 |
def apply_size_filter(breed_score: float, user_preference: str, breed_size: str) -> float:
|
35 |
"""
|
36 |
-
|
37 |
|
38 |
Parameters:
|
39 |
breed_score (float): 原始品種評分
|
@@ -161,14 +161,14 @@ def calculate_breed_bonus(breed_info: dict, user_prefs: 'UserPreferences') -> fl
|
|
161 |
# 6. 適應性評估
|
162 |
adaptability_bonus = 0.0
|
163 |
if breed_info.get('Size') == "Small" and user_prefs.living_space == "apartment":
|
164 |
-
adaptability_bonus += 0.08
|
165 |
|
166 |
# 環境適應性評估
|
167 |
if 'adaptable' in temperament or 'versatile' in temperament:
|
168 |
if user_prefs.living_space == "apartment":
|
169 |
-
adaptability_bonus += 0.10
|
170 |
else:
|
171 |
-
adaptability_bonus += 0.05
|
172 |
|
173 |
# 氣候適應性
|
174 |
description = breed_info.get('Description', '').lower()
|
@@ -633,7 +633,7 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
633 |
|
634 |
def calculate_exercise_score(breed_needs: str, exercise_time: int, exercise_type: str, breed_size: str, living_space: str) -> float:
|
635 |
"""
|
636 |
-
|
637 |
1. 不同品種的運動耐受度差異
|
638 |
2. 運動時間與類型的匹配度
|
639 |
3. 極端運動量的嚴格限制
|
@@ -902,21 +902,21 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
902 |
2. 縮小經驗等級間的差距
|
903 |
3. 保持適度的區分度
|
904 |
"""
|
905 |
-
# 基礎分數矩陣
|
906 |
base_scores = {
|
907 |
"High": {
|
908 |
"beginner": 0.55, # 提高起始分,讓新手也有機會
|
909 |
-
"intermediate": 0.80, #
|
910 |
"advanced": 0.95 # 資深者幾乎完全勝任
|
911 |
},
|
912 |
"Moderate": {
|
913 |
"beginner": 0.65, # 適中難度對新手更友善
|
914 |
-
"intermediate": 0.85, #
|
915 |
"advanced": 0.90 # 資深者完全勝任
|
916 |
},
|
917 |
"Low": {
|
918 |
"beginner": 0.85, # 新手友善品種維持高分
|
919 |
-
"intermediate": 0.90, #
|
920 |
"advanced": 0.90 # 資深者完全勝任
|
921 |
}
|
922 |
}
|
@@ -924,25 +924,25 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
924 |
# 取得基礎分數
|
925 |
score = base_scores.get(care_level, base_scores["Moderate"])[user_experience]
|
926 |
|
927 |
-
#
|
928 |
temperament_lower = temperament.lower()
|
929 |
temperament_adjustments = 0.0
|
930 |
|
931 |
# 根據經驗等級設定不同的特徵評估標準,降低懲罰程度
|
932 |
if user_experience == "beginner":
|
933 |
difficult_traits = {
|
934 |
-
'stubborn': -0.15,
|
935 |
'independent': -0.12,
|
936 |
'dominant': -0.12,
|
937 |
'strong-willed': -0.10,
|
938 |
'protective': -0.10,
|
939 |
'aloof': -0.08,
|
940 |
'energetic': -0.08,
|
941 |
-
'aggressive': -0.20
|
942 |
}
|
943 |
|
944 |
easy_traits = {
|
945 |
-
'gentle': 0.08,
|
946 |
'friendly': 0.08,
|
947 |
'eager to please': 0.10,
|
948 |
'patient': 0.08,
|
@@ -967,7 +967,7 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
967 |
elif 'guard' in temperament_lower:
|
968 |
temperament_adjustments -= 0.12
|
969 |
|
970 |
-
#
|
971 |
elif user_experience == "intermediate":
|
972 |
moderate_traits = {
|
973 |
'stubborn': -0.08,
|
@@ -1237,7 +1237,7 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
1237 |
print(f"品種信息: {breed_info}")
|
1238 |
print(f"使用者偏好: {vars(user_prefs)}")
|
1239 |
|
1240 |
-
#
|
1241 |
scores = {
|
1242 |
'space': calculate_space_score(
|
1243 |
breed_info['Size'],
|
@@ -1348,7 +1348,7 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
1348 |
"""
|
1349 |
def evaluate_perfect_conditions():
|
1350 |
"""
|
1351 |
-
|
1352 |
1. 運動類型與時間的綜合評估
|
1353 |
2. 專業技能需求評估
|
1354 |
3. 品種特性評估
|
@@ -1358,13 +1358,13 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
1358 |
'exercise_match': 0,
|
1359 |
'experience_match': 0,
|
1360 |
'living_condition_match': 0,
|
1361 |
-
'breed_trait_match': 0
|
1362 |
}
|
1363 |
|
1364 |
# 第一部分:運動需求評估
|
1365 |
def evaluate_exercise_compatibility():
|
1366 |
"""
|
1367 |
-
|
1368 |
1. 時間與強度的合理搭配
|
1369 |
2. 不同品種的運動特性
|
1370 |
3. 運動類型的適配性
|
@@ -1425,7 +1425,7 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
1425 |
}
|
1426 |
|
1427 |
def determine_breed_type():
|
1428 |
-
"""
|
1429 |
# 優先檢查特殊運動類型的標識符
|
1430 |
for breed_type, pattern in breed_exercise_patterns.items():
|
1431 |
if any(identifier in temperament or identifier in description
|
@@ -1477,7 +1477,6 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
1477 |
def apply_special_adjustments(time_score, type_score, breed_type, pattern):
|
1478 |
"""
|
1479 |
處理特殊情況,確保運動方式真正符合品種需求。
|
1480 |
-
特別加強:
|
1481 |
1. 短跑型犬種的長時間運動懲罰
|
1482 |
2. 耐力型犬種的獎勵機制
|
1483 |
3. 運動類型匹配的重要性
|
@@ -1496,7 +1495,7 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
1496 |
elif breed_type == 'endurance_type':
|
1497 |
if exercise_time < pattern['time_ranges']['penalty_start']:
|
1498 |
time_score *= 0.5 # 維持運動不足的懲罰
|
1499 |
-
elif exercise_time >= 150:
|
1500 |
if exercise_type in ['active_training', 'moderate_activity']:
|
1501 |
time_bonus = min(0.3, (exercise_time - 150) / 150)
|
1502 |
time_score = min(1.0, time_score * (1 + time_bonus))
|
@@ -1575,7 +1574,7 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
1575 |
|
1576 |
def evaluate_living_conditions() -> float:
|
1577 |
"""
|
1578 |
-
|
1579 |
1. 降低對大型犬的過度懲罰
|
1580 |
2. 增加品種特性評估
|
1581 |
3. 提升對適應性的重視度
|
@@ -1700,7 +1699,7 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
1700 |
|
1701 |
def calculate_weights() -> dict:
|
1702 |
"""
|
1703 |
-
|
1704 |
1. 極端情況的權重調整
|
1705 |
2. 使用者條件的協同效應
|
1706 |
3. 品種特性的影響
|
@@ -1739,7 +1738,7 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
1739 |
|
1740 |
# 空間限制評估 - 更合理的空間評估
|
1741 |
space_extremity = {
|
1742 |
-
'apartment': ('restricted', 0.7),
|
1743 |
'house_small': ('moderate', 0.5),
|
1744 |
'house_large': ('spacious', 0.3)
|
1745 |
}
|
@@ -1876,9 +1875,9 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
1876 |
adjustments['experience'] = 2.5
|
1877 |
elif extremities['experience'][0] == 'high':
|
1878 |
if is_working_dog:
|
1879 |
-
adjustments['experience'] = 2.5
|
1880 |
if extremities['exercise'][0] in ['high', 'extremely_high']:
|
1881 |
-
adjustments['experience'] = 2.8
|
1882 |
else:
|
1883 |
adjustments['experience'] = 1.8
|
1884 |
|
@@ -1890,7 +1889,7 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
1890 |
adjustments['space'] = adjustments.get('space', 1.0) * 1.3
|
1891 |
adjustments['exercise'] = adjustments.get('exercise', 1.0) * 1.3
|
1892 |
|
1893 |
-
#
|
1894 |
if (extremities['experience'][0] == 'high' and
|
1895 |
extremities['space'][0] == 'spacious' and
|
1896 |
extremities['exercise'][0] in ['high', 'extremely_high'] and
|
@@ -1931,14 +1930,11 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
1931 |
|
1932 |
def apply_special_case_adjustments(score: float) -> float:
|
1933 |
"""
|
1934 |
-
|
1935 |
1. 條件組合的協同效應
|
1936 |
2. 品種特性的獨特需求
|
1937 |
3. 極端情況的合理處理
|
1938 |
-
|
1939 |
-
這個函數就像是一個細心的裁判,會考慮到各種特殊情況,
|
1940 |
-
並根據具體場景做出合理的評分調整。
|
1941 |
-
|
1942 |
Parameters:
|
1943 |
score: 初始評分
|
1944 |
Returns:
|
@@ -1967,16 +1963,16 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
1967 |
# 大型犬的特殊處理
|
1968 |
if breed_info['Size'] in ['Large', 'Giant']:
|
1969 |
if apartment_friendly:
|
1970 |
-
multiplier *= 0.85
|
1971 |
else:
|
1972 |
-
multiplier *= 0.75
|
1973 |
|
1974 |
# 檢查運動需求的匹配度
|
1975 |
exercise_needs = breed_info.get('Exercise Needs', 'MODERATE').upper()
|
1976 |
exercise_time = user_prefs.exercise_time
|
1977 |
|
1978 |
if exercise_needs in ['HIGH', 'VERY HIGH']:
|
1979 |
-
if exercise_time >= 120:
|
1980 |
multiplier *= 1.1
|
1981 |
|
1982 |
return multiplier
|
@@ -1996,17 +1992,17 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
1996 |
if user_prefs.experience_level == 'beginner':
|
1997 |
if care_level == 'HIGH':
|
1998 |
if user_prefs.has_children:
|
1999 |
-
multiplier *= 0.7
|
2000 |
else:
|
2001 |
-
multiplier *= 0.8
|
2002 |
|
2003 |
# 性格特徵影響,降低懲罰程度
|
2004 |
challenging_traits = {
|
2005 |
-
'stubborn': -0.10,
|
2006 |
-
'independent': -0.08,
|
2007 |
-
'dominant': -0.08,
|
2008 |
-
'protective': -0.06,
|
2009 |
-
'aggressive': -0.15
|
2010 |
}
|
2011 |
|
2012 |
for trait, penalty in challenging_traits.items():
|
@@ -2018,9 +2014,6 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
2018 |
def evaluate_breed_specific_requirements() -> float:
|
2019 |
"""
|
2020 |
評估品種特定需求。
|
2021 |
-
|
2022 |
-
這個函數就像是為每個品種量身定制評估標準,
|
2023 |
-
考慮其獨特的特性和需求。
|
2024 |
"""
|
2025 |
multiplier = 1.0
|
2026 |
exercise_time = user_prefs.exercise_time
|
@@ -2034,19 +2027,19 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
2034 |
# 運動需求匹配度評估,更合理的標準
|
2035 |
if exercise_needs == 'LOW':
|
2036 |
if exercise_time > 120:
|
2037 |
-
multiplier *= 0.85
|
2038 |
elif exercise_needs == 'VERY HIGH':
|
2039 |
if exercise_time < 60:
|
2040 |
-
multiplier *= 0.7
|
2041 |
|
2042 |
# 特殊品種類型的考慮
|
2043 |
if 'sprint' in temperament:
|
2044 |
if exercise_time > 120 and exercise_type != 'active_training':
|
2045 |
-
multiplier *= 0.85
|
2046 |
|
2047 |
if any(trait in temperament for trait in ['working', 'herding']):
|
2048 |
if exercise_time < 90 or exercise_type == 'light_walks':
|
2049 |
-
multiplier *= 0.8
|
2050 |
|
2051 |
return multiplier
|
2052 |
|
@@ -2066,9 +2059,8 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
2066 |
|
2067 |
def calculate_base_score(scores: dict, weights: dict) -> float:
|
2068 |
"""
|
2069 |
-
|
2070 |
-
|
2071 |
-
這個函數使用了改進後的評分邏輯,主要關注:
|
2072 |
1. 降低關鍵指標的最低門檻,使系統更包容
|
2073 |
2. 引入非線性評分曲線,讓分數分布更合理
|
2074 |
3. 優化多重條件失敗的處理方式
|
@@ -2288,10 +2280,7 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
2288 |
|
2289 |
|
2290 |
def amplify_score_extreme(score: float) -> float:
|
2291 |
-
"""
|
2292 |
-
優化分數分布,提供更有意義的評分範圍。
|
2293 |
-
純粹進行數學轉換,不依賴外部資訊。
|
2294 |
-
|
2295 |
Parameters:
|
2296 |
score: 原始評分(0-1之間的浮點數)
|
2297 |
|
|
|
33 |
|
34 |
def apply_size_filter(breed_score: float, user_preference: str, breed_size: str) -> float:
|
35 |
"""
|
36 |
+
基於用戶的體型偏好過濾品種,只要不符合就過濾掉
|
37 |
|
38 |
Parameters:
|
39 |
breed_score (float): 原始品種評分
|
|
|
161 |
# 6. 適應性評估
|
162 |
adaptability_bonus = 0.0
|
163 |
if breed_info.get('Size') == "Small" and user_prefs.living_space == "apartment":
|
164 |
+
adaptability_bonus += 0.08
|
165 |
|
166 |
# 環境適應性評估
|
167 |
if 'adaptable' in temperament or 'versatile' in temperament:
|
168 |
if user_prefs.living_space == "apartment":
|
169 |
+
adaptability_bonus += 0.10
|
170 |
else:
|
171 |
+
adaptability_bonus += 0.05
|
172 |
|
173 |
# 氣候適應性
|
174 |
description = breed_info.get('Description', '').lower()
|
|
|
633 |
|
634 |
def calculate_exercise_score(breed_needs: str, exercise_time: int, exercise_type: str, breed_size: str, living_space: str) -> float:
|
635 |
"""
|
636 |
+
計算品種運動需求與使用者運動條件的匹配度
|
637 |
1. 不同品種的運動耐受度差異
|
638 |
2. 運動時間與類型的匹配度
|
639 |
3. 極端運動量的嚴格限制
|
|
|
902 |
2. 縮小經驗等級間的差距
|
903 |
3. 保持適度的區分度
|
904 |
"""
|
905 |
+
# 基礎分數矩陣
|
906 |
base_scores = {
|
907 |
"High": {
|
908 |
"beginner": 0.55, # 提高起始分,讓新手也有機會
|
909 |
+
"intermediate": 0.80, # 中等經驗用戶可能有不錯的勝任能力
|
910 |
"advanced": 0.95 # 資深者幾乎完全勝任
|
911 |
},
|
912 |
"Moderate": {
|
913 |
"beginner": 0.65, # 適中難度對新手更友善
|
914 |
+
"intermediate": 0.85, # 中等經驗用戶相當適合
|
915 |
"advanced": 0.90 # 資深者完全勝任
|
916 |
},
|
917 |
"Low": {
|
918 |
"beginner": 0.85, # 新手友善品種維持高分
|
919 |
+
"intermediate": 0.90, # 中等經驗用戶幾乎完全勝任
|
920 |
"advanced": 0.90 # 資深者完全勝任
|
921 |
}
|
922 |
}
|
|
|
924 |
# 取得基礎分數
|
925 |
score = base_scores.get(care_level, base_scores["Moderate"])[user_experience]
|
926 |
|
927 |
+
# 性格評估的權重
|
928 |
temperament_lower = temperament.lower()
|
929 |
temperament_adjustments = 0.0
|
930 |
|
931 |
# 根據經驗等級設定不同的特徵評估標準,降低懲罰程度
|
932 |
if user_experience == "beginner":
|
933 |
difficult_traits = {
|
934 |
+
'stubborn': -0.15,
|
935 |
'independent': -0.12,
|
936 |
'dominant': -0.12,
|
937 |
'strong-willed': -0.10,
|
938 |
'protective': -0.10,
|
939 |
'aloof': -0.08,
|
940 |
'energetic': -0.08,
|
941 |
+
'aggressive': -0.20
|
942 |
}
|
943 |
|
944 |
easy_traits = {
|
945 |
+
'gentle': 0.08,
|
946 |
'friendly': 0.08,
|
947 |
'eager to please': 0.10,
|
948 |
'patient': 0.08,
|
|
|
967 |
elif 'guard' in temperament_lower:
|
968 |
temperament_adjustments -= 0.12
|
969 |
|
970 |
+
# 中等經驗用戶
|
971 |
elif user_experience == "intermediate":
|
972 |
moderate_traits = {
|
973 |
'stubborn': -0.08,
|
|
|
1237 |
print(f"品種信息: {breed_info}")
|
1238 |
print(f"使用者偏好: {vars(user_prefs)}")
|
1239 |
|
1240 |
+
# 計算所有基礎分數
|
1241 |
scores = {
|
1242 |
'space': calculate_space_score(
|
1243 |
breed_info['Size'],
|
|
|
1348 |
"""
|
1349 |
def evaluate_perfect_conditions():
|
1350 |
"""
|
1351 |
+
評估條件匹配度:
|
1352 |
1. 運動類型與時間的綜合評估
|
1353 |
2. 專業技能需求評估
|
1354 |
3. 品種特性評估
|
|
|
1358 |
'exercise_match': 0,
|
1359 |
'experience_match': 0,
|
1360 |
'living_condition_match': 0,
|
1361 |
+
'breed_trait_match': 0
|
1362 |
}
|
1363 |
|
1364 |
# 第一部分:運動需求評估
|
1365 |
def evaluate_exercise_compatibility():
|
1366 |
"""
|
1367 |
+
評估運動需求的匹配度:
|
1368 |
1. 時間與強度的合理搭配
|
1369 |
2. 不同品種的運動特性
|
1370 |
3. 運動類型的適配性
|
|
|
1425 |
}
|
1426 |
|
1427 |
def determine_breed_type():
|
1428 |
+
"""改進品種運動類型的判斷,識別工作犬"""
|
1429 |
# 優先檢查特殊運動類型的標識符
|
1430 |
for breed_type, pattern in breed_exercise_patterns.items():
|
1431 |
if any(identifier in temperament or identifier in description
|
|
|
1477 |
def apply_special_adjustments(time_score, type_score, breed_type, pattern):
|
1478 |
"""
|
1479 |
處理特殊情況,確保運動方式真正符合品種需求。
|
|
|
1480 |
1. 短跑型犬種的長時間運動懲罰
|
1481 |
2. 耐力型犬種的獎勵機制
|
1482 |
3. 運動類型匹配的重要性
|
|
|
1495 |
elif breed_type == 'endurance_type':
|
1496 |
if exercise_time < pattern['time_ranges']['penalty_start']:
|
1497 |
time_score *= 0.5 # 維持運動不足的懲罰
|
1498 |
+
elif exercise_time >= 150:
|
1499 |
if exercise_type in ['active_training', 'moderate_activity']:
|
1500 |
time_bonus = min(0.3, (exercise_time - 150) / 150)
|
1501 |
time_score = min(1.0, time_score * (1 + time_bonus))
|
|
|
1574 |
|
1575 |
def evaluate_living_conditions() -> float:
|
1576 |
"""
|
1577 |
+
評估生活環境適配性:
|
1578 |
1. 降低對大型犬的過度懲罰
|
1579 |
2. 增加品種特性評估
|
1580 |
3. 提升對適應性的重視度
|
|
|
1699 |
|
1700 |
def calculate_weights() -> dict:
|
1701 |
"""
|
1702 |
+
動態計算評分權重:
|
1703 |
1. 極端情況的權重調整
|
1704 |
2. 使用者條件的協同效應
|
1705 |
3. 品種特性的影響
|
|
|
1738 |
|
1739 |
# 空間限制評估 - 更合理的空間評估
|
1740 |
space_extremity = {
|
1741 |
+
'apartment': ('restricted', 0.7),
|
1742 |
'house_small': ('moderate', 0.5),
|
1743 |
'house_large': ('spacious', 0.3)
|
1744 |
}
|
|
|
1875 |
adjustments['experience'] = 2.5
|
1876 |
elif extremities['experience'][0] == 'high':
|
1877 |
if is_working_dog:
|
1878 |
+
adjustments['experience'] = 2.5
|
1879 |
if extremities['exercise'][0] in ['high', 'extremely_high']:
|
1880 |
+
adjustments['experience'] = 2.8
|
1881 |
else:
|
1882 |
adjustments['experience'] = 1.8
|
1883 |
|
|
|
1889 |
adjustments['space'] = adjustments.get('space', 1.0) * 1.3
|
1890 |
adjustments['exercise'] = adjustments.get('exercise', 1.0) * 1.3
|
1891 |
|
1892 |
+
# 專家 + 大空間 + 高運動量 + 工作犬的組合
|
1893 |
if (extremities['experience'][0] == 'high' and
|
1894 |
extremities['space'][0] == 'spacious' and
|
1895 |
extremities['exercise'][0] in ['high', 'extremely_high'] and
|
|
|
1930 |
|
1931 |
def apply_special_case_adjustments(score: float) -> float:
|
1932 |
"""
|
1933 |
+
處理特殊情況和極端案例的評分調整:
|
1934 |
1. 條件組合的協同效應
|
1935 |
2. 品種特性的獨特需求
|
1936 |
3. 極端情況的合理處理
|
1937 |
+
|
|
|
|
|
|
|
1938 |
Parameters:
|
1939 |
score: 初始評分
|
1940 |
Returns:
|
|
|
1963 |
# 大型犬的特殊處理
|
1964 |
if breed_info['Size'] in ['Large', 'Giant']:
|
1965 |
if apartment_friendly:
|
1966 |
+
multiplier *= 0.85
|
1967 |
else:
|
1968 |
+
multiplier *= 0.75
|
1969 |
|
1970 |
# 檢查運動需求的匹配度
|
1971 |
exercise_needs = breed_info.get('Exercise Needs', 'MODERATE').upper()
|
1972 |
exercise_time = user_prefs.exercise_time
|
1973 |
|
1974 |
if exercise_needs in ['HIGH', 'VERY HIGH']:
|
1975 |
+
if exercise_time >= 120:
|
1976 |
multiplier *= 1.1
|
1977 |
|
1978 |
return multiplier
|
|
|
1992 |
if user_prefs.experience_level == 'beginner':
|
1993 |
if care_level == 'HIGH':
|
1994 |
if user_prefs.has_children:
|
1995 |
+
multiplier *= 0.7
|
1996 |
else:
|
1997 |
+
multiplier *= 0.8
|
1998 |
|
1999 |
# 性格特徵影響,降低懲罰程度
|
2000 |
challenging_traits = {
|
2001 |
+
'stubborn': -0.10,
|
2002 |
+
'independent': -0.08,
|
2003 |
+
'dominant': -0.08,
|
2004 |
+
'protective': -0.06,
|
2005 |
+
'aggressive': -0.15
|
2006 |
}
|
2007 |
|
2008 |
for trait, penalty in challenging_traits.items():
|
|
|
2014 |
def evaluate_breed_specific_requirements() -> float:
|
2015 |
"""
|
2016 |
評估品種特定需求。
|
|
|
|
|
|
|
2017 |
"""
|
2018 |
multiplier = 1.0
|
2019 |
exercise_time = user_prefs.exercise_time
|
|
|
2027 |
# 運動需求匹配度評估,更合理的標準
|
2028 |
if exercise_needs == 'LOW':
|
2029 |
if exercise_time > 120:
|
2030 |
+
multiplier *= 0.85
|
2031 |
elif exercise_needs == 'VERY HIGH':
|
2032 |
if exercise_time < 60:
|
2033 |
+
multiplier *= 0.7
|
2034 |
|
2035 |
# 特殊品種類型的考慮
|
2036 |
if 'sprint' in temperament:
|
2037 |
if exercise_time > 120 and exercise_type != 'active_training':
|
2038 |
+
multiplier *= 0.85
|
2039 |
|
2040 |
if any(trait in temperament for trait in ['working', 'herding']):
|
2041 |
if exercise_time < 90 or exercise_type == 'light_walks':
|
2042 |
+
multiplier *= 0.8
|
2043 |
|
2044 |
return multiplier
|
2045 |
|
|
|
2059 |
|
2060 |
def calculate_base_score(scores: dict, weights: dict) -> float:
|
2061 |
"""
|
2062 |
+
計算基礎評分分數
|
2063 |
+
這個函數使用了改進後的評分邏輯:
|
|
|
2064 |
1. 降低關鍵指標的最低門檻,使系統更包容
|
2065 |
2. 引入非線性評分曲線,讓分數分布更合理
|
2066 |
3. 優化多重條件失敗的處理方式
|
|
|
2280 |
|
2281 |
|
2282 |
def amplify_score_extreme(score: float) -> float:
|
2283 |
+
"""
|
|
|
|
|
|
|
2284 |
Parameters:
|
2285 |
score: 原始評分(0-1之間的浮點數)
|
2286 |
|