/** * @copyright Sister Software * @license AGPL-3.0 * @author Teffen Ellis, et al. * * Synthesis and augmentation utilities. */ import type { CanonicalRow, LabeledRow, QuarantinedRow } from "#types"; import { type Tokenizer } from "#utils/tokenize"; /** * A row augmentation. */ export type Augmentation = (row: CanonicalRow) => CanonicalRow | null; /** * Upper-case raw and components. */ export declare const caseUpper: Augmentation; /** * Lower-case raw and components. */ export declare const caseLower: Augmentation; /** * Drop commas from raw. */ export declare const dropCommas: Augmentation; /** * Double spaces in raw and components. */ export declare const doubleSpace: 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; /** * Expand state abbreviation to full name. */ 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[]): 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. * Default `", "`. */ 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