Spaces:
Running
on
Zero
Running
on
Zero
Update scoring_calculation_system.py
Browse files- 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,
|
557 |
"""
|
558 |
ๅชๅ็้ๅ้ๆฑ่ฉๅ็ณป็ตฑ
|
559 |
|
|
|
|
|
|
|
|
|
560 |
ๆน้ฒ๏ผ
|
561 |
-
1.
|
562 |
-
2.
|
563 |
-
3.
|
564 |
"""
|
565 |
# ๅบ็ค้ๅ้ๆฑ่ฉไผฐ
|
566 |
exercise_needs = {
|
567 |
-
'VERY HIGH': {'min': 120, 'ideal': 150, 'max': 180
|
568 |
-
'HIGH': {'min': 90, 'ideal': 120, 'max': 150
|
569 |
-
'MODERATE': {'min': 45, 'ideal': 60, 'max': 90
|
570 |
-
'LOW': {'min': 20, 'ideal': 30, 'max': 45
|
571 |
-
'VARIES': {'min': 30, 'ideal': 60, 'max': 90
|
572 |
}
|
573 |
|
574 |
breed_need = exercise_needs.get(breed_needs.strip().upper(), exercise_needs['MODERATE'])
|
575 |
|
576 |
# ๅบ็คๆ้ๅน้
ๅบฆ่จ็ฎ
|
577 |
-
if
|
578 |
-
|
579 |
-
|
580 |
-
|
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 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
|
|
|
|
|
|
625 |
|
626 |
-
|
|
|
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:
|