UNPKG

@zsnout/ithkuil

Version:

A set of tools which can generate and parse romanized Ithkuil text and which can generate Ithkuil script from text and JSON data.

46 lines (45 loc) 1.54 kB
import { type AffixEntry, type RootEntry } from "../data/index.js"; import type { AffixDegree } from "../generate/index.js"; export interface DataRoot { readonly stem: number; readonly label: string; readonly cr: string; } export interface DataAffixByDegree { cs: string; abbr: string; value: string; degree: AffixDegree; } export type RecognizerIssueKind = "root" | "affix by degree" | "affix by label" | "affix by abbreviation"; export type RecognizerIssue = { kind: RecognizerIssueKind; source: string; }; export interface SomeReplacement<T, K extends string> { source: string; kind: K; actual: T; alts: T[]; } export type Replacement = SomeReplacement<DataRoot, "root"> | SomeReplacement<DataAffixByDegree, "affix by degree"> | (SomeReplacement<AffixEntry, "affix by label" | "affix by abbreviation"> & { degree: AffixDegree; }); export interface RecognizerOutput { source: string; gloss: string; replacements: Replacement[]; issues: RecognizerIssue[]; } export interface Recognizer { /** * Replaces instance of double quotes with corresponding roots, single quotes * with affixes, and `abbr/degree` segments with the proper affix. */ (source: string): RecognizerOutput; } /** * Creates a function which recognizes roots and affixes in a gloss. This is * designed to transform user input before passing to `ungloss`. */ export declare function createRecognizer(affixes: readonly AffixEntry[], roots: readonly RootEntry[]): Recognizer;