/** * Relevance scoring algorithms for search results */ import type { SearchMatch } from './types.js'; /** * Field weights for scoring (higher = more relevant) */ export declare const FIELD_WEIGHTS: { readonly title: 100; readonly name: 70; readonly tags: 70; readonly description: 50; readonly content: 10; }; /** * Calculate relevance score for a match * * Scoring factors: * - Field weight (title > name > tags > description > content) * - Exact word match bonus (2x) * - Position bonus (earlier = more relevant) * - Frequency penalty (many matches = less specific) * * @param match - The search match to score * @param queryTerms - Individual query terms * @param totalMatches - Total matches found in the field * @param matchPosition - Position of this match (0-based) * @returns Score between 0-100 */ export declare function calculateMatchScore(match: Pick, queryTerms: string[], totalMatches: number, matchPosition: number): number; /** * Calculate overall relevance score for a spec * * Uses the highest scoring match from each field type, * weighted by field importance. * * @param matches - All matches for the spec * @returns Overall score between 0-100 */ export declare function calculateSpecScore(matches: SearchMatch[]): number; /** * Check if text contains all query terms (AND logic) * * @param text - Text to search * @param queryTerms - Terms to find * @returns True if all terms are found */ export declare function containsAllTerms(text: string, queryTerms: string[]): boolean; /** * Check if text contains any query term (OR logic) * * @param text - Text to search * @param queryTerms - Terms to find * @returns True if any term is found, false for empty queryTerms */ export declare function containsAnyTerm(text: string, queryTerms: string[]): boolean; /** * Count occurrences of query terms in text * * @param text - Text to search * @param queryTerms - Terms to count * @returns Number of occurrences */ export declare function countOccurrences(text: string, queryTerms: string[]): number; /** * Find all match positions in text for query terms * * @param text - Text to search * @param queryTerms - Terms to find * @returns Array of [start, end] positions */ export declare function findMatchPositions(text: string, queryTerms: string[]): Array<[number, number]>; //# sourceMappingURL=scoring.d.ts.map