(row: Dict[str, Any], idf: Dict[str, float], state: UserNaturalProfileState)
| 365 | |
| 366 | |
| 367 | def score_row(row: Dict[str, Any], idf: Dict[str, float], state: UserNaturalProfileState) -> Dict[str, Any]: |
| 368 | row_text = paper_text(row) |
| 369 | title = str(row.get("title") or "") |
| 370 | row_vector = vectorize_text(row_text, idf) |
| 371 | profile_similarity = scaled_similarity(row_vector, state.profile_vector) |
| 372 | keyphrase_alignment = phrase_alignment_score(row_text, state.terms) |
| 373 | title_alignment = phrase_alignment_score(title, state.terms) |
| 374 | aspect_coverage = aspect_coverage_score(row_text, state.directions) |
| 375 | final_score = clamp( |
| 376 | SCORE_WEIGHTS["profile_similarity"] * profile_similarity |
| 377 | + SCORE_WEIGHTS["keyphrase_alignment"] * keyphrase_alignment |
| 378 | + SCORE_WEIGHTS["title_alignment"] * title_alignment |
| 379 | + SCORE_WEIGHTS["aspect_coverage"] * aspect_coverage |
| 380 | ) |
| 381 | return { |
| 382 | "system_score": final_score, |
| 383 | "system_label": label_for_score(final_score), |
| 384 | "profile_similarity_score": profile_similarity, |
| 385 | "keyphrase_alignment_score": keyphrase_alignment, |
| 386 | "title_alignment_score": title_alignment, |
| 387 | "aspect_coverage_score": aspect_coverage, |
| 388 | "profile_term_count": len(state.terms), |
| 389 | "profile_direction_count": len(state.directions), |
| 390 | "uses_feedback_update": False, |
| 391 | } |
| 392 | |
| 393 | |
| 394 | def load_user_metadata(input_dir: Path) -> Dict[str, Dict[str, Any]]: |
no test coverage detected