MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / DriftEngine

Class DriftEngine

scripts/drift_engine.py:1290–1375  ·  view source on GitHub ↗

鍏磋叮婕傜Щ鎵ц寮曟搸

Source from the content-addressed store, hash-verified

1288
1289class DriftEngine:
1290 """鍏磋叮婕傜Щ鎵ц寮曟搸"""
1291
1292 DRIFT_METHODS = {
1293 "topic_weight_decay": topic_weight_decay,
1294 "must_read_replace": must_read_replace,
1295 "keyword_emergence": keyword_emergence,
1296 "direction_add": direction_add,
1297 "direction_remove": direction_remove,
1298 }
1299
1300 def __init__(self, checkfiles: List[Dict[str, Any]]):
1301 self.checkfiles = checkfiles
1302 self.drift_history: List[Dict[str, Any]] = []
1303
1304 def select_random_checkfile(self) -> Optional[Dict[str, Any]]:
1305 """闅忔満閫夋嫨涓€涓?checkfile"""
1306 if not self.checkfiles:
1307 return None
1308 return random.choice(self.checkfiles)
1309
1310 def should_drift(self, probability: float = 0.5) -> bool:
1311 """鍒ゆ柇鏄惁鍙戠敓婕傜Щ"""
1312 return random.random() < probability
1313
1314 def advance_profile_drift(
1315 self,
1316 profile: Dict[str, Any],
1317 *,
1318 selected_papers: Optional[List[Dict]] = None,
1319 date: Optional[str] = None,
1320 drift_probability: float = 0.5,
1321 strategy_mode: str = STRATEGY_SIMULATION,
1322 ) -> Tuple[Dict[str, Any], Optional[Dict[str, Any]]]:
1323 return advance_anchor_drift(
1324 profile,
1325 selected_papers,
1326 date,
1327 drift_probability=drift_probability,
1328 checkfiles=self.checkfiles,
1329 strategy_mode=strategy_mode,
1330 )
1331
1332 def apply_drift(
1333 self,
1334 profile: Dict[str, Any],
1335 checkfile: Optional[Dict[str, Any]] = None,
1336 selected_papers: Optional[List[Dict]] = None,
1337 date: Optional[str] = None,
1338 ) -> Tuple[Dict[str, Any], Optional[Dict[str, Any]]]:
1339 """
1340 瀵圭敤鎴风敾鍍忓簲鐢ㄦ紓绉?
1341 Args:
1342 profile: 鐢ㄦ埛鐢诲儚
1343 checkfile: 婕傜Щ閰嶇疆鏂囦欢锛堝鏋滀笉浼犲垯闅忔満閫夋嫨锛? selected_papers: 鐢ㄦ埛閫変腑鐨勮鏂? date: 鏃ユ湡
1344
1345 Returns:
1346 (鏇存柊鍚庣殑 profile, drift_event 鍏冩暟鎹?
1347 """

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected