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

Function prepare_paper_features

deployments/feishu/daily-push-agent/main.py:876–907  ·  view source on GitHub ↗

Attach embeddings and normalized ranking features to fetched papers.

(papers: List[Dict])

Source from the content-addressed store, hash-verified

874 return papers
875
876 embedding_texts = [build_paper_text(paper) for paper in papers]
877 embeddings = embed_batch(embedding_texts)
878 embedding_service = get_embedding_service()
879 print(f"Embedding descriptor: {embedding_service.descriptor}")
880
881 for paper, embedding in zip(papers, embeddings):
882 paper["embedding"] = embedding
883 paper["embedding_model"] = embedding_service.descriptor
884 paper["institution"] = str(paper.get("institution") or "")
885 paper["quality_score"] = estimate_quality_score(paper)
886
887 semantic_topics = canonicalize_direction_terms(
888 extract_topics_from_text(paper.get("title", ""), paper.get("abstract", "")),
889 keep_unknown=True,
890 )
891 source_categories = list(paper.get("categories", []))
892 if paper.get("source") == "openreview":
893 source_categories.append(paper.get("venue", "conference"))
894 elif paper.get("source") == "journal":
895 source_categories.append(paper.get("journal", "journal"))
896
897 expanded_terms = expand_direction_terms(semantic_topics)
898 paper["keywords"] = dedupe_preserve_order(source_categories + semantic_topics)
899 paper["topics"] = semantic_topics
900 paper["direction_terms"] = expanded_terms
901
902 return papers
903
904
905def extract_topics_from_text(title: str, abstract: str = "") -> List[str]:
906 """Extract coarse semantic topics from title and abstract text."""
907 title_lower = f"{title} {abstract}".lower()
908 topics = []
909
910 # ===== 用户画像中的主题(优先匹配)=====

Callers 1

fetch_and_process_papersFunction · 0.85

Calls 9

build_paper_textFunction · 0.85
embed_batchFunction · 0.85
get_embedding_serviceFunction · 0.85
estimate_quality_scoreFunction · 0.85
extract_topics_from_textFunction · 0.85
dedupe_preserve_orderFunction · 0.85
getMethod · 0.80
expand_direction_termsFunction · 0.70

Tested by

no test coverage detected