import { type ShapeSeed, SurfaceSlot } from "#tools/prominent-shapes/seeds"; /** * One form as the model returns it: the text and the keys of the surfaces it contains. */ export interface ReturnedForm { raw: string; uses: string[]; } /** * The forms the model returned for one place. */ export interface ReturnedPlace { id: string; forms: ReturnedForm[]; } /** * The reasons a returned form is dropped. */ export declare const FormDrop: { /** * The form cites a key the seed doesn't hold. */ readonly UnknownSurface: "unknown_surface_key"; /** * The form cites a bare slot letter, and no choice of that slot's keys passes every other rule. */ readonly LetterUnresolved: "slot_letter_without_passing_key"; /** * The form cites a bare slot letter, and more than one choice of that slot's keys passes every other rule. */ readonly LetterAmbiguous: "slot_letter_with_several_passing_keys"; /** * The cited slots are a combination the label policy doesn't write. */ readonly SlotsNotAllowed: "slots_not_allowed"; /** * A cited surface isn't in the text, so its span has no offsets. */ readonly UnresolvableSpan: "unresolvable_span"; /** * The text holds letters or digits outside every cited surface. */ readonly UnsuppliedText: "text_outside_supplied_surfaces"; /** * Two spans touch without a separator in a script that separates words. */ readonly UnseparatedSpans: "unseparated_spans"; /** * The form writes one surface in Latin script beside another in a different script. */ readonly MixedScript: "mixed_script"; /** * The text is empty or longer than a search-box query. */ readonly Length: "raw_length"; /** * The same text was already kept for this place. */ readonly Duplicate: "duplicate_raw"; }; /** * One drop reason. */ export type FormDrop = (typeof FormDrop)[keyof typeof FormDrop]; /** * One labeled span of a kept form. */ export interface CandidateSpan { tag: "locality" | "dependent_locality" | "region" | "country"; /** * The span's text as the form writes it. */ value: string; /** * UTF-16 offsets into `raw`, `end` exclusive. */ start: number; end: number; /** * The supplied surface the span writes, and the record it came from. */ surface: string; origin: string; } /** * A kept form before the run's model and batch are added to it. */ export interface ValidatedForm { wof_id: number; country: string; band: ShapeSeed["band"]; shape: string; raw: string; spans: CandidateSpan[]; /** * Whether the form cited a bare slot letter (`n`) rather than a key (`n2`), * and the letter was resolved to the one key of that slot the text passes with. */ keys_from_letters: boolean; } /** * The shape id of a set of cited slots: the second segments in a fixed order, * or `bare` for a form that cites only the name. */ export declare function shapeOfSlots(slots: ReadonlySet): string; /** * Checks one returned form against its seed. * * A bare slot letter cited as a key stands for a key of that slot. * Each choice of keys is checked under the rules a numbered citation passes. * * The form is kept only when exactly one choice passes, so a letter never decides * between two surfaces the text could both be. */ export declare function validateForm(seed: ShapeSeed, form: ReturnedForm): ValidatedForm | FormDrop; /** * The kept forms of one place and its drops by reason, with a repeated text kept once. */ export declare function validatePlaceForms(seed: ShapeSeed, forms: readonly ReturnedForm[]): { kept: ValidatedForm[]; drops: Partial>; }; /** * What one request's response held: the kept forms, the drops by reason, * the forms returned and the places answered. */ export interface ValidatedResponse { kept: ValidatedForm[]; drops: Partial>; returned: number; answered: Set; } /** * Validates the response text of one request against the request's seeds, * or returns `null` when the text isn't the schema's shape. */ export declare function validateResponse(text: string, seeds: readonly ShapeSeed[]): ValidatedResponse | null; /** * The reason every form of a response dropped under, or `null` when a form was kept, * the response held no form, or its forms dropped under more than one reason. * * One reason taking a whole response is a fault of the request or of the validator rather than of a form. */ export declare function wholeResponseDropReason(response: ValidatedResponse): string | null; /** * Parses a response's text into its places, or returns `null` when the text isn't the schema's shape. * * A place or form of another shape makes the whole response unreadable rather than a * shorter list, so a caller never counts a partly read response as a complete one. */ export declare function parseShapeResponse(text: string): ReturnedPlace[] | null; //# sourceMappingURL=validate.d.ts.map