MCPcopy Create free account
hub / github.com/917Dhj/DeepPaperNote / normalize_crossref_work

Function normalize_crossref_work

scripts/common.py:502–541  ·  view source on GitHub ↗
(item: dict[str, Any])

Source from the content-addressed store, hash-verified

500
501
502def normalize_crossref_work(item: dict[str, Any]) -> dict[str, Any]:
503 title = normalize_whitespace(" ".join(item.get("title") or []))
504 authors = []
505 affiliations = []
506 for author in item.get("author", []) or []:
507 given = normalize_whitespace(str(author.get("given", "")))
508 family = normalize_whitespace(str(author.get("family", "")))
509 name = normalize_whitespace(" ".join(part for part in [given, family] if part))
510 if name:
511 authors.append(name)
512 for aff in author.get("affiliation", []) or []:
513 aff_name = normalize_whitespace(str(aff.get("name", "")))
514 if aff_name and aff_name not in affiliations:
515 affiliations.append(aff_name)
516 venue = normalize_whitespace(" ".join(item.get("container-title") or []))
517 published = (
518 item.get("published-print", {}).get("date-parts")
519 or item.get("published-online", {}).get("date-parts")
520 or item.get("issued", {}).get("date-parts")
521 or []
522 )
523 year = ""
524 if published and isinstance(published, list) and isinstance(published[0], list) and published[0]:
525 year = str(published[0][0])
526 doi = normalize_whitespace(str(item.get("DOI", "")))
527 source_url = normalize_whitespace(str(item.get("URL", "")))
528 return {
529 "title": title,
530 "authors": authors,
531 "affiliations": affiliations,
532 "venue": venue,
533 "doi": doi,
534 "source": "crossref",
535 "source_type": "crossref",
536 "source_url": source_url,
537 "year": year,
538 "published": year,
539 "abstract": strip_tags(str(item.get("abstract", ""))),
540 "metadata_sources": ["crossref"],
541 }
542
543
544def fetch_crossref_by_doi(doi: str) -> dict[str, Any] | None:

Callers 2

fetch_crossref_by_doiFunction · 0.85
search_crossref_by_titleFunction · 0.85

Calls 2

normalize_whitespaceFunction · 0.85
strip_tagsFunction · 0.85

Tested by

no test coverage detected