DawnC commited on
Commit
a88748a
1 Parent(s): 987ecd1

Update scoring_calculation_system.py

Browse files
Files changed (1) hide show
  1. 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.15, # 降低起始分,高難度品種對新手幾乎不推薦
917
- "intermediate": 0.65, # 中級玩家仍需謹慎
918
- "advanced": 1.0 # 資深者能完全勝任
919
  },
920
  "Moderate": {
921
- "beginner": 0.40, # 適中難度對新手仍具挑戰
922
- "intermediate": 0.85, # 中級玩家較適合
923
- "advanced": 0.95 # 資深者完全勝任
924
  },
925
  "Low": {
926
- "beginner": 0.85, # 新手友善品種
927
  "intermediate": 0.90, # 中級玩家幾乎完全勝任
928
- "advanced": 0.85 # 資深者完全勝任
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.30, # 固執性格嚴重影響新手
943
- 'independent': -0.25, # 獨立性高的品種不適合新手
944
- 'dominant': -0.25, # 支配性強的品種需要經驗處理
945
- 'strong-willed': -0.20, # 強勢性格需要技巧管理
946
- 'protective': -0.20, # 保護性強需要適當訓練
947
- 'aloof': -0.15, # 冷漠性格需要耐心培養
948
- 'energetic': -0.15, # 活潑好動需要經驗引導
949
- 'aggressive': -0.35 # 攻擊傾向極不適合新手
950
  }
951
 
952
- # 新手友善的特徵 - 適度的獎勵
953
  easy_traits = {
954
- 'gentle': 0.05, # 溫和性格適合新手
955
- 'friendly': 0.05, # 友善性格容易相處
956
- 'eager to please': 0.08, # 願意服從較容易訓練
957
- 'patient': 0.05, # 耐心的特質有助於建立關係
958
- 'adaptable': 0.05, # 適應性強較容易照顧
959
- 'calm': 0.06 # 冷靜的性格較好掌握
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.20 # 梗類犬種通常不適合新手
974
  elif 'working' in temperament_lower:
975
- temperament_adjustments -= 0.25 # 工作犬需要經驗豐富的主人
976
  elif 'guard' in temperament_lower:
977
- temperament_adjustments -= 0.25 # 護衛犬需要專業訓練
978
 
 
979
  elif user_experience == "intermediate":
980
- # 中級玩家的特徵評估
981
  moderate_traits = {
982
- 'stubborn': -0.15, # 仍然需要注意,但懲罰較輕
983
- 'independent': -0.10,
984
- 'intelligent': 0.08, # 聰明的特質可以好好發揮
985
- 'athletic': 0.06, # 運動能力可以適當訓練
986
- 'versatile': 0.07, # 多功能性可以開發
987
- 'protective': -0.08 # 保護性仍需注意
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.05, min(1.0, score + temperament_adjustments))
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()