(
paper: Dict[str, Any],
user_profile: Dict[str, Any],
combined_text: str,
parsed_pdf: Optional[Dict[str, Any]],
response_language: str = "zh",
)
| 3526 | |
| 3527 | |
| 3528 | def _build_relevance_points( |
| 3529 | paper: Dict[str, Any], |
| 3530 | user_profile: Dict[str, Any], |
| 3531 | combined_text: str, |
| 3532 | parsed_pdf: Optional[Dict[str, Any]], |
| 3533 | response_language: str = "zh", |
| 3534 | ) -> List[str]: |
| 3535 | is_en = _normalize_response_language(response_language) == "en" |
| 3536 | text_lower = combined_text.lower() |
| 3537 | points: List[str] = [] |
| 3538 | |
| 3539 | core_directions = user_profile.get("core_directions", {}) or {} |
| 3540 | sorted_directions = sorted(core_directions.items(), key=lambda item: float(item[1]), reverse=True) |
| 3541 | |
| 3542 | matched: List[str] = [] |
| 3543 | for direction, weight in sorted_directions[:3]: |
| 3544 | tokens = str(direction).lower().replace("-", " ").replace("_", " ").split() |
| 3545 | if str(direction).lower() in text_lower or any(token in text_lower for token in tokens if len(token) >= 4): |
| 3546 | if is_en: |
| 3547 | matched.append(f"{_format_direction_label(direction, response_language)} (weight {float(weight):.2f})") |
| 3548 | else: |
| 3549 | matched.append(f"{_format_direction_label(direction)}(权重 {float(weight):.2f})") |
| 3550 | |
| 3551 | if matched: |
| 3552 | points.append( |
| 3553 | f"This paper directly overlaps with the current profile directions: {', '.join(matched)}." |
| 3554 | if is_en |
| 3555 | else f"这篇论文和你当前画像里的方向有直接重合:{', '.join(matched)}。" |
| 3556 | ) |
| 3557 | elif sorted_directions: |
| 3558 | direction_label = _format_direction_label(sorted_directions[0][0], response_language) |
| 3559 | points.append( |
| 3560 | f"It may not exactly match the current core direction, {direction_label}, but its method design and evaluation structure are worth inspecting." |
| 3561 | if is_en |
| 3562 | else f"它不一定和你当前最核心的 {direction_label} 完全同题,但方法设计和评测组织值得借鉴。" |
| 3563 | ) |
| 3564 | else: |
| 3565 | points.append( |
| 3566 | "The current profile is still learning; this paper can act as a new interest anchor for deciding whether to keep tracking the topic." |
| 3567 | if is_en |
| 3568 | else "你当前画像还在持续学习阶段,这篇论文适合作为新的兴趣锚点来判断后续是否继续追踪。" |
| 3569 | ) |
| 3570 | |
| 3571 | preferences = user_profile.get("methodology_preferences", {}) or {} |
| 3572 | if preferences.get("preference_data_driven_over_theory"): |
| 3573 | points.append( |
| 3574 | "Methodologically, it leans toward a data-driven or empirically validated path, which matches the current profile preference." |
| 3575 | if is_en |
| 3576 | else "从方法论上看,它偏向数据驱动或实验验证路径,和你当前偏好比较一致。" |
| 3577 | ) |
| 3578 | if preferences.get("preference_systematic_work_over_incremental"): |
| 3579 | points.append( |
| 3580 | "If the profile favors systematic work, focus on how the paper organizes the task setup, experiment protocol, and overall framework." |
| 3581 | if is_en |
| 3582 | else "如果你更看重系统性工作,可以重点看它如何组织任务设定、实验协议和整体框架。" |
| 3583 | ) |
| 3584 | if preferences.get("preference_bio_science_application"): |
| 3585 | points.append( |
no test coverage detected