orthonym.validation.spelling.lexer#
Note
Internal API. Names and behaviour may change between releases.
Lexical reader of a substitutive name, for the spelling checks (no naming code, no OPSIN).
*normalise() – primes as ', no superscript digits, no markdown marks.
*enclosures() – every pair of enclosing marks, as a tree, each classified as a
counted mark (a substituent enclosure, a stereodescriptor set, a compound locant, an isotope descriptor) or an integral one (fusion, von Baeyer, spiro and ring-assembly descriptors, added indicated hydrogen), the distinction of -.4 (the Blue Book-:7506).
- *
units()– the words of the name and the content of every substituent enclosure, each read as a token stream with its child enclosures collapsed to placeholders.
- *
letters()– the nonitalic Roman letters of a prefix for alphanumerical order ,:3442).
A reader that cannot make sense of a string never guesses:UnbalancedMarksError is raised
for marks that do not pair, and the checks treat any other unknown shape as an abstention.
- orthonym.validation.spelling.lexer.normalise(s)#
The name with primes written
'and superscript digits as plain digits.
- class orthonym.validation.spelling.lexer.Encl(typ, start, end, content, kind='', children=<factory>, parent=None)#
Bases:
objectOne pair of enclosing marks of the normalised name.
- typ: str#
- start: int#
- end: int#
- content: str#
- kind: str = ''#
- children: list#
- parent: object = None#
- property counted: bool#
the parentheses of added indicated hydrogen and the brackets of fusion, spiro, ring-assembly and von Baeyer descriptors are ignored in the nesting order; /.4 (:7478,:7501): those of compound locants, stereodescriptors and isotope descriptors are taken into consideration.
- Type:
/.2 (the Blue Book,
- Type:
- exception orthonym.validation.spelling.lexer.UnbalancedMarksError#
Bases:
ExceptionThe enclosing marks of the name do not pair.
- orthonym.validation.spelling.lexer.enclosures(s)#
Every pair of enclosing marks of
s(a normalised name), with its tree and kind.
- class orthonym.validation.spelling.lexer.Tok(kind, text, locs=(), enc=None)#
Bases:
objectA token of a unit: LOC (a locant set), IH (an indicated-hydrogen group), ENC (a child substituent enclosure), STEREO, OTHER (isotope, ratio), ITAL (an italic prefix), ASM (a ring-assembly descriptor), TXT (letters).
- kind: str#
- text: str#
- locs: tuple = ()#
- enc: object = None#
- class orthonym.validation.spelling.lexer.Unit(text, toks, encl=None, word=0)#
Bases:
objectA word of the name (
enclNone) or the content of a substituent enclosure.- text: str#
- toks: list#
- encl: object = None#
- word: int = 0#
- orthonym.validation.spelling.lexer.units(name)#
(normalised name, enclosures, units, placeholder mapping) of
name.
- orthonym.validation.spelling.lexer.letters(text)#
The nonitalic Roman letters of a prefix name for alphanumerical order,:3442): locants, italic prefixes, stereodescriptors, indicated hydrogen, isotope descriptors and the integral descriptors removed; the letters of enclosed substituent names are kept ,:3477: ‘the first letter of its complete name’).