@siva-sub/mcp-public-transport
Version:
A Model Context Protocol server for Singapore transport data with real-time information and routing
41 lines (40 loc) • 1.15 kB
TypeScript
export interface FuzzySearchResult<T> {
item: T;
score: number;
matches: string[];
}
export interface SearchPattern {
pattern: RegExp;
replacement: string;
weight: number;
}
export declare class FuzzySearchService {
private singaporeAbbreviations;
private commonPatterns;
/**
* Expand abbreviations in a search query
*/
expandAbbreviations(query: string): string[];
/**
* Calculate Levenshtein distance between two strings
*/
private levenshteinDistance;
/**
* Calculate similarity score between query and target string
*/
calculateSimilarity(query: string, target: string): number;
/**
* Search through items with fuzzy matching
*/
search<T>(query: string, items: T[], extractText: (item: T) => string[], minScore?: number, maxResults?: number): FuzzySearchResult<T>[];
/**
* Extract common Singapore location patterns from text
*/
extractLocationPatterns(text: string): {
blockNumber?: string;
roadName?: string;
landmark?: string;
direction?: string;
amenityType?: string;
};
}