orthonym.rules.functional_replacement#

Note

Internal API. Names and behaviour may change between releases.

Shared functional-replacement (FRN) acid-name engine — /.

ONE name-builder for the functional-replacement / functional-class derivatives of the retained acid parents (carbonic, carbamic, phosphoric, sulfuric, …), used by BOTH the carbon acids carbonic family) and the non-carbon oxoacids. Per the cross-cutting design (, FRN-infix owner = a phase) the construction logic lives here once, not duplicated per family.

This module is PURE string assembly: it does NOT perceive structure. The caller (rules.inorganic_acids / future non-carbon adapters) decides which replacement a given structure represents — keyed on the exact canonical SMILES, fail-closed — and asks this engine to spell the name. Keeping perception out of the builder is what makes it safely reusable and free of false positives.

Coverage in a phase = the OPSIN-round-trippable plain forms:
  • chalcogen / peroxo infix replacement on a retained acid (carbonoperoxoic, carbonodithioic, carbonotrithioic)

  • the =O -> =NH imido replacement (carbonimidic, carbamimidic)

  • multiplicative poly-acids (dicarbonic, tricarbonic)

  • acyl-halide functional-class words (phosphoryl trichloride, sulfuryl dichloride)

The italic O/S/Se tautomer-locant word-forms (carbonothioic S-acid) are DEFERRED to a phase — OPSIN rejects the word-form, so they require name-exact gold rather than round-trip validation (V23 plan, a phase).

orthonym.rules.functional_replacement.build_frn_acid_name(base_stem, infix, count=1)#

Spell a single-infix functional-replacement acid (-ic acid parents).

base_stem is the parent-acid stem WITHOUT its trailing linking vowel: "carbon" (carbonic), "carbam" (carbamic), "phosphor" (phosphoric), "sulfur" (sulfuric). infix is the FRN infix key; count its multiplicity. Returns None for an unknown infix (fail-closed).

Examples:

build_frn_acid_name("carbon", "peroxo", 1) -> "carbonoperoxoic acid"
build_frn_acid_name("carbon", "thio", 2) -> "carbonodithioic acid"
build_frn_acid_name("carbon", "thio", 3) -> "carbonotrithioic acid"
build_frn_acid_name("carbon", "imido", 1) -> "carbonimidic acid"
build_frn_acid_name("carbam", "imido", 1) -> "carbamimidic acid"
orthonym.rules.functional_replacement.build_carbonic_mono_frn(base_stem, infix_counts)#

Spell a mononuclear carbonic/carbamic functional-replacement acid carrying a SET of FRN infixes /.1.3). base_stem is "carbon" or "carbam"; infix_counts maps an infix in {thio, seleno, telluro, peroxo, imido, hydrazono} to its multiplicity. Infixes are cited in ALPHABETICAL order /, the =X infix contracted only when it is final. Fail-closed (None) for an unknown infix, an out-of-range count, or an empty set.

build_carbonic_mono_frn(“carbon”, {“imido”: 1, “thio”: 1})

-> “carbonimidothioic acid”

build_carbonic_mono_frn(“carbam”, {“peroxo”: 1}) -> “carbamoperoxoic acid” build_carbonic_mono_frn(“carbon”, {“peroxo”: 2}) -> “carbonodiperoxoic acid” build_carbonic_mono_frn(“carbon”, {“hydrazono”: 1})-> “carbonohydrazonic acid” build_carbonic_mono_frn(“carbam”, {“imido”: 1, “seleno”: 1})

-> “carbamimidoselenoic acid”

build_carbonic_mono_frn(“carbon”, {“hydrazono”: 1, “seleno”: 2})

-> “carbonohydrazonodiselenoic acid”

orthonym.rules.functional_replacement.build_polyacid_name(base_acid_name, count)#

Spell a multiplicative poly-acid /: multiplier + acid.

build_polyacid_name("carbonic acid", 2) -> "dicarbonic acid".

orthonym.rules.functional_replacement.build_acyl_halide_name(acyl_word, halide_word, count)#

Spell an acid-halide functional-class name from an acyl-group word.

For acids with identical replaceable groups the acyl word (phosphoryl / sulfuryl / phosphorothioyl …) carries the structure; the halide is a separate class word, multiplied. build_acyl_halide_name( "phosphoryl", "chloride", 3) -> "phosphoryl trichloride".

orthonym.rules.functional_replacement.build_p_frn_acid_name(front_prefix, parent_stem, infix_counts)#
Spell a mononuclear noncarbon-oxoacid functional-replacement acid

whose replacements are class infixes (amido / halido /

pseudohalido), NOT chalcogen infixes.

front_prefix — already-assembled detachable-prefix string cited in front

