Fix standardise_taxon_rank() mangling 'section' - #292
Conversation
"sectio" is a literal prefix of its own English translation
("section"), so a fixed substring replacement anywhere in the
input also matched (and mangled) already-English values:
"section"/"subsection"/"zoosection"/"zoosubsection" became
"sectionn"/"subsectionn"/etc.
Anchor the replacement to the end of the string instead --
generalises to any "...section" variant without an allowlist.
Found via real AFD data in traitecoevo/taxonAlign#11.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Root causeOf the seven Latin→English rank translations in None of the other six pairs (regnum/kingdom, classis/class, ordo/order, familia/family, varietas/variety, forma/form) have this property -- checked each; none is a prefix of its own translation. Fix and rejected alternativeAnchored the "sectio" replacement to the end of the string ( Considered an alternative: skip translation for any input already in an allowlist of known-English terms. Rejected because it would need every current and future "...section" compound spelled out to stay correct. Confirmed the anchored fix instead handles an untested compound for free: standardise_taxon_rank("supersectio")
#> [1] "supersection"Verificationstandardise_taxon_rank(c("section", "sectio", "subsection", "subsectio",
"zoosection", "zoosectio", "zoosubsection", "zoosubsectio"))
#> [1] "section" "section" "subsection" "subsection"
#> [5] "zoosection" "zoosection" "zoosubsection" "zoosubsection"Added a regression test to Found while building an APCalign-equivalence test suite in the sibling |
"sectio" is a literal prefix of its own English translation
("section"), so a fixed substring replacement anywhere in the
input also matched (and mangled) already-English values:
"section"/"subsection"/"zoosection"/"zoosubsection" became
"sectionn"/"subsectionn"/etc.
Anchor the replacement to the end of the string instead --
generalises to any "...section" variant without an allowlist.
Found via real AFD data in traitecoevo/taxonAlign#11.