Render a short ranking explanation based on drift state.
(profile: Dict)
| 1572 | |
| 1573 | |
| 1574 | def format_drift_hint(profile: Dict) -> str: |
| 1575 | """Render a short ranking explanation based on drift state.""" |
| 1576 | drift_state = (profile or {}).get("drift_state", {}) or {} |
| 1577 | status = drift_state.get("status", "stable") |
| 1578 | if drift_state.get("anchor_topic"): |
| 1579 | anchor_label = format_direction_label(drift_state.get("anchor_topic")) |
| 1580 | progress = float(drift_state.get("anchor_progress", 0.0) or 0.0) |
| 1581 | if int(drift_state.get("commitment_days_remaining", 0) or 0) > 0: |
| 1582 | return f"兴趣迁移状态:已锁定锚点 {anchor_label},当前正在持续推进(progress={progress:.2f})。" |
| 1583 | return f"兴趣迁移状态:已形成稳定迁移方向,当前锚点为 {anchor_label}(progress={progress:.2f})。" |
| 1584 | if drift_state.get("hidden_anchor") and drift_state.get("drift_enabled"): |
| 1585 | anchor_label = format_direction_label(drift_state.get("hidden_anchor")) |
| 1586 | return f"兴趣迁移状态:观察期,系统正在跟踪你是否持续转向 {anchor_label}。" |
| 1587 | if status == "shifting": |
| 1588 | topics = [format_direction_label(topic) for topic in (drift_state.get("top_shift_topics", []) or [])[:3]] |
| 1589 | if topics: |
| 1590 | return f"兴趣迁移状态:迁移中,近期偏好权重已提升,当前重点关注 {', '.join(topics)}。" |
| 1591 | return "兴趣迁移状态:迁移中,近期偏好权重已提升。" |
| 1592 | if status == "recovered": |
| 1593 | topics = [format_direction_label(topic) for topic in (drift_state.get("top_shift_topics", []) or [])[:3]] |
| 1594 | if topics: |
| 1595 | return f"兴趣迁移状态:已恢复,系统正在重新平衡短期与长期兴趣,近期变化主要围绕 {', '.join(topics)}。" |
| 1596 | return "兴趣迁移状态:已恢复,系统正在重新平衡短期与长期兴趣。" |
| 1597 | return "兴趣迁移状态:稳定,长期画像权重占优。" |
| 1598 | |
| 1599 | |
| 1600 | def format_reading_signal_hint(profile: Dict) -> str: |
no test coverage detected