Language packs¶
What a third-party language pack must implement, and how it tells the library what it can do.
denckring.core.protocol.LanguagePack ¶
Bases: Protocol
Per-language behaviour.
A pack implements every method here, but one whose capability it does not
declare must raise MissingCapability rather than approximate. word_spans,
alphabet, vowels, ascenders and descenders go beyond the original
four-method sketch: violations need character offsets, and the prisoner's
constraint needs glyph shapes.
denckring.core.protocol.Constructive ¶
Bases: Protocol
A procedure that can generate, not merely validate.
apply is optional by ADR 0002, so it is not on BaseProcedure. This
protocol is how callers ask whether a given procedure has one, and it
narrows the type at the same time.
seed was an explicit keyword here and is now an ordinary parameter on
SeedParams, carried by the ten procedures that draw. A keyword named in
this signature binds before **params and so can never be validated, which
is what made seed unvalidatable for all 27.
produce joined apply here for the same reason: runtime_checkable
makes isinstance check method presence only, and every
ConstructiveProcedure inherits both from the base class, so the set of
procedures this protocol matches is unchanged by adding the second name.
Capabilities¶
A pack does not declare a language "supported" or not — it declares a capabilities
set, built from string constants defined in denckring.lang.base: TOKENS,
ALPHABET, FOLD_DIACRITICS, LETTER_SHAPES, SYLLABLES, SYLLABLES_HEURISTIC,
SYLLABLES_DICTIONARY, WORDS, NOUNS, GLOSSES, PHONEMES and STRESS. A
procedure, in turn, declares a requires list of the same strings on its catalogue
entry. BaseProcedure.check compares the two before running anything: if the pack's
capabilities do not cover everything the procedure requires, it raises
MissingCapability naming the
procedure, the language and the missing capability, rather than falling back to an
approximation. Adding a language pack is a matter of implementing
LanguagePack and declaring which of these
strings it can honestly back — nothing more.