/** * BM25 Text Search — Free Tier Semantic Search Alternative * * Okapi BM25 ranking function with field boosting. * Significantly better than naive keyword matching: * - Term frequency saturation (repeated terms don't dominate) * - Inverse document frequency (rare terms score higher) * - Document length normalization (short docs don't get penalized) * - Stemming via Porter-like suffix stripping * * Zero dependencies. ~100 lines of actual logic. */ /** Tokenize and stem text. Strips punctuation, lowercases, stems. */ export declare function tokenize(text: string): string[]; export interface BM25Document { /** Unique ID */ id: string; /** Fields to index, with boost weights. Higher boost = more important. */ fields: { text: string; boost: number; }[]; } export interface BM25Result { id: string; score: number; /** Normalized score 0-1 for compatibility with similarity field */ similarity: number; } /** * Score documents against a query using BM25 with field boosting. * * @param query - Search query text * @param docs - Documents to search * @param k - Max results to return * @returns Scored and ranked results */ export declare function bm25Search(query: string, docs: BM25Document[], k: number): BM25Result[]; //# sourceMappingURL=bm25.d.ts.map