@sroussey/parse-address
Version:
International street address parser for 220 jurisdictions (US, CA + 218 countries and territories), with SEC EDGAR country-code resolution
20 lines (19 loc) • 1.24 kB
TypeScript
import type { ParsedAddress } from "./types/address.js";
export declare function countSignificantTokens(text: string): number;
export declare function streetSegment(address: string, parsed: ParsedAddress): string;
export declare function losesTokens(address: string, parsed: ParsedAddress | null, ignored?: string[]): boolean;
/**
* A minimal, guaranteed-lossless parse: leading civic number (+ attached letter
* suffix) and the entire remaining street segment intact in `street`. Reuses
* `streetSegment` -- the same street-segment isolation `losesTokens` uses --
* so the fallback and the detector never disagree on where the street portion
* ends. Keeps the high-confidence locational fields the raw parse already
* found; drops the (untrusted) prefix/type/suffix/unit structure rather than
* risk a partial, lossy split.
*/
export declare function minimalLosslessParse(address: string, parsed: ParsedAddress): ParsedAddress;
/**
* Guard applied at the `AddressParser` facade: passes a lossless parse
* through unchanged, and replaces a truncating one with `minimalLosslessParse`.
*/
export declare function enforceTokenPreservation(address: string, parsed: ParsedAddress | null, ignored?: string[]): ParsedAddress | null;