feat(scoring): implemented tiered conflict severity system v2.73.0

This commit is contained in:
g1nation
2026-05-05 11:15:03 +09:00
parent 563e499324
commit e6bc263872
4 changed files with 25 additions and 9 deletions
+16 -2
View File
@@ -168,6 +168,8 @@ function inverseDocumentFrequency(
return Math.log((smoothN + 1) / (smoothContaining + 1)) + 1;
}
export type ConflictSeverity = 'NONE' | 'LOW' | 'MEDIUM' | 'HIGH';
export interface ScoredDocument {
index: number;
score: number;
@@ -175,6 +177,7 @@ export interface ScoredDocument {
recencyBoost: number;
matchedTerms: string[];
conflictDetected: boolean;
conflictSeverity: ConflictSeverity;
informationDensity: number;
}
@@ -216,8 +219,18 @@ export function scoreTfIdf(
let score = 0;
const matchedTerms: string[] = [];
// Conflict Detection: 문서 내 상충 지표 확인
const conflictDetected = docTokens.some(t => SCORING_CONFIG.CONFLICT_INDICATORS.has(t));
// Conflict Detection & Severity Analysis (Substring based for better recall with particles)
const rawText = `${doc.title} ${doc.content}`.toLowerCase();
const conflictMatches = [...SCORING_CONFIG.CONFLICT_INDICATORS].filter(indicator =>
rawText.includes(indicator.toLowerCase())
);
const conflictDetected = conflictMatches.length > 0;
let conflictSeverity: ConflictSeverity = 'NONE';
if (conflictMatches.length >= 4) conflictSeverity = 'HIGH';
else if (conflictMatches.length >= 2) conflictSeverity = 'MEDIUM';
else if (conflictMatches.length === 1) conflictSeverity = 'LOW';
for (const term of expandedQuery) {
const tf = termFrequency(term, docTokens);
@@ -255,6 +268,7 @@ export function scoreTfIdf(
recencyBoost,
matchedTerms: [...new Set(matchedTerms)],
conflictDetected,
conflictSeverity,
informationDensity
};
});