Spaces:
Running
Running
File size: 1,687 Bytes
7ef1abc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import sys
import os
import asyncio
# Add project root to path
sys.path.append(os.getcwd())
from app.services.doaj_service import DOAJService
from app.services.arxiv_service import ArXivService
from app.services.pubmed_service import PubMedService
def test_pubmed_search():
print("Testing PubMed search...")
service = PubMedService()
results = service.fetch_papers("cancer immunotherapy", max_results=5)
print(f"Found {len(results)} results from PubMed")
for r in results:
print(f"- {r['title']} (Has PDF: {r['has_pdf']})")
if r['has_pdf']:
print(f" URL: {r['url']}")
def test_discovery_logic_simulation():
print("\nTesting Triple-Source Discovery logic simulation...")
# Simulate the logic in discovery.py
arxiv_service = ArXivService()
doaj_service = DOAJService()
pubmed_service = PubMedService()
query = "Alzheimer's disease"
max_results = 5
arxiv_data = arxiv_service.fetch_papers(query, max_results)
doaj_data = doaj_service.fetch_papers(query, max_results)
pubmed_data = pubmed_service.fetch_papers(query, max_results)
print(f"ArXiv: {len(arxiv_data)} papers")
print(f"DOAJ: {len(doaj_data)} papers")
print(f"PubMed: {len(pubmed_data)} papers")
merged = []
seen = set()
for p in arxiv_data + doaj_data + pubmed_data:
title_key = "".join(p["title"].lower().split())
if title_key not in seen:
merged.append(p["title"])
seen.add(title_key)
print(f"Total unique papers merged: {len(merged)}")
if __name__ == "__main__":
test_pubmed_search()
test_discovery_logic_simulation()
|