Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -52,28 +52,23 @@ def get_keybert_query(text, top_n=10):
|
|
52 |
return query
|
53 |
|
54 |
# --- PubMed retrieval ---
|
55 |
-
def
|
56 |
-
query = get_keybert_query(text, top_n=10)
|
57 |
-
print("PubMed Query:", query)
|
58 |
ncbi_url = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/'
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
abstracts = [re.sub(r"\s+", " ", a).strip() for a in abstracts]
|
75 |
-
return titles, abstracts
|
76 |
-
return [], []
|
77 |
|
78 |
# --- Claim extraction ---
|
79 |
indicator_phrases = [
|
@@ -189,7 +184,7 @@ def summarize_evidence_llm(claim, evidence_list, model_choice):
|
|
189 |
pipe = get_summarizer(model_choice)
|
190 |
outputs = pipe(
|
191 |
messages,
|
192 |
-
max_new_tokens=
|
193 |
do_sample=False,
|
194 |
temperature=0.1,
|
195 |
)
|
|
|
52 |
return query
|
53 |
|
54 |
# --- PubMed retrieval ---
|
55 |
+
def retrieve_pubmed_abstracts_vintage(query, n=100):
|
|
|
|
|
56 |
ncbi_url = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/'
|
57 |
+
search_url = f"{ncbi_url}esearch.fcgi?db=pubmed&term={query}&retmax={n}&sort=relevance&retmode=xml"
|
58 |
+
r = requests.get(search_url)
|
59 |
+
root = ET.fromstring(r.text)
|
60 |
+
pmids = [el.text for el in root.findall('.//Id')]
|
61 |
+
if not pmids:
|
62 |
+
return [], []
|
63 |
+
ids = ','.join(pmids)
|
64 |
+
fetch_url = f"{ncbi_url}efetch.fcgi?db=pubmed&id={ids}&rettype=abstract&retmode=xml&retmax={n}&sort=relevance"
|
65 |
+
resp = requests.get(fetch_url)
|
66 |
+
root2 = ET.fromstring(resp.text)
|
67 |
+
titles = [a.text for a in root2.findall('.//ArticleTitle')]
|
68 |
+
abstracts = [b.text for b in root2.findall('.//AbstractText')]
|
69 |
+
return titles, abstracts
|
70 |
+
|
71 |
+
#return [], []
|
|
|
|
|
|
|
72 |
|
73 |
# --- Claim extraction ---
|
74 |
indicator_phrases = [
|
|
|
184 |
pipe = get_summarizer(model_choice)
|
185 |
outputs = pipe(
|
186 |
messages,
|
187 |
+
max_new_tokens=128,
|
188 |
do_sample=False,
|
189 |
temperature=0.1,
|
190 |
)
|