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