arela
Version:
AI-powered CTO with multi-agent orchestration, code summarization, visual testing (web + mobile) for blazing fast development.
57 lines • 1.59 kB
TypeScript
import type { MemoryItem, ScoredItem } from "./types.js";
/**
* RelevanceScorer - Scores memory items by relevance to query
*
* Scoring factors:
* 1. Semantic similarity (40%) - Using simple text similarity
* 2. Keyword overlap (30%) - Direct word matches
* 3. Layer confidence weight (20%) - From classifier
* 4. Recency (10%) - Newer items preferred for Session/Project
*/
export declare class RelevanceScorer {
/**
* Score multiple items by relevance to query
*/
score(query: string, items: MemoryItem[]): ScoredItem[];
/**
* Calculate relevance score for a single item
*/
private calculateScore;
/**
* Extract content from item (handles various formats)
*/
private getItemContent;
/**
* Calculate text similarity using character n-grams
* Returns score between 0 and 1
*/
private textSimilarity;
/**
* Generate character n-grams from text
*/
private getNgrams;
/**
* Calculate keyword overlap score
* Returns score between 0 and 1
*/
private keywordOverlap;
/**
* Calculate recency score based on timestamp
* Returns score between 0 and 1
*/
private recencyScore;
/**
* Tokenize text into words
*/
private tokenize;
/**
* Calculate cosine similarity between two texts
* Alternative to textSimilarity using TF-IDF-like approach
*/
cosineSimilarity(text1: string, text2: string): number;
/**
* Calculate term frequency
*/
private termFrequency;
}
//# sourceMappingURL=scorer.d.ts.map