/** * @copyright Sister Software * @license AGPL-3.0 * @author Teffen Ellis, et al. * * Inference-side gazetteer-anchor features (#464, knowledge-ladder rung 3.2) — the TS mirror of the * Python training pipeline (`mailwoman_train/gazetteer_anchor.py`). Both consumers load the SAME * codex-generated lexicon (`scripts/build-gazetteer-anchor-lexicon.mjs` → * `data/gazetteer/anchor-lexicon-v1.json`) whose `rules` encode the match semantics as DATA, so * the two implementations cannot drift. The model conditions on per-token candidate-tag-set clues * fed alongside `input_ids`; this builds them from a raw address + its SentencePiece pieces. * * The clue INFORMS, the model decides (model-first). `gazetteer-inference.test.ts` pins the matcher * against the Python fixture: the homograph clue is symmetric, "in" ≠ "IN", multi-word countries * paint every word. */ import type { TokenizedPiece } from "./tokenizer.ts"; /** * The candidate-tag-set feature width: country/region/po_box/cedex/homograph (the lexicon's slot count). Used for the * ONNX zero-fallback when a gazetteer-trained model is run with no clue data. MUST match the lexicon JSON's * `feature_dim` and the trained model's `gazetteer_feature_dim`. */ export declare const GAZETTEER_FEATURE_DIM = 5; /** * Street-type evidence channel width (Option-A bundle) — the runner zero-fallback + lexicon feature_dim contract. */ export declare const STREET_TYPE_FEATURE_DIM = 1; /** * Locality-surface evidence channel width (locality + locality_homograph). */ export declare const LOCALITY_SURFACE_FEATURE_DIM = 2; /** * The loaded lexicon — the JSON shape from build-gazetteer-anchor-lexicon.mjs. */ export interface GazetteerLexicon { featureDim: number; slots: readonly string[]; bits: Record; maxNgram: number; /** * Case-insensitive: key = word_norm lowercased → bitmask. */ entries: Map; /** * Case-SENSITIVE: key = word_norm uppercased → bitmask (surface must already be uppercase). */ codeEntries: Map; /** * V3.23 digit guard (`rules.digit_guard`): a matched span paints NOTHING when any span word or the nearest non-empty * neighbor word carries a decimal digit — evidence painted beside a house number swallowed the digit into the span. * Rides the lexicon so train/inference stay symmetric by construction; false on pre-v3.23 artifacts. */ digitGuard: boolean; } /** * Parse the lexicon JSON (already `JSON.parse`d — keeps this module browser-safe; caller reads). */ export declare function parseGazetteerLexicon(raw: { feature_dim: number; slots: string[]; bits: Record; max_ngram: number; entries: Record; code_entries: Record; rules?: { digit_guard?: boolean; }; }): GazetteerLexicon; /** * Scan the raw surface and paint each char with its candidate-tag bitmask (mirrors Python). */ export declare function gazetteerCharPaint(text: string, lexicon: GazetteerLexicon): number[]; /** * Channel choreography (#464, v0.9.13 postcode fix; DeepSeek 2026-06-10): zero the gazetteer clue on pieces within * `window` of a postcode-anchor hit. The clue fires on the region token (`CA`/`GA`) immediately before a US postcode; * its additive vector strengthens `B-region`, which makes the `B-region → B-postcode` CRF transition less competitive * and drops the postcode (~3pp, US-only — FR postcode precedes the locality, no region neighbor). Suppressing the clue * adjacent to the postcode removes the interference while leaving every other clue intact. Returns a NEW * features/confidence pair (does not mutate). `anchorConfidence[i] > 0` marks postcode-span pieces. PAIRS WITH the * train-time half (`gazetteer_anchor.suppress_gazetteer_near_postcode`) — enable both or neither. */ export declare function suppressGazetteerNearPostcode(gazetteer: { features: number[][]; confidence: number[]; }, anchorConfidence: ReadonlyArray, window?: number): { features: number[][]; confidence: number[]; }; /** * Per-piece gazetteer features + confidence for `text`, projected onto its SP `pieces` by the SAME char→piece rule the * labels use (a piece takes the bits of the first non-whitespace char it covers). Returns `(pieces × featureDim)` * features + `(pieces,)` confidence (1.0 wherever any bit fires). */ export declare function buildGazetteerFeatures(text: string, pieces: ReadonlyArray, lexicon: GazetteerLexicon): { features: number[][]; confidence: number[]; }; //# sourceMappingURL=gazetteer-inference.d.ts.map