Spaces:
Running
on
Zero
Running
on
Zero
Update scoring_calculation_system.py
Browse files- scoring_calculation_system.py +45 -47
scoring_calculation_system.py
CHANGED
@@ -903,60 +903,59 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
903 |
|
904 |
def calculate_experience_score(care_level: str, user_experience: str, temperament: str) -> float:
|
905 |
"""
|
906 |
-
|
907 |
|
908 |
-
|
909 |
-
1.
|
910 |
-
2.
|
911 |
-
3.
|
912 |
"""
|
913 |
-
# 基礎分數矩陣 -
|
914 |
base_scores = {
|
915 |
"High": {
|
916 |
-
"beginner": 0.
|
917 |
-
"intermediate": 0.
|
918 |
-
"advanced":
|
919 |
},
|
920 |
"Moderate": {
|
921 |
-
"beginner": 0.
|
922 |
-
"intermediate": 0.85, #
|
923 |
-
"advanced": 0.
|
924 |
},
|
925 |
"Low": {
|
926 |
-
"beginner": 0.85, #
|
927 |
"intermediate": 0.90, # 中級玩家幾乎完全勝任
|
928 |
-
"advanced": 0.
|
929 |
}
|
930 |
}
|
931 |
|
932 |
# 取得基礎分數
|
933 |
score = base_scores.get(care_level, base_scores["Moderate"])[user_experience]
|
934 |
|
|
|
935 |
temperament_lower = temperament.lower()
|
936 |
temperament_adjustments = 0.0
|
937 |
|
938 |
-
#
|
939 |
if user_experience == "beginner":
|
940 |
-
# 新手不適合的特徵 - 更嚴格的懲罰
|
941 |
difficult_traits = {
|
942 |
-
'stubborn': -0.
|
943 |
-
'independent': -0.
|
944 |
-
'dominant': -0.
|
945 |
-
'strong-willed': -0.
|
946 |
-
'protective': -0.
|
947 |
-
'aloof': -0.
|
948 |
-
'energetic': -0.
|
949 |
-
'aggressive': -0.
|
950 |
}
|
951 |
|
952 |
-
# 新手友善的特徵 - 適度的獎勵
|
953 |
easy_traits = {
|
954 |
-
'gentle': 0.
|
955 |
-
'friendly': 0.
|
956 |
-
'eager to please': 0.
|
957 |
-
'patient': 0.
|
958 |
-
'adaptable': 0.
|
959 |
-
'calm': 0.
|
960 |
}
|
961 |
|
962 |
# 計算特徵調整
|
@@ -968,23 +967,23 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
968 |
if trait in temperament_lower:
|
969 |
temperament_adjustments += bonus
|
970 |
|
971 |
-
#
|
972 |
if 'terrier' in temperament_lower:
|
973 |
-
temperament_adjustments -= 0.
|
974 |
elif 'working' in temperament_lower:
|
975 |
-
temperament_adjustments -= 0.
|
976 |
elif 'guard' in temperament_lower:
|
977 |
-
temperament_adjustments -= 0.
|
978 |
|
|
|
979 |
elif user_experience == "intermediate":
|
980 |
-
# 中級玩家的特徵評估
|
981 |
moderate_traits = {
|
982 |
-
'stubborn': -0.
|
983 |
-
'independent': -0.
|
984 |
-
'intelligent': 0.
|
985 |
-
'athletic': 0.
|
986 |
-
'versatile': 0.
|
987 |
-
'protective': -0.
|
988 |
}
|
989 |
|
990 |
for trait, adjustment in moderate_traits.items():
|
@@ -992,9 +991,8 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
992 |
temperament_adjustments += adjustment
|
993 |
|
994 |
else: # advanced
|
995 |
-
# 資深玩家能夠應對挑戰性特徵
|
996 |
advanced_traits = {
|
997 |
-
'stubborn': 0.05,
|
998 |
'independent': 0.05,
|
999 |
'intelligent': 0.10,
|
1000 |
'protective': 0.05,
|
@@ -1005,8 +1003,8 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
|
|
1005 |
if trait in temperament_lower:
|
1006 |
temperament_adjustments += bonus
|
1007 |
|
1008 |
-
#
|
1009 |
-
final_score = max(0.
|
1010 |
|
1011 |
return final_score
|
1012 |
|
@@ -1623,7 +1621,7 @@ def calculate_breed_compatibility_score(scores: dict, user_prefs: UserPreference
|
|
1623 |
|
1624 |
return space_score
|
1625 |
|
1626 |
-
#
|
1627 |
def evaluate_breed_traits():
|
1628 |
temperament = breed_info.get('Temperament', '').lower()
|
1629 |
description = breed_info.get('Description', '').lower()
|
|
|
903 |
|
904 |
def calculate_experience_score(care_level: str, user_experience: str, temperament: str) -> float:
|
905 |
"""
|
906 |
+
計算使用者經驗與品種需求的匹配分數,更平衡的經驗等級影響
|
907 |
|
908 |
+
改進重點:
|
909 |
+
1. 提高初學者的基礎分數
|
910 |
+
2. 縮小經驗等級間的差距
|
911 |
+
3. 保持適度的區分度
|
912 |
"""
|
913 |
+
# 基礎分數矩陣 - 更合理的分數分配
|
914 |
base_scores = {
|
915 |
"High": {
|
916 |
+
"beginner": 0.55, # 提高起始分,讓新手也有機會
|
917 |
+
"intermediate": 0.80, # 中級玩家有不錯的勝任能力
|
918 |
+
"advanced": 0.95 # 資深者幾乎完全勝任
|
919 |
},
|
920 |
"Moderate": {
|
921 |
+
"beginner": 0.65, # 適中難度對新手更友善
|
922 |
+
"intermediate": 0.85, # 中級玩家相當適合
|
923 |
+
"advanced": 0.90 # 資深者完全勝任
|
924 |
},
|
925 |
"Low": {
|
926 |
+
"beginner": 0.85, # 新手友善品種維持高分
|
927 |
"intermediate": 0.90, # 中級玩家幾乎完全勝任
|
928 |
+
"advanced": 0.90 # 資深者完全勝任
|
929 |
}
|
930 |
}
|
931 |
|
932 |
# 取得基礎分數
|
933 |
score = base_scores.get(care_level, base_scores["Moderate"])[user_experience]
|
934 |
|
935 |
+
# 性格評估的權重也需要調整
|
936 |
temperament_lower = temperament.lower()
|
937 |
temperament_adjustments = 0.0
|
938 |
|
939 |
+
# 根據經驗等級設定不同的特徵評估標準,降低懲罰程度
|
940 |
if user_experience == "beginner":
|
|
|
941 |
difficult_traits = {
|
942 |
+
'stubborn': -0.15, # 降低懲罰程度
|
943 |
+
'independent': -0.12,
|
944 |
+
'dominant': -0.12,
|
945 |
+
'strong-willed': -0.10,
|
946 |
+
'protective': -0.10,
|
947 |
+
'aloof': -0.08,
|
948 |
+
'energetic': -0.08,
|
949 |
+
'aggressive': -0.20 # 保持較高懲罰,因為安全考慮
|
950 |
}
|
951 |
|
|
|
952 |
easy_traits = {
|
953 |
+
'gentle': 0.08, # 提高獎勵以平衡
|
954 |
+
'friendly': 0.08,
|
955 |
+
'eager to please': 0.10,
|
956 |
+
'patient': 0.08,
|
957 |
+
'adaptable': 0.08,
|
958 |
+
'calm': 0.08
|
959 |
}
|
960 |
|
961 |
# 計算特徵調整
|
|
|
967 |
if trait in temperament_lower:
|
968 |
temperament_adjustments += bonus
|
969 |
|
970 |
+
# 品種類型特殊評估,降低懲罰程度
|
971 |
if 'terrier' in temperament_lower:
|
972 |
+
temperament_adjustments -= 0.10 # 降低懲罰
|
973 |
elif 'working' in temperament_lower:
|
974 |
+
temperament_adjustments -= 0.12
|
975 |
elif 'guard' in temperament_lower:
|
976 |
+
temperament_adjustments -= 0.12
|
977 |
|
978 |
+
# 中級和高級玩家的調整保持不變...
|
979 |
elif user_experience == "intermediate":
|
|
|
980 |
moderate_traits = {
|
981 |
+
'stubborn': -0.08,
|
982 |
+
'independent': -0.05,
|
983 |
+
'intelligent': 0.10,
|
984 |
+
'athletic': 0.08,
|
985 |
+
'versatile': 0.08,
|
986 |
+
'protective': -0.05
|
987 |
}
|
988 |
|
989 |
for trait, adjustment in moderate_traits.items():
|
|
|
991 |
temperament_adjustments += adjustment
|
992 |
|
993 |
else: # advanced
|
|
|
994 |
advanced_traits = {
|
995 |
+
'stubborn': 0.05,
|
996 |
'independent': 0.05,
|
997 |
'intelligent': 0.10,
|
998 |
'protective': 0.05,
|
|
|
1003 |
if trait in temperament_lower:
|
1004 |
temperament_adjustments += bonus
|
1005 |
|
1006 |
+
# 確保最終分數範圍合理
|
1007 |
+
final_score = max(0.15, min(1.0, score + temperament_adjustments))
|
1008 |
|
1009 |
return final_score
|
1010 |
|
|
|
1621 |
|
1622 |
return space_score
|
1623 |
|
1624 |
+
# 第四部分:品種特性評估
|
1625 |
def evaluate_breed_traits():
|
1626 |
temperament = breed_info.get('Temperament', '').lower()
|
1627 |
description = breed_info.get('Description', '').lower()
|