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

Function _build_scholar_network_signals

agents/coldstart-agent/main.py:688–771  ·  view source on GitHub ↗

Aggregate richer Scholar collaboration and citation signals.

(publications: List[Dict[str, Any]], scholar_name: str = "")

Source from the content-addressed store, hash-verified

686
687
688def _build_scholar_network_signals(publications: List[Dict[str, Any]], scholar_name: str = "") -> Dict[str, Any]:
689 """Aggregate richer Scholar collaboration and citation signals."""
690 coauthor_counter: Counter[str] = Counter()
691 venue_counter: Counter[str] = Counter()
692 coauthor_stats: Dict[str, Dict[str, Any]] = {}
693
694 for publication in publications or []:
695 citation_count = int(publication.get("citations") or 0)
696 year = int(publication.get("year") or 0)
697 venue = _collapse_whitespace(publication.get("venue", ""))
698 title = _collapse_whitespace(publication.get("title", ""))
699
700 if venue:
701 venue_counter[venue] += 1
702
703 for author_name in _parse_author_names(publication.get("authors", ""), scholar_name=scholar_name):
704 coauthor_counter[author_name] += 1
705 stats = coauthor_stats.setdefault(
706 author_name,
707 {
708 "count": 0,
709 "citation_sum": 0,
710 "last_year": 0,
711 "venues": Counter(),
712 "sample_titles": [],
713 },
714 )
715 stats["count"] += 1
716 stats["citation_sum"] += citation_count
717 stats["last_year"] = max(int(stats.get("last_year") or 0), year)
718 if venue:
719 stats["venues"][venue] += 1
720 if title and title not in stats["sample_titles"]:
721 stats["sample_titles"].append(title)
722
723 collaboration_network = []
724 for author_name, stats in coauthor_stats.items():
725 top_venues = [venue for venue, _ in stats["venues"].most_common(3)]
726 collaboration_network.append(
727 {
728 "name": author_name,
729 "count": int(stats["count"]),
730 "citation_sum": int(stats["citation_sum"]),
731 "last_year": int(stats["last_year"] or 0),
732 "top_venues": top_venues,
733 "sample_titles": list(stats["sample_titles"][:2]),
734 }
735 )
736
737 collaboration_network.sort(
738 key=lambda item: (
739 int(item.get("count") or 0),
740 int(item.get("citation_sum") or 0),
741 int(item.get("last_year") or 0),
742 ),
743 reverse=True,
744 )
745

Callers 2

_merge_scholar_page_dataFunction · 0.85

Calls 3

_collapse_whitespaceFunction · 0.85
_parse_author_namesFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected