DawnC commited on
Commit
640abcf
1 Parent(s): a5086e9

Update scoring_calculation_system.py

Browse files
Files changed (1) hide show
  1. scoring_calculation_system.py +12 -12
scoring_calculation_system.py CHANGED
@@ -486,7 +486,7 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
486
  },
487
  "Medium": {
488
  "apartment": {
489
- "no_yard": 0.35, # 中型犬在公寓較受限
490
  "shared_yard": 0.45,
491
  "private_yard": 0.55
492
  },
@@ -503,9 +503,9 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
503
  },
504
  "Large": {
505
  "apartment": {
506
- "no_yard": 0.35,
507
- "shared_yard": 0.45,
508
- "private_yard": 0.55
509
  },
510
  "house_small": {
511
  "no_yard": 0.55,
@@ -520,9 +520,9 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
520
  },
521
  "Giant": {
522
  "apartment": {
523
- "no_yard": 0.15, # 巨型犬在公寓基本不適合
524
- "shared_yard": 0.25,
525
- "private_yard": 0.35
526
  },
527
  "house_small": {
528
  "no_yard": 0.40,
@@ -605,10 +605,10 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
605
  def apply_extreme_case_adjustments(score):
606
  # 處理極端情況
607
  if size == "Giant" and living_space == "apartment":
608
- return score * 0.75 # 巨型犬在公寓給予較低分數
609
 
610
  if size == "Large" and living_space == "apartment" and exercise_needs == "Very High":
611
- return score * 0.85 # 高運動需求的大型犬在公寓更不適合
612
 
613
  if size == "Small" and living_space == "house_large" and exercise_needs == "Low":
614
  return score * 0.9 # 低運動需求的小型犬在大房子可能過於寬敞
@@ -727,9 +727,9 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
727
  def calculate_time_score():
728
  if exercise_time >= breed_level['ideal']:
729
  if exercise_time > breed_level['max']:
730
- # 超出最大值的懲罰更明顯
731
- excess = (exercise_time - breed_level['max']) / 30
732
- return max(0.4, 1.0 - (excess * 0.2))
733
  return 1.0 # 理想範圍內給予滿分
734
  elif exercise_time >= breed_level['min']:
735
  # 在最小值和理想值之間使用更陡峭的曲線
 
486
  },
487
  "Medium": {
488
  "apartment": {
489
+ "no_yard": 0.35,
490
  "shared_yard": 0.45,
491
  "private_yard": 0.55
492
  },
 
503
  },
504
  "Large": {
505
  "apartment": {
506
+ "no_yard": 0.45,
507
+ "shared_yard": 0.55,
508
+ "private_yard": 0.65
509
  },
510
  "house_small": {
511
  "no_yard": 0.55,
 
520
  },
521
  "Giant": {
522
  "apartment": {
523
+ "no_yard": 0.40,
524
+ "shared_yard": 0.50,
525
+ "private_yard": 0.60
526
  },
527
  "house_small": {
528
  "no_yard": 0.40,
 
605
  def apply_extreme_case_adjustments(score):
606
  # 處理極端情況
607
  if size == "Giant" and living_space == "apartment":
608
+ return score * 0.85
609
 
610
  if size == "Large" and living_space == "apartment" and exercise_needs == "Very High":
611
+ return score * 0.85
612
 
613
  if size == "Small" and living_space == "house_large" and exercise_needs == "Low":
614
  return score * 0.9 # 低運動需求的小型犬在大房子可能過於寬敞
 
727
  def calculate_time_score():
728
  if exercise_time >= breed_level['ideal']:
729
  if exercise_time > breed_level['max']:
730
+ excess = (exercise_time - breed_level['max']) / breed_level['max']
731
+ bonus = min(0.15, excess * 0.3)
732
+ return min(1.0, 1.0 + bonus)
733
  return 1.0 # 理想範圍內給予滿分
734
  elif exercise_time >= breed_level['min']:
735
  # 在最小值和理想值之間使用更陡峭的曲線