Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a4048bc56d0719ef

Jump to content

Module:SMILES2IUPAC/Data

From Wikipedia, the free encyclopedia
-- Module:SMILES2IUPAC/Data
-- Shared data tables: organic-subset elements, IUPAC numeral roots, multiplying prefixes.
-- No logic here on purpose, so every naming submodule reads from one source of truth.

local p = {}

-- Organic subset atoms allowed without brackets (SMILES spec).
-- Longest symbols first matters for the parser (Cl/Br before C/B).
p.organicSubset = {
	['Cl'] = 'Cl', ['Br'] = 'Br',
	['B'] = 'B', ['C'] = 'C', ['N'] = 'N', ['O'] = 'O',
	['P'] = 'P', ['S'] = 'S', ['F'] = 'F', ['I'] = 'I',
}

-- Two-letter symbols that must be checked before falling back to one letter.
p.twoLetterSymbols = { 'Cl', 'Br' }

-- IUPAC roots for chain length 1-20 (unbranched parent chain / substituent stem).
-- 1-4 are retained trivial roots; 5+ are the systematic Greek/Latin numeral roots.
p.chainRoot = {
	[1] = 'meth', [2] = 'eth', [3] = 'prop', [4] = 'but',
	[5] = 'pent', [6] = 'hex', [7] = 'hept', [8] = 'oct',
	[9] = 'non', [10] = 'dec', [11] = 'undec', [12] = 'dodec',
	[13] = 'tridec', [14] = 'tetradec', [15] = 'pentadec',
	[16] = 'hexadec', [17] = 'heptadec', [18] = 'octadec',
	[19] = 'nonadec', [20] = 'icos',
}

-- Multiplying prefixes for identical substituents (di/tri...) — NOT used for the
-- parent chain itself, only for citing repeated substituents.
p.multiplyingPrefix = {
	[2] = 'di', [3] = 'tri', [4] = 'tetra', [5] = 'penta',
	[6] = 'hexa', [7] = 'hepta', [8] = 'octa', [9] = 'nona', [10] = 'deca',
}

-- IUPAC roots for ones digit (for dynamic chain construction >20)
p.chainOnes = {
	[1] = 'hen', [2] = 'do', [3] = 'tri', [4] = 'tetra',
	[5] = 'penta', [6] = 'hexa', [7] = 'hepta', [8] = 'octa', [9] = 'nona'
}

-- IUPAC roots for tens digit (20-90)
p.chainTens = {
	[10] = 'dec', [20] = 'cos', [30] = 'triacont', [40] = 'tetracont',
	[50] = 'pentacont', [60] = 'hexacont', [70] = 'heptacont',
	[80] = 'octacont', [90] = 'nonacont'
}

-- IUPAC roots for hundreds digit (100-900)
p.chainHundreds = {
	[100] = 'hect', [200] = 'dict', [300] = 'trict', [400] = 'tetract',
	[500] = 'pentact', [600] = 'hexact', [700] = 'heptact',
	[800] = 'octact', [900] = 'nonact'
}

-- IUPAC spelling exceptions for dynamic concatenation
-- The naming logic module should check this table BEFORE attempting to blindly 
-- concatenate ones + tens + hundreds (e.g. to prevent "hendec" for 11).
p.chainExceptions = {
	[11] = 'undec',     -- Exception: 11 is undec, not hendec
	[20] = 'icos',      -- Exception: Standalone 20 is icos. (When combined >21 it uses 'cos', e.g. docos)
	[21] = 'henicos',   -- Exception: 21 retains the 'i' from icos because 'hen' ends in a consonant
	[22] = 'docos',     -- Standard rule application (do + cos) placed here for safety/reference
	[23] = 'tricos'
}

p.heteroSubstituents = {
	['Cl'] = 'chloro', ['Br'] = 'bromo', ['I'] = 'iodo', ['F'] = 'fluoro',
	['N'] = 'amino', ['O'] = 'hydroxy', ['S'] = 'mercapto',
	['NO2'] = 'nitro', ['CN'] = 'cyano', ['OR'] = 'alkoxy'
}

p.functionalGroups = {
	['COOH'] = { suffix = 'oic acid', priority = 10, type = 'suffix' },
	['COOR'] = { suffix = 'oate', priority = 9, type = 'suffix' },
	['CONH2'] = { suffix = 'amide', priority = 8, type = 'suffix' },
	['C#N'] = { suffix = 'nitrile', priority = 7, type = 'suffix' },
	['CHO'] = { suffix = 'al', priority = 6, type = 'suffix' },
	['=O'] = { suffix = 'one', priority = 5, type = 'suffix' },
	['OH'] = { suffix = 'ol', priority = 4, type = 'suffix' },
	['SH'] = { suffix = 'thiol', priority = 3, type = 'suffix' },
	['NH2'] = { suffix = 'amine', priority = 2, type = 'suffix' }
}

return p