Source: https://github.com/aipoch/medical-research-skills
When to Use
- You have a scientific paragraph and want suggested PubMed papers for each sentence.
- You need top-ranked references with title, DOI, PMID, year, and a short why recommended explanation.
- You are drafting or reviewing a manuscript and want quick literature grounding for key claims.
- You want a lightweight reference matcher that uses only the official PubMed E-utilities API (no third-party services).
- You need a scriptable tool for batch or CLI workflows to generate candidate citations.
Key Features
- Sentence-level reference matching for scientific text.
- Returns the top N (default: 3) most relevant PubMed records per sentence.
- Outputs structured fields: title, DOI, PMID, year, recommendation reason.
- Relevance ranking based on:
- keyword overlap / match strength,
- publication year preference,
- citation-count signal (when available/derivable).
- Safety constraints:
- Network access restricted to
eutils.ncbi.nlm.nih.gov.
- No local filesystem writes except to
outputs/ during execution.
- Request timeout set to 30 seconds with clear error messages.
- Supports Python API usage and CLI usage (including interactive mode).
Dependencies
- Python 3.x (standard library only; no third-party packages required)
Example Usage
Python (direct call)
from reference_finder import find_references
text = "CRISPR-Cas9 gene editing has revolutionized biomedical research."
results = find_references(text)
for ref in results[:3]:
print(f"- {ref['title']} ({ref['year']})")
print(f" DOI: {ref['doi']}")
print(f" PMID: {ref['pmid']}")
print(f" Reason: {ref['reason']}")
CLI (single input)
python scripts/find_refs.py "CRISPR-Cas9 gene editing has revolutionized biomedical research."
CLI (interactive mode)
python scripts/find_refs.py
Example output (JSON)
[
{
"pmid": "PMID:",
"title": "A Programmable Dual-RNA-Guided DNA Endonuclease in Vitro",
"doi": "10.1126/science.1225829",
"year": 2012,
"reason": "Highest keyword match for 'CRISPR-Cas9', foundational paper"
}
]
Implementation Details
Data flow
- Sentence splitting: The input text is split into sentences (implementation-defined; typically punctuation-based).
- PubMed search (ESearch): For each sentence, a query is sent to:
https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi
- Record retrieval (EFetch): The top candidate PMIDs are fetched via:
https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi
- Field extraction: Title, year, PMID, and DOI (when present) are extracted from the returned metadata.
- Ranking and selection: Candidates are scored and the top N are returned with a short recommendation reason.
Ranking signals
- Keyword match: Measures overlap between sentence terms and retrieved record metadata (e.g., title/abstract terms when available).
- Publication year: Used as a preference signal (e.g., favoring more recent work unless a classic/foundational match is strong).
- Citation count: Incorporated when available/derivable; otherwise treated as missing without failing the run.
Operational constraints and safety
- Allowed network host:
eutils.ncbi.nlm.nih.gov only.
- Prohibited: Any third-party URLs.
- Filesystem: Do not write outside
outputs/ during execution.
- Rate limiting: Use a reasonable request cadence (e.g., ~0.5s between requests) to respect API limits.
- Timeout: 30 seconds per request.
- Error handling: Return semantic, user-readable error messages for network/API/parse failures.
Defaults
- Top references per sentence: 3
- Endpoints:
- ESearch:
https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi
- EFetch:
https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi
Related project files
1---2name: reference-finder3description: Automatically finds and ranks PubMed references for each sentence in scientific text; use when you need titles, DOIs, and brief recommendation reasons from the PubMed E-utilities API.4license: MIT5---6> **Source**: [https://github.com/aipoch/medical-research-skills](https://github.com/aipoch/medical-research-skills)
7
8## When to Use
9
10- You have a scientific paragraph and want suggested PubMed papers for **each sentence**.
11- You need **top-ranked references** with **title, DOI, PMID, year**, and a short **why recommended** explanation.
12- You are drafting or reviewing a manuscript and want quick **literature grounding** for key claims.
13- You want a lightweight reference matcher that uses **only the official PubMed E-utilities API** (no third-party services).
14- You need a scriptable tool for batch or CLI workflows to generate candidate citations.
15
16## Key Features
17
18- Sentence-level reference matching for scientific text.
19- Returns the **top N (default: 3)** most relevant PubMed records per sentence.
20- Outputs structured fields: **title, DOI, PMID, year, recommendation reason**.
21- Relevance ranking based on:
22 - keyword overlap / match strength,
23 - publication year preference,
24 - citation-count signal (when available/derivable).
25- Safety constraints:
26 - Network access restricted to `eutils.ncbi.nlm.nih.gov`.
27 - No local filesystem writes except to `outputs/` during execution.
28 - Request timeout set to **30 seconds** with clear error messages.
29- Supports Python API usage and CLI usage (including interactive mode).
30
31## Dependencies
32
33- Python **3.x** (standard library only; no third-party packages required)
34
35## Example Usage
36
37### Python (direct call)
38
39```python
40from reference_finder import find_references
41
42text = "CRISPR-Cas9 gene editing has revolutionized biomedical research."
43
44results = find_references(text)
45
46for ref in results[:3]:
47 print(f"- {ref['title']} ({ref['year']})")
48 print(f" DOI: {ref['doi']}")
49 print(f" PMID: {ref['pmid']}")
50 print(f" Reason: {ref['reason']}")
51```
52
53### CLI (single input)
54
55```bash
56python scripts/find_refs.py "CRISPR-Cas9 gene editing has revolutionized biomedical research."
57```
58
59### CLI (interactive mode)
60
61```bash
62python scripts/find_refs.py
63```
64
65### Example output (JSON)
66
67```json
68[
69 {
70 "pmid": "PMID:",
71 "title": "A Programmable Dual-RNA-Guided DNA Endonuclease in Vitro",
72 "doi": "10.1126/science.1225829",
73 "year": 2012,
74 "reason": "Highest keyword match for 'CRISPR-Cas9', foundational paper"
75 }
76]
77```
78
79## Implementation Details
80
81### Data flow
82
831. **Sentence splitting**: The input text is split into sentences (implementation-defined; typically punctuation-based).
842. **PubMed search (ESearch)**: For each sentence, a query is sent to:
85 - `https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi`
863. **Record retrieval (EFetch)**: The top candidate PMIDs are fetched via:
87 - `https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi`
884. **Field extraction**: Title, year, PMID, and DOI (when present) are extracted from the returned metadata.
895. **Ranking and selection**: Candidates are scored and the top **N** are returned with a short recommendation reason.
90
91### Ranking signals
92
93- **Keyword match**: Measures overlap between sentence terms and retrieved record metadata (e.g., title/abstract terms when available).
94- **Publication year**: Used as a preference signal (e.g., favoring more recent work unless a classic/foundational match is strong).
95- **Citation count**: Incorporated when available/derivable; otherwise treated as missing without failing the run.
96
97### Operational constraints and safety
98
99- **Allowed network host**: `eutils.ncbi.nlm.nih.gov` only.
100- **Prohibited**: Any third-party URLs.
101- **Filesystem**: Do not write outside `outputs/` during execution.
102- **Rate limiting**: Use a reasonable request cadence (e.g., **~0.5s** between requests) to respect API limits.
103- **Timeout**: **30 seconds** per request.
104- **Error handling**: Return semantic, user-readable error messages for network/API/parse failures.
105
106### Defaults
107
108- **Top references per sentence**: 3
109- **Endpoints**:
110 - ESearch: `https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi`
111 - EFetch: `https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi`
112
113### Related project files
114
115- Main script: `scripts/find_refs.py`
116- Tests: `tests/test_finder.py`
117- Evaluation checklist: `references/evaluation-checklist.md`
118- PubMed E-utilities documentation: https://www.ncbi.nlm.nih.gov/books/NBK25504/