DawnC commited on
Commit
ef1f36e
1 Parent(s): b80fce6

Update scoring_calculation_system.py

Browse files
Files changed (1) hide show
  1. scoring_calculation_system.py +62 -0
scoring_calculation_system.py CHANGED
@@ -294,8 +294,56 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
294
 
295
  return base_score
296
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  def calculate_experience_score(care_level: str, user_experience: str, temperament: str) -> float:
298
  """飼養經驗需求計算"""
 
 
 
299
  # 降低初學者的基礎分數
300
  base_scores = {
301
  "High": {"beginner": 0.15, "intermediate": 0.70, "advanced": 1.0},
@@ -336,6 +384,20 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
336
  if "terrier" in breed_info['Description'].lower():
337
  temperament_adjustments -= 0.1 # 梗類犬對新手不友善
338
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  final_score = max(0.2, min(1.0, score + temperament_adjustments))
340
  return final_score
341
 
 
294
 
295
  return base_score
296
 
297
+ # def calculate_experience_score(care_level: str, user_experience: str, temperament: str) -> float:
298
+ # """飼養經驗需求計算"""
299
+ # # 降低初學者的基礎分數
300
+ # base_scores = {
301
+ # "High": {"beginner": 0.15, "intermediate": 0.70, "advanced": 1.0},
302
+ # "Moderate": {"beginner": 0.40, "intermediate": 0.85, "advanced": 1.0},
303
+ # "Low": {"beginner": 0.75, "intermediate": 0.95, "advanced": 1.0}
304
+ # }
305
+
306
+ # score = base_scores.get(care_level, base_scores["Moderate"])[user_experience]
307
+
308
+ # # 擴展性格特徵評估
309
+ # temperament_lower = temperament.lower()
310
+
311
+ # if user_experience == "beginner":
312
+ # # 增加更多特徵評估
313
+ # difficult_traits = {
314
+ # 'stubborn': -0.12,
315
+ # 'independent': -0.10,
316
+ # 'dominant': -0.10,
317
+ # 'strong-willed': -0.08,
318
+ # 'protective': -0.06,
319
+ # 'energetic': -0.05
320
+ # }
321
+
322
+ # easy_traits = {
323
+ # 'gentle': 0.06,
324
+ # 'friendly': 0.06,
325
+ # 'eager to please': 0.06,
326
+ # 'patient': 0.05,
327
+ # 'adaptable': 0.05,
328
+ # 'calm': 0.04
329
+ # }
330
+
331
+ # # 更精確的特徵影響計算
332
+ # temperament_adjustments = sum(value for trait, value in easy_traits.items() if trait in temperament_lower)
333
+ # temperament_adjustments += sum(value for trait, value in difficult_traits.items() if trait in temperament_lower)
334
+
335
+ # # 品種特定調整
336
+ # if "terrier" in breed_info['Description'].lower():
337
+ # temperament_adjustments -= 0.1 # 梗類犬對新手不友善
338
+
339
+ # final_score = max(0.2, min(1.0, score + temperament_adjustments))
340
+ # return final_score
341
+
342
  def calculate_experience_score(care_level: str, user_experience: str, temperament: str) -> float:
343
  """飼養經驗需求計算"""
344
+ # 初始化 temperament_adjustments,確保所有路徑都有值
345
+ temperament_adjustments = 0.0
346
+
347
  # 降低初學者的基礎分數
348
  base_scores = {
349
  "High": {"beginner": 0.15, "intermediate": 0.70, "advanced": 1.0},
 
384
  if "terrier" in breed_info['Description'].lower():
385
  temperament_adjustments -= 0.1 # 梗類犬對新手不友善
386
 
387
+ elif user_experience == "intermediate":
388
+ # 中級飼主的調整較溫和
389
+ if any(trait in temperament_lower for trait in ['gentle', 'friendly', 'patient']):
390
+ temperament_adjustments += 0.03
391
+ if any(trait in temperament_lower for trait in ['stubborn', 'independent']):
392
+ temperament_adjustments -= 0.02
393
+
394
+ else: # advanced
395
+ # 資深飼主能處理更具挑戰性的犬種
396
+ if any(trait in temperament_lower for trait in ['stubborn', 'independent', 'dominant']):
397
+ temperament_adjustments += 0.02 # 反而可能是優點
398
+ if any(trait in temperament_lower for trait in ['protective', 'energetic']):
399
+ temperament_adjustments += 0.03
400
+
401
  final_score = max(0.2, min(1.0, score + temperament_adjustments))
402
  return final_score
403