import type { CanonicalRow, LabeledRow, QuarantinedRow } from "#types"; import { type Tokenizer } from "#utils/tokenize"; /** * One augmentation: a function from a row to its variant, or `null` when the row * offers no text to vary, with its method name. * * The variant writes that name as its `augmentation.name` and as its `source_id` suffix. * * The name lets a caller decide whether it wants a variant before the augmentation runs. */ export interface Augmentation { (row: CanonicalRow): CanonicalRow | null; readonly method: string; } /** * Upper-case raw and components. */ export declare const caseUpper: Augmentation; /** * Lower-case raw and components. */ export declare const caseLower: Augmentation; /** * Drop commas from raw and from every component, each the same way. * * A component that holds a comma of its own (`WAL-MART STORES EAST, LP`) has to lose it too. * The aligner places a span of the component's length, so a component left one character * longer than its text in raw ends its span on the space after it. */ export declare const dropCommas: Augmentation; /** * Double spaces in raw and components. */ export declare const doubleSpace: Augmentation; /** * Render the row on its country layout's envelope lines, so a line break separates * the street line from the city line, for one row in four (#2992). * * The variant's components are the ones the layout printed. * A row whose layout puts everything on one line, or a country with no layout, gets no variant. */ export declare const lineBreaks: Augmentation; /** * Strip accents/diacritics from raw and components. */ export declare const accentStrip: Augmentation; /** * Inject one deterministic typo into an eligible component. */ export declare const typoInject: Augmentation; /** * Writes a US row's state abbreviation as the state's full name (`AK` to `Alaska`), * in the text and the region. */ export declare const stateExpand: Augmentation; /** * Abbreviate full state name to alpha-2. */ export declare const stateAbbreviate: Augmentation; /** * Expand directional abbreviations. */ export declare const directionalExpand: Augmentation; /** * Abbreviate directional words. */ export declare const directionalAbbreviate: Augmentation; /** * Abbreviate trailing US street suffix. */ export declare const streetSuffixAbbreviate: Augmentation; /** * Expand trailing US street suffix. */ export declare const streetSuffixExpand: Augmentation; /** * Abbreviate leading US unit designator. */ export declare const unitDesignatorAbbreviate: Augmentation; /** * Expand leading US unit designator. */ export declare const unitDesignatorExpand: Augmentation; /** * Drop dash from ZIP+4. */ export declare const zipPlus4DashDrop: Augmentation; /** * Drop French street particle. */ export declare const particleStrip: Augmentation; /** * Stable id -> augmentation function. */ export declare const AUGMENTATIONS: Record; /** * Default augmentations by country. */ export declare function defaultAugmentationsForCountry(country: string): readonly Augmentation[]; /** * Yield all non-null augmentation outputs. */ export declare function synthesizeRow(row: CanonicalRow, augmentations?: readonly Augmentation[], /** * Whether the caller wants the variant an augmentation's method writes. An augmentation it doesn't want isn't * run, so a caller that would drop the variant skips its work. */ wants?: (method: string) => boolean): Generator; /** * Weighted random pick from items. */ export declare function weightedPick(items: readonly T[], random: () => number, weightOf: (item: T) => number, options?: { inclusive?: boolean; }): T; /** * One band in a tiered number distribution. */ export interface TieredNumberBand { cutoff?: number; base: number; span: number; } /** * Draw a number from tiered bands. */ export declare function tieredNumber(random: () => number, bands: readonly TieredNumberBand[]): string; /** * Map country names/codes to default locale. */ export declare function countryToLocale(country: string): string; /** * Options for `composeAdversarialRow`. */ export interface ComposeAdversarialOptions { /** * Pattern name written to the row's `recipe.recipe` as `compose:`. */ pattern: string; /** * Separator between venue and address raw. * * @defaultValue `", "` */ separator?: string; /** * Tokenizer for venue and address alignment. */ tokenizer?: Tokenizer; } /** * Successful composition or quarantine result. */ export type ComposeResult = { kind: "labeled"; row: LabeledRow; } | { kind: "quarantined"; row: QuarantinedRow; }; /** * Compose venue + address into a labeled adversarial row. */ export declare function composeAdversarialRow(venue: string, address: CanonicalRow, options: ComposeAdversarialOptions): ComposeResult; //# sourceMappingURL=utils.d.ts.map