(organyl on P: "methyl" / "phenyl"; or the N-locant amido substituents: "N,N-dimethyl"). "" for the bare parent.

parent_stem — parent-acid stem WITHOUT its linking vowel: "phosphor"

(phosphoric), "phosphon" (phosphonic), "phosphin" (phosphinic), "arsor"/"arson" etc.

infix_counts — {combining-form: multiplicity} for the class infixes

present, e.g. {"amido": 1} / {"chlorido": 1} / {"cyanatido": 1}.

Returns None (fail-closed) for an unknown infix or an out-of-range count.

Examples:

build_p_frn_acid_name("N,N-dimethyl", "phosphor", {"amido": 1})
    -> "N,N-dimethylphosphoramidic acid"
build_p_frn_acid_name("methyl", "phosphon", {"cyanatido": 1})
    -> "methylphosphonocyanatidic acid"
build_p_frn_acid_name("phenyl", "phosphon", {"chlorido": 1})
    -> "phenylphosphonochloridic acid"
orthonym.rules.functional_replacement.build_p_frn_acid_stem_word(front_prefix, parent_stem, infix_counts)#

The class-infix FRN acid name WITHOUT the trailing " acid" — i.e. the "{front}{stem}o{infixes}ic" stem word that:func:build_p_frn_acid_name appends " acid" to, and that the halide / amide builders append a class word to / derive the halide/amide from the same acid stem). Fail-closed (None) for an unknown infix or out-of-range count.

build_p_frn_acid_stem_word(“N,N-dimethyl”, “phosphor”, {“amido”: 1})

-> “N,N-dimethylphosphoramidic”

orthonym.rules.functional_replacement.build_p_frn_halide_name(acid_stem_word, halide_counts)#

Spell a mononuclear noncarbon-oxoacid HALIDE / pseudohalide.

acid_stem_word — the acid name with the trailing " acid" stripped:

"phenylphosphonous" (BB phenylphosphonous dichloride), "phenylphosphonic", "diphenylphosphinous", or an FRN-infixed stem such as "N,N-dimethylphosphoramidic" (BB N,N-dimethylphosphoramidic dichloride).

halide_counts — {class-word: multiplicity} for the halide /

pseudohalide principal groups, e.g. {"chloride": 2} or {"bromide": 1, "chloride": 1}. The class words are cited in:data:_HALIDE_CLASS_ORDER; identical ones are multiplied.

Returns None (fail-closed) for an unknown class word or out-of-range count.

Examples:

build_p_frn_halide_name("phenylphosphonous", {"chloride": 2})
    -> "phenylphosphonous dichloride"
build_p_frn_halide_name("phenylphosphonous", {"bromide": 1, "chloride": 1})
    -> "phenylphosphonous bromide chloride"
build_p_frn_halide_name("N,N-dimethylphosphoramidic", {"chloride": 2})
    -> "N,N-dimethylphosphoramidic dichloride"
orthonym.rules.functional_replacement.build_p_frn_amide_name(acid_stem_word, kind='amide', count=1)#

Spell a mononuclear noncarbon-oxoacid AMIDE / hydrazide.

acid_stem_word — the acid name minus " acid" (including any N-/P-

substituent prefixes already assembled), e.g. "N,N,P,P-tetramethylphosphinic" (BB N,N,P,P-tetramethylphosphinic amide) or "P-phenylphosphonic" for a diamide.

kind — "amide" or "hydrazide": the class

word when every -OH is replaced by -NH2 / -NH-NH2 and the amide/hydrazide is the principal group).

count — multiplicity of the class word ("diamide").

Returns None (fail-closed) for an unknown class or out-of-range count.

Examples:

build_p_frn_amide_name("N,N,P,P-tetramethylphosphinic")
    -> "N,N,P,P-tetramethylphosphinic amide"
build_p_frn_amide_name("P-phenylphosphonic", "amide", 2)
    -> "P-phenylphosphonic diamide"
orthonym.rules.functional_replacement.acyl_prefix_for(element, chalcogen='oxo', skeletal=0)#

acyl PREFIX base name for a mononuclear P/As/Sb acid core, or None if the cell is not tabled (fail-closed). chalcogen is the =E token (‘oxo’/’thio’/’imido’/’nitrido’); skeletal is the C + H count on the central atom (0 -> the -oryl exception, 1 -> -onoyl, 2 -> -inoyl). SHARED export: a phase

must look up acyl names here, never re-spell them.

acyl_prefix_for(“P”, “oxo”, 0) -> “phosphoryl” acyl_prefix_for(“As”, “oxo”, 0) -> “arsoryl” acyl_prefix_for(“P”, “thio”, 2) -> “phosphinothioyl”