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

Function normalize_authors

agents/feedback-agent/main.py:308–328  ·  view source on GitHub ↗

Normalize author field from list / JSON string / plain string.

(authors: Any)

Source from the content-addressed store, hash-verified

306def 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
329def _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 {}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected