feat(scoring): implemented semantic context padding and optimized excerpting v2.76.0
This commit is contained in:
@@ -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(' ');
|
||||
|
||||
Reference in New Issue
Block a user