import { Normaliser } from "./normalise.js"; import { type Gazetteer } from "./gazetteer.js"; export declare const DEFAULT_THRESHOLD = 0.82; export declare const DEFAULT_MARGIN = 0.05; export type Method = "exact" | "variant" | "fuzzy" | "ambiguous" | "none"; export interface Candidate { pcode: string; name_en: string; name_ar: string; level: number; score: number; } export interface MatchResult { pcode: string | null; name_en: string | null; name_ar: string | null; level: number | null; score: number; method: Method; alternatives: Candidate[]; } export interface MatchOptions { /** The state the place is in: a P-code (SD15) or a name in any spelling. */ stateHint?: string | null; /** 1 for states, 2 for localities; omit to search both. */ level?: 1 | 2 | null; } /** Round half up to four decimals, the same way in both languages. */ export declare const round4: (x: number) => number; /** Similarity from 0 to 100: 100 * (1 - insertions and deletions needed / total length). */ export declare function ratio(a: string, b: string): number; export declare function tokenSortRatio(a: string, b: string): number; /** Every word of the shorter name is a word of the longer one, and the shorter is long enough to mean something. */ export declare function containsEveryWord(a: string, b: string): boolean; export interface MatcherOptions { threshold?: number; margin?: number; } export declare class Matcher { readonly normaliser: Normaliser; threshold: number; margin: number; private readonly places; private readonly index; private readonly choicesCache; private readonly scorer; constructor(data?: Gazetteer, options?: MatcherOptions); private add; private choices; private allowed; /** The state P-code a hint names (a P-code or a name in any spelling), or null. */ resolveState(hint: string | null | undefined): string | null; private inputs; /** Best [score, method] per P-code for name, within the allowed level and state. */ candidates(name: string, level?: number | null, state?: string | null): Map; /** Every candidate as [pcode, score, method], best first. */ rank(name: string, options?: MatchOptions): [string, number, Method][]; /** Turn ranked candidates into a result: a match only above the threshold and clear of the runner-up. */ decide(ranked: [string, number, Method][]): MatchResult; /** * The official record for name, or no match plus up to three alternatives. * method is exact, variant or fuzzy for a match, and ambiguous or none otherwise. */ match(name: string, options?: MatchOptions): MatchResult; } /** Match name with the bundled gazetteer and default settings. */ export declare function match(name: string, options?: MatchOptions): MatchResult;