鍏抽敭璇嶆紓绉伙細娣诲姞鏂板叴鎶€鏈叧閿瘝鍒板繀璇绘竻鍗?
(
profile: Dict[str, Any],
params: Dict[str, Any],
selected_papers: Optional[List[Dict]] = None,
date: Optional[str] = None,
)
| 1043 | |
| 1044 | def keyword_emergence( |
| 1045 | profile: Dict[str, Any], |
| 1046 | params: Dict[str, Any], |
| 1047 | selected_papers: Optional[List[Dict]] = None, |
| 1048 | date: Optional[str] = None, |
| 1049 | ) -> Tuple[Dict[str, Any], Dict[str, Any]]: |
| 1050 | """ |
| 1051 | 鍏抽敭璇嶆紓绉伙細娣诲姞鏂板叴鎶€鏈叧閿瘝鍒板繀璇绘竻鍗? """ |
| 1052 | updated = copy.deepcopy(profile) |
| 1053 | must_read = updated.get("must_read", {}) |
| 1054 | |
| 1055 | old_keywords = list(must_read.get("keywords", [])) |
| 1056 | new_keywords_pool = params.get("new_keywords_pool", []) |
| 1057 | add_count = params.get("add_count", 2) |
| 1058 | |
| 1059 | # 杩囨护鎺夊凡鏈夌殑鍏抽敭璇? |
| 1060 | available_keywords = [k for k in new_keywords_pool if k not in old_keywords] |
| 1061 | |
| 1062 | # 闅忔満閫夋嫨鏂板叧閿瘝 |
| 1063 | new_keywords = random.sample(available_keywords, min(add_count, len(available_keywords))) |
| 1064 | |
| 1065 | must_read["keywords"] = old_keywords + new_keywords |
| 1066 | updated["must_read"] = must_read |
| 1067 | |
| 1068 | # 鏇存柊 drift_state |
| 1069 | updated["drift_state"] = _update_drift_state(profile, date, score_delta=0.2) |
| 1070 | |
| 1071 | drift_event = { |
| 1072 | "method": "keyword_emergence", |
| 1073 | "keywords_before": old_keywords, |
| 1074 | "keywords_added": new_keywords, |
| 1075 | "keywords_after": list(must_read["keywords"]), |
| 1076 | } |
| 1077 | |
| 1078 | return updated, drift_event |
| 1079 | |
| 1080 | |
| 1081 | def direction_add( |
| 1082 | profile: Dict[str, Any], |
nothing calls this directly
no test coverage detected