feat(scoring): implemented tiered conflict severity system v2.73.0
This commit is contained in:
@@ -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
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user