Skip to content

Commit

Permalink
Merge pull request #20 from Martin-lc/yu-update
Browse files Browse the repository at this point in the history
pubmed empty fixed
  • Loading branch information
Martin-lc authored Dec 7, 2023
2 parents 4a7ca13 + 67ad786 commit 883c6ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions content_fetcher/pubmed.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,13 @@ const getAbstractByID = function (PMID) {
const elements = xmlDoc.getElementsByTagName('AbstractText');
for (let i = 0; i < elements.length; i++) {
const element = elements[i];
const textContent = element.innerText;
abstractArray.push(textContent);
const textContent = element.textContent;
if (textContent && textContent.trim()) {
abstractArray.push(textContent.trim());
} else {
console.warn(`No valid abstract found for PMID: ${PMID}`);
abstractArray.push('No abstract available.');
}
}
return abstractArray;
});
Expand Down
3 changes: 3 additions & 0 deletions content_optimizer/llm.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ async function summarizePubmedOutput(pubmedData, maxLength = null, targetLanguag


for (let i = 0; i < pubmedData.length; i++) {
if (pubmedData[i].some(text => typeof text !== 'string' || !text.trim())) {
throw new Error(`Invalid text in PubMed data at index ${i}`);
}
const concatenatedText = pubmedData[i].join(' ');
const summary = await summarizeText(concatenatedText, maxLength, targetLanguage);
const summary_trimmed = summary.replace(/\n+/g, ' ').trim();
Expand Down

0 comments on commit 883c6ff

Please sign in to comment.