feat(scoring): implemented semantic context padding and optimized excerpting v2.76.0

This commit is contained in:
g1nation
2026-05-05 11:30:29 +09:00
parent fc7cc16e88
commit 18021bd19d
4 changed files with 28 additions and 5 deletions
+10 -2
View File
@@ -300,7 +300,7 @@ export function extractBestExcerpt(
const sentences = content
.split(/(?<=[.!?。!?\n])\s*/)
.map((s) => s.trim())
.filter((s) => s.length > 10);
.filter((s) => s.length > 5);
if (sentences.length === 0) return content.slice(0, maxLength);
@@ -343,8 +343,16 @@ export function extractBestExcerpt(
}
}
// 4. Result construction with semantic context padding
let finalStart = bestStart;
let finalEnd = bestStart + bestLen;
// 전후 문맥을 1문장씩 추가하여 의미적 완전성 확보 (예산 허용 시)
if (finalStart > 0) finalStart--;
if (finalEnd < scored.length) finalEnd++;
const excerptSentences = scored
.slice(bestStart, bestStart + bestLen)
.slice(finalStart, finalEnd)
.map((s) => s.sentence);
const result = excerptSentences.join(' ');