orthonym.validation.spelling.units#

Note

Internal API. Names and behaviour may change between releases.

Unit parser on top of:mod:.lexer: per unit (a word of the name or the content of a substituent enclosure), its detachable prefixes with their locants and alphanumerical key, hydro prefixes, indicated hydrogen, skeletal replacement prefixes, the parent token and the endings (suffix, ene/yne, free valence).

(the Blue Book) defines the unit: “the parent structure or… a unit of

structure as defined by its appropriate enclosing marks”. The parser reads a closed lexicon of simple prefixes; a word it cannot split leaves the rest as the parent token, and the checks abstain on a parent they do not know.

orthonym.validation.spelling.units.REPL_ELEMENT = {'aluma': 'Al', 'alumina': 'Al', 'arsa': 'As', 'astata': 'At', 'aza': 'N', 'bisma': 'Bi', 'bora': 'B', 'broma': 'Br', 'chlora': 'Cl', 'fluora': 'F', 'galla': 'Ga', 'germa': 'Ge', 'inda': 'In', 'indiga': 'In', 'ioda': 'I', 'oxa': 'O', 'phospha': 'P', 'plumba': 'Pb', 'polona': 'Po', 'selena': 'Se', 'sila': 'Si', 'stanna': 'Sn', 'stiba': 'Sb', 'tellura': 'Te', 'thalla': 'Tl', 'thia': 'S'}#

the spellings of Table 1.5, general replacement) and Table 2.4, Hantzsch-Widman; ‘aluma’ and ‘indiga’ there, the Blue Book), without ‘carba’. The reader keeps its own copy, since a check must not inherit a defect of the writer’s tables; a test holds it equal to the two tables.

Type:

skeletal replacement (‘a’) prefixes the reader knows, with the element each one names

orthonym.validation.spelling.units.SIMPLE = ['fluoro', 'chloro', 'bromo', 'iodo', 'astato', 'oxo', 'thioxo', 'selanylidene', 'sulfanylidene', 'tellanylidene', 'selenoxo', 'imino', 'hydrazinylidene', 'diazo', 'azido', 'nitro', 'nitroso', 'cyano', 'isocyano', 'cyanato', 'isocyanato', 'thiocyanato', 'isothiocyanato', 'selenocyanato', 'isoselenocyanato', 'amino', 'hydroxy', 'hydroperoxy', 'sulfanyl', 'disulfanyl', 'trisulfanyl', 'selanyl', 'tellanyl', 'sulfo', 'sulfino', 'sulfeno', 'carboxy', 'phosphono', 'phosphanyl', 'phosphoryl', 'phosphinyl', 'phosphinato', 'phosphonato', 'arsanyl', 'stibanyl', 'silyl', 'disilanyl', 'germyl', 'stannyl', 'plumbyl', 'boranyl', 'hydrazinyl', 'diazenyl', 'triazanyl', 'diphosphanyl', 'diselanyl', 'ditellanyl', 'digermyl', 'distannyl', 'diboranyl', 'diarsanyl', 'triazenyl', 'disilyl', 'azanyl', 'azanylidene', 'oxido', 'sulfido', 'oxy', 'dioxy', 'trioxy', 'peroxy', 'sulfanediyl', 'ethenyl', 'ethynyl', 'ethenylidene', 'methylidene', 'methylene', 'carbonyl', 'sulfonyl', 'sulfinyl', 'phenyl', 'phenoxy', 'phenylene', 'benzoyl', 'benzyl', 'benzylidene', 'acetyl', 'formyl', 'carbamoyl', 'sulfamoyl', 'carbamimidoyl', 'acetamido', 'benzamido', 'formamido', 'carbamoylamino', 'anilino', 'ureido', 'guanidino', 'ammonio', 'azaniumyl', 'oxidanyl', 'sulfonato', 'carboxylato', 'olato', 'sulfanylato', 'nitrilo', 'phosphanylidene', 'silylidene', 'ylidene', 'cyclopropyl', 'cyclobutyl', 'cyclopentyl', 'cyclohexyl', 'cycloheptyl', 'cyclooctyl', 'hydroxyimino', 'methoxyimino', 'oxidanylidene', 'sulfanidyl', 'aminooxy', 'hydroxyamino', 'azanylidyne', 'tert', 'sec']#

simple substituent prefixes,, -; a prefix outside this lexicon ends the prefix zone, so an unknown word is read as part of the parent, never split by guess

orthonym.validation.spelling.units.split_simple(txt, nlocs=None)#

Greedy split of the leading simple prefixes of txt: ([(multiplier, prefix)], rest). nlocs (the locants in front) prefers a reading whose multiplier matches their count.

class orthonym.validation.spelling.units.Pref(locs, key, kind, raw, mult=1, enc=None, nested=False, ital=())#

Bases: object

A detachable prefix of a unit.

locs: tuple#
key: str#
kind: str#
raw: str#
mult: int = 1#
enc: object = None#
nested: bool = False#
ital: tuple = ()#
class orthonym.validation.spelling.units.Parsed(unit, prefixes=<factory>, hydro=<factory>, ih=<factory>, repl=<factory>, parent='', parent_locs=(), endings=<factory>, order_after_hydro=<factory>, stereo=<factory>, multiplied=None, notes=<factory>)#

Bases: object

One unit read into prefixes, hydro prefixes, indicated hydrogen, parent and endings.

unit: object#
prefixes: list#
hydro: list#
ih: list#
repl: list#
parent: str = ''#
parent_locs: tuple = ()#
endings: list#
order_after_hydro: list#
stereo: list#
multiplied: object = None#
notes: list#
orthonym.validation.spelling.units.parse_name(name)#

(normalised name, enclosures, [Parsed per unit]) of name. Raises lexer.UnbalancedMarksError for marks that do not pair. Cached per string: the result is shared by every check and must not be changed by a caller.