Skip to content

fix(data): recover 524 silently-unnamed molecules; prefer flavorist names - #255

Merged
rvnminers-A-and-N merged 1 commit into
mainfrom
feat/data-common-names
Jul 29, 2026
Merged

rvnminers-A-and-N merged 1 commit into
mainfrom
feat/data-common-names

Conversation

@rvnminers-A-and-N

Copy link
Copy Markdown
Collaborator

Part of #217. Three naming defects, found by auditing what the grid and cards actually render rather than by reading the code.

1. NaN is truthy. pr.get("common_name") or pr.get("iupac_name") returns NaN whenever the common name is missing, so it never fell through to the IUPAC name β€” leaving ~500 molecules unnamed even though a perfectly good name sat in the table. They rendered as raw SMILES in the grid and on cards. Replaced with an explicit _pick_name() that type-checks each candidate, carrying a comment on why the idiomatic or is wrong here so nobody "simplifies" it back.

2. Curated names were losing to systematic ones. PubChem's common_name is frequently systematic β€” spilanthol's is N-(2-Methylpropyl)-2,6,8-decatrienamide β€” so our hand-picked flavorist names were being overridden by worse ones. The 836 curated names (flavors + aroma/mouthfeel supplements) now take precedence: they were chosen deliberately as what a flavorist calls the molecule. spilanthol now reads "spilanthol".

3. CAS-inverted names read backwards. Carvone, (+-)- Β· Cyclohexanol, 5-methyl-2-(1-methylethenyl)- β€” an ordering that exists for alphabetised print indexes and reads backwards to everyone else. _uninvert_cas() handles the three cases separately, because they resolve differently:

input output
Carvone, (+-)- (+-)-Carvone (stereo prefix, parent keeps its case)
Linalool, oxide Linalool oxide (derivative suffix)
2-Hexen-1-ol, 1-acetate 2-Hexen-1-ol 1-acetate (ester suffix, not a locant prefix)
Cyclohexanol, 5-methyl-… 5-methyl-…-cyclohexanol (substituent prefix)

Anything it doesn't recognise is returned untouched β€” a wrong "fix" is worse than none. 124 β†’ 16. Verified Vanillin, Methyl Methacrylate and 1,6-Dihydrocarvone pass through unchanged.

Net: 7,559 β†’ 8,083 named of 8,853. The remaining 770 genuinely have no name in any source we hold and need the PubChem crawl (#209), so #217 stays open.

ruff check . clean and 30 unit tests pass.

…ames

Three naming defects, found by auditing what the grid and cards actually render.

1. NaN IS TRUTHY. `pr.get("common_name") or pr.get("iupac_name")` returns NaN whenever
   the common name is missing, so it never fell through to the IUPAC name β€” leaving
   ~500 molecules with no name at all even though a perfectly good one sat in the
   table. They rendered as raw SMILES. Replaced with an explicit _pick_name() that
   type-checks each candidate, with a comment explaining why the idiomatic `or` is
   wrong here so nobody "simplifies" it back.

2. CURATED NAMES LOST TO SYSTEMATIC ONES. PubChem's "common_name" is frequently
   systematic β€” spilanthol's is "N-(2-Methylpropyl)-2,6,8-decatrienamide" β€” so our
   hand-picked flavorist names were being overridden by worse ones. Curated names
   (flavors + aroma/mouthfeel supplements, 836 of them) now take precedence: those
   were chosen deliberately as what a flavorist calls the molecule. spilanthol now
   reads "spilanthol".

3. CAS-INVERTED NAMES READ BACKWARDS. "Carvone, (+-)-", "Cyclohexanol, 5-methyl-2-
   (1-methylethenyl)-" β€” an ordering that exists for alphabetised print indexes.
   _uninvert_cas() handles the three cases separately (stereo descriptor -> prefix
   keeping the parent's case; derivative word -> suffix; substituent -> prefix with
   the parent lowercased) and returns anything it doesn't recognise untouched, since
   a wrong "fix" is worse than none. 124 -> 16.

Net: 7,559 -> 8,083 named of 8,853. The remaining 770 genuinely have no name in any
source we hold and need the PubChem crawl (#209).

Part of #217.

Signed-off-by: Austin L. <86896075+rvnminers-A-and-N@users.noreply.github.com>
@rvnminers-A-and-N
rvnminers-A-and-N merged commit cbc7893 into main Jul 29, 2026
4 checks passed
@rvnminers-A-and-N
rvnminers-A-and-N deleted the feat/data-common-names branch July 29, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant