MCPcopy Create free account
hub / github.com/HzaCode/OneCite / _search_pubmed

Method _search_pubmed

onecite/pipeline/identifier.py:685–717  ·  view source on GitHub ↗

Search PubMed for medical literature

(self, query: str, limit: int = 5)

Source from the content-addressed store, hash-verified

683 return None
684
685 def _search_pubmed(self, query: str, limit: int = 5) -> List[Dict]:
686 """Search PubMed for medical literature"""
687 try:
688 # First, search for PMIDs
689 search_url = f"{self.pubmed_base}/esearch.fcgi"
690 params = {
691 'db': 'pubmed',
692 'term': query,
693 'retmax': limit,
694 'retmode': 'json'
695 }
696
697 response = requests.get(search_url, params=params, timeout=10)
698 response.raise_for_status()
699
700 data = response.json()
701 pmids = data.get('esearchresult', {}).get('idlist', [])
702
703 if not pmids:
704 return []
705
706 results = []
707 for pmid in pmids:
708 result = self._search_pubmed_by_id(pmid)
709 if result:
710 results.append(result)
711
712 self.logger.info(f"PubMed search returned {len(results)} results")
713 return results
714
715 except Exception as e:
716 self.logger.warning(f"PubMed search failed: {str(e)}")
717 return []
718
719 def _search_semantic_scholar(self, query: str, limit: int = 5) -> List[Dict]:
720 """Search Semantic Scholar for academic papers"""

Callers 2

_fuzzy_searchMethod · 0.95

Calls 3

_search_pubmed_by_idMethod · 0.95
raise_for_statusMethod · 0.45
jsonMethod · 0.45

Tested by 1