Normalize author field from list / JSON string / plain string.
(authors: Any)
| 306 | def normalize_authors(authors: Any) -> List[str]: |
| 307 | """Normalize author field from list / JSON string / plain string.""" |
| 308 | if not authors: |
| 309 | return [] |
| 310 | |
| 311 | if isinstance(authors, list): |
| 312 | return [str(author).strip() for author in authors if str(author).strip()] |
| 313 | |
| 314 | if isinstance(authors, str): |
| 315 | authors_text = authors.strip() |
| 316 | if not authors_text: |
| 317 | return [] |
| 318 | try: |
| 319 | parsed = json.loads(authors_text) |
| 320 | except json.JSONDecodeError: |
| 321 | parsed = None |
| 322 | if isinstance(parsed, list): |
| 323 | return [str(author).strip() for author in parsed if str(author).strip()] |
| 324 | return [part.strip() for part in re.split(r"[;,,、]", authors_text) if part.strip()] |
| 325 | |
| 326 | return [str(authors).strip()] |
| 327 | |
| 328 | |
| 329 | def _build_interest_vector_descriptor(profile: Dict[str, Any]) -> str: |
| 330 | """Compact descriptor for drift-aware interest fusion.""" |
| 331 | drift_state = (profile or {}).get("drift_state", {}) or {} |
no outgoing calls
no test coverage detected