feat(scoring): integrated conflict detection and info density metrics v2.71.0

This commit is contained in:
g1nation
2026-05-05 11:03:06 +09:00
parent 0bac9d4b21
commit ca9fbf125a
3 changed files with 22 additions and 8 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "g1nation", "name": "g1nation",
"version": "2.70.0", "version": "2.71.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "g1nation", "name": "g1nation",
"version": "2.70.0", "version": "2.71.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"marked": "^18.0.2" "marked": "^18.0.2"
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "astra", "name": "astra",
"displayName": "Astra", "displayName": "Astra",
"description": "The personal intelligence layer for Antigravity and VS Code. A private cognitive partner for deep project context, memory, and proactive strategic decision-making.", "description": "The personal intelligence layer for Antigravity and VS Code. A private cognitive partner for deep project context, memory, and proactive strategic decision-making.",
"version": "2.70.0", "version": "2.71.0",
"publisher": "g1nation", "publisher": "g1nation",
"license": "MIT", "license": "MIT",
"icon": "assets/icon.png", "icon": "assets/icon.png",
+19 -5
View File
@@ -51,7 +51,11 @@ const SCORING_CONFIG = {
] as [string, string[]][], ] as [string, string[]][],
DENSITY_THRESHOLD: 0.15, // 발췌문 추출 시 최소 키워드 밀도 DENSITY_THRESHOLD: 0.15, // 발췌문 추출 시 최소 키워드 밀도
TITLE_MULTIPLIER: 3.0, // 제목 일치 가중치 TITLE_MULTIPLIER: 3.0, // 제목 일치 가중치
GLOBAL_CACHE_LIMIT: 2000 GLOBAL_CACHE_LIMIT: 2000,
CONFLICT_INDICATORS: new Set([
'반대', '충돌', '오류', '논란', '반박', '차이', '대조',
'conflict', 'contradict', 'dispute', 'controversy', 'error', 'mismatch', 'vs'
])
}; };
// ─── Global Search State & Cache ─── // ─── Global Search State & Cache ───
@@ -168,6 +172,8 @@ export interface ScoredDocument {
titleBoost: number; titleBoost: number;
recencyBoost: number; recencyBoost: number;
matchedTerms: string[]; matchedTerms: string[];
conflictDetected: boolean;
informationDensity: number;
} }
/** /**
@@ -208,6 +214,9 @@ export function scoreTfIdf(
let score = 0; let score = 0;
const matchedTerms: string[] = []; const matchedTerms: string[] = [];
// Conflict Detection: 문서 내 상충 지표 확인
const conflictDetected = docTokens.some(t => SCORING_CONFIG.CONFLICT_INDICATORS.has(t));
for (const term of expandedQuery) { for (const term of expandedQuery) {
const tf = termFrequency(term, docTokens); const tf = termFrequency(term, docTokens);
const idf = idfCache.get(term) || 1; const idf = idfCache.get(term) || 1;
@@ -217,12 +226,15 @@ export function scoreTfIdf(
matchedTerms.push(term); matchedTerms.push(term);
} }
// Title match bonus (3x) // Title match bonus
const titleMultiplier = titleTokens.has(term) ? 3.0 : 1.0; const titleMultiplier = titleTokens.has(term) ? SCORING_CONFIG.TITLE_MULTIPLIER : 1.0;
score += tfidf * titleMultiplier; score += tfidf * titleMultiplier;
} }
// Recency boost: documents modified recently get a boost // Information Density: 쿼리 관련 토큰의 밀도 측정
const informationDensity = docTokens.length > 0 ? matchedTerms.length / docTokens.length : 0;
// Recency boost
let recencyBoost = 0; let recencyBoost = 0;
if (doc.lastModified) { if (doc.lastModified) {
const daysAgo = (now - doc.lastModified) / (1000 * 60 * 60 * 24); const daysAgo = (now - doc.lastModified) / (1000 * 60 * 60 * 24);
@@ -239,7 +251,9 @@ export function scoreTfIdf(
score: score + recencyBoost + titleBoost, score: score + recencyBoost + titleBoost,
titleBoost, titleBoost,
recencyBoost, recencyBoost,
matchedTerms: [...new Set(matchedTerms)] matchedTerms: [...new Set(matchedTerms)],
conflictDetected,
informationDensity
}; };
}); });
} }