/** * Fuzzy Search Utilities * * Provides fuzzy string matching capabilities for search functionality */ /** * Calculate simple edit distance (Levenshtein distance) between two strings * @param {string} str1 - First string * @param {string} str2 - Second string * @returns {number} Edit distance */ export function editDistance(str1: string, str2: string): number; /** * Fuzzy match with tolerance for typos * @param {string} searchWord - Word to search for * @param {string} targetWord - Word to match against * @param {number} tolerance - Maximum edit distance allowed (default: 2) * @returns {boolean} Whether words match within tolerance */ export function fuzzyMatch(searchWord: string, targetWord: string, tolerance?: number): boolean; /** * Score text based on fuzzy matching with search words * @param {string} text - Text to score * @param {string[]} searchWords - Array of search words * @param {number} baseWeight - Base weight for this text field * @returns {number} Score */ export function scoreText(text: string, searchWords: string[], baseWeight?: number): number; /** * Perform fuzzy search on an array of items * @param {Array} items - Items to search * @param {string} keyword - Search keyword * @param {Function} scoringFunction - Function to score each item * @param {number} minScore - Minimum score threshold (default: 1) * @returns {Array} Filtered and sorted items */ export function fuzzySearch(items: any[], keyword: string, scoringFunction: Function, minScore?: number): any[]; /** * Create a line-based fuzzy search for text content * @param {string} content - Text content to search * @param {string} keyword - Search keyword * @param {number} contextLines - Number of context lines to include (default: 2) * @returns {Array} Array of matching sections with context */ export function fuzzySearchLines(content: string, keyword: string, contextLines?: number): any[];