DawnC commited on
Commit
b9f7c90
โ€ข
1 Parent(s): 11269b9

Update scoring_calculation_system.py

Browse files
Files changed (1) hide show
  1. scoring_calculation_system.py +26 -57
scoring_calculation_system.py CHANGED
@@ -553,77 +553,46 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
553
  # return max(0.3, 0.8 * (user_time / breed_need['min']))
554
 
555
 
556
- def calculate_exercise_score(breed_needs: str, user_prefs: UserPreferences) -> float:
557
  """
558
  ๅ„ชๅŒ–็š„้‹ๅ‹•้œ€ๆฑ‚่ฉ•ๅˆ†็ณป็ตฑ
559
 
 
 
 
 
560
  ๆ”น้€ฒ๏ผš
561
- 1. ่€ƒๆ…ฎ้‹ๅ‹•้กžๅž‹็š„ๅŒน้…ๅบฆ
562
- 2. ่ฉ•ไผฐๆดปๅ‹•ๆจกๅผ็š„้ฉ้…ๆ€ง
563
- 3. ๅŠ ๅ…ฅๅ“็จฎ็‰นๆ€ง่€ƒ้‡
564
  """
565
  # ๅŸบ็คŽ้‹ๅ‹•้œ€ๆฑ‚่ฉ•ไผฐ
566
  exercise_needs = {
567
- 'VERY HIGH': {'min': 120, 'ideal': 150, 'max': 180, 'intensity': 'high'},
568
- 'HIGH': {'min': 90, 'ideal': 120, 'max': 150, 'intensity': 'moderate_high'},
569
- 'MODERATE': {'min': 45, 'ideal': 60, 'max': 90, 'intensity': 'moderate'},
570
- 'LOW': {'min': 20, 'ideal': 30, 'max': 45, 'intensity': 'low'},
571
- 'VARIES': {'min': 30, 'ideal': 60, 'max': 90, 'intensity': 'moderate'}
572
  }
573
 
574
  breed_need = exercise_needs.get(breed_needs.strip().upper(), exercise_needs['MODERATE'])
575
 
576
  # ๅŸบ็คŽๆ™‚้–“ๅŒน้…ๅบฆ่จˆ็ฎ—
577
- if user_prefs.exercise_time >= breed_need['ideal']:
578
- time_score = 1.0 if user_prefs.exercise_time <= breed_need['max'] else 0.9
579
- elif user_prefs.exercise_time >= breed_need['min']:
580
- time_score = 0.7 + (user_prefs.exercise_time - breed_need['min']) / (breed_need['ideal'] - breed_need['min']) * 0.3
581
- else:
582
- time_score = max(0.3, 0.7 * (user_prefs.exercise_time / breed_need['min']))
583
-
584
- # ้‹ๅ‹•้กžๅž‹ๅŒน้…ๅบฆ่ฉ•ไผฐ
585
- exercise_type_scores = {
586
- 'light_walks': {
587
- 'low': 1.0,
588
- 'moderate': 0.8,
589
- 'moderate_high': 0.5,
590
- 'high': 0.3
591
- },
592
- 'moderate_activity': {
593
- 'low': 0.7,
594
- 'moderate': 1.0,
595
- 'moderate_high': 0.8,
596
- 'high': 0.6
597
- },
598
- 'active_training': {
599
- 'low': 0.5,
600
- 'moderate': 0.8,
601
- 'moderate_high': 1.0,
602
- 'high': 1.0
603
- }
604
- }
605
-
606
- type_score = exercise_type_scores.get(user_prefs.exercise_type, exercise_type_scores['moderate_activity']).get(breed_need['intensity'], 0.7)
607
-
608
- # ๆ™‚้–“ๅฏ็”จๆ€ง่ชฟๆ•ด
609
- availability_multiplier = {
610
- 'limited': 0.85, # ๆ™‚้–“ๆœ‰้™๏ผŒๅฏ่ƒฝๅฝฑ้Ÿฟ้‹ๅ‹•ๅ“่ณช
611
- 'moderate': 1.0, # ๆจ™ๆบ–ๅƒ่€ƒ้ปž
612
- 'flexible': 1.1 # ๆ›ด้ˆๆดป็š„ๆ™‚้–“ๅฎ‰ๆŽ’ๆœ‰ๅˆฉๆ–ผๆปฟ่ถณ็‹—็‹—้œ€ๆฑ‚
613
- }.get(user_prefs.time_availability, 1.0)
614
-
615
- # ็’ฐๅขƒๅ› ็ด ่€ƒ้‡
616
- environment_bonus = 0
617
- if user_prefs.yard_access != 'no_yard':
618
- if breed_needs.strip().upper() in ['VERY HIGH', 'HIGH']:
619
- environment_bonus = 0.1
620
  else:
621
- environment_bonus = 0.05
622
-
623
- # ่จˆ็ฎ—ๆœ€็ต‚ๅˆ†ๆ•ธ
624
- final_score = (time_score * 0.5 + type_score * 0.3) * availability_multiplier + environment_bonus
 
 
 
625
 
626
- return min(1.0, max(0.3, final_score))
 
627
 
628
 
629
  def calculate_grooming_score(breed_needs: str, user_commitment: str, breed_size: str) -> float:
 
553
  # return max(0.3, 0.8 * (user_time / breed_need['min']))
554
 
555
 
556
+ def calculate_exercise_score(breed_needs: str, exercise_time: int) -> float:
557
  """
558
  ๅ„ชๅŒ–็š„้‹ๅ‹•้œ€ๆฑ‚่ฉ•ๅˆ†็ณป็ตฑ
559
 
560
+ Parameters:
561
+ breed_needs: str - ๅ“็จฎ็š„้‹ๅ‹•้œ€ๆฑ‚็ญ‰็ดš
562
+ exercise_time: int - ไฝฟ็”จ่€…ๅฏๆไพ›็š„้‹ๅ‹•ๆ™‚้–“๏ผˆๅˆ†้˜๏ผ‰
563
+
564
  ๆ”น้€ฒ๏ผš
565
+ 1. ๆ›ด็ดฐ็ทป็š„้‹ๅ‹•้œ€ๆฑ‚่ฉ•ไผฐ
566
+ 2. ๆ›ดๅˆ็†็š„ๆ™‚้–“ๅŒน้…่จˆ็ฎ—
567
+ 3. ้ฟๅ…ๆฅต็ซฏ่ฉ•ๅˆ†
568
  """
569
  # ๅŸบ็คŽ้‹ๅ‹•้œ€ๆฑ‚่ฉ•ไผฐ
570
  exercise_needs = {
571
+ 'VERY HIGH': {'min': 120, 'ideal': 150, 'max': 180},
572
+ 'HIGH': {'min': 90, 'ideal': 120, 'max': 150},
573
+ 'MODERATE': {'min': 45, 'ideal': 60, 'max': 90},
574
+ 'LOW': {'min': 20, 'ideal': 30, 'max': 45},
575
+ 'VARIES': {'min': 30, 'ideal': 60, 'max': 90}
576
  }
577
 
578
  breed_need = exercise_needs.get(breed_needs.strip().upper(), exercise_needs['MODERATE'])
579
 
580
  # ๅŸบ็คŽๆ™‚้–“ๅŒน้…ๅบฆ่จˆ็ฎ—
581
+ if exercise_time >= breed_need['ideal']:
582
+ if exercise_time > breed_need['max']:
583
+ # ้‹ๅ‹•ๆ™‚้–“้Ž้•ท๏ผŒ็จๅพฎ้™ไฝŽๅˆ†ๆ•ธ
584
+ time_score = 0.9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
585
  else:
586
+ time_score = 1.0
587
+ elif exercise_time >= breed_need['min']:
588
+ # ๅœจๆœ€ๅฐ้œ€ๆฑ‚ๅ’Œ็†ๆƒณ้œ€ๆฑ‚ไน‹้–“๏ผŒ็ทšๆ€ง่จˆ็ฎ—ๅˆ†ๆ•ธ
589
+ time_score = 0.7 + (exercise_time - breed_need['min']) / (breed_need['ideal'] - breed_need['min']) * 0.3
590
+ else:
591
+ # ้‹ๅ‹•ๆ™‚้–“ไธ่ถณ๏ผŒไฝ†ไปๆ นๆ“šๆฏ”ไพ‹็ตฆไบˆๅˆ†ๆ•ธ
592
+ time_score = max(0.3, 0.7 * (exercise_time / breed_need['min']))
593
 
594
+ # ็ขบไฟๅˆ†ๆ•ธๅœจๅˆ็†็ฏ„ๅœๅ…ง
595
+ return min(1.0, max(0.3, time_score))
596
 
597
 
598
  def calculate_grooming_score(breed_needs: str, user_commitment: str, breed_size: str) -> float: