(v3.0.1.9125) Fix translations being translated again (e.g. Ticarcillinee, groupee) and untranslated parts of combination names, and let as.mo() recognise translated names in the set language, cached per language

This commit is contained in:
dr. M.S. (Matthijs) Berends committed 2026-10-12 22:25:57 +02:00
1 parent d4ba5051e7
commit 04a2f0b3ac
9 files changed
+98 -35

No files matched your search

+10
View File
@@ -365,4 +365,14 @@ test_that("test-mo.R", {
c("B_SLMNL_TYPH", "B_SLMNL_TYPH", "B_SLMNL_TYPH", "B_SLMNL_HMRM", "B_SLMNL_PRTA", "B_SLMNL_GRPB")
)
expect_identical(as.character(as.mo("Salmonella enterica arizonae", info = FALSE)), "B_SLMNL_ENTR_ARZN")
# translated names, such as the output of mo_name() in the set language
translated_mos <- c("B_STPHY_CONS", "B_STPHY_COPS", "B_STRPT_HAEM", "B_STRPT_GRPA", "B_STRPT_GRPB", "B_STRPT_ABCG", "B_STRPT_MILL", "B_STRPT_VIRI", "B_SLMNL_GRPB", "B_GRAMN", "B_GRAMP", "F_YEAST", "F_FUNGUS", "P_PROTOZOAN", "UNKNOWN")
for (lang in setdiff(AMR:::LANGUAGES_SUPPORTED, "en")) {
expect_identical(as.character(as.mo(mo_name(translated_mos, language = lang), language = lang, info = FALSE)), translated_mos, info = lang)
}
expect_identical(
as.character(as.mo(c("Staphylocoque à coagulase négative", "Streptocoque Bêta-hémolytique", "streptocoque beta-hemolytique", "Streptococcus groupe A"), language = "fr", info = FALSE)),
c("B_STPHY_CONS", "B_STRPT_HAEM", "B_STRPT_HAEM", "B_STRPT_GRPA")
)
})
+12
View File
@@ -54,4 +54,16 @@ test_that("test-translate.R", {
expect_identical(mo_fullname("CoNS", "zh"), "凝固酶阴性葡萄球菌 (CoNS)")
expect_error(mo_fullname("CoNS", "aa"))
# a translation is never translated again, such as "Ticarcillin" to "Ticarcilline" and then to "Ticarcillinee"
expect_identical(ab_name("TCC", language = "nl"), "Ticarcilline/clavulaanzuur")
expect_identical(ab_name("TCC", language = "fr"), "Ticarcilline/acide clavulanique")
expect_identical(ab_name(c("RIF", "PEN"), language = "it"), c("Rifampicina", "Benzilpenicillina"))
expect_identical(ab_name("AKF", language = "nl"), "Amikacine/fosfomycin")
expect_identical(AMR:::translate_into_language(c("Syndromic Group", "Streptococcus Group A", "Salmonella group B", "biogroup 1"), language = "fr"), c("Groupe syndromique", "Streptococcus Groupe A", "Salmonella groupe B", "biogroupe 1"))
expect_identical(mo_name(c("B_STRPT_GRPA", "B_SLMNL_GRPB"), language = "fr"), c("Streptococcus groupe A", "Salmonella groupe B"))
for (lang in setdiff(AMR:::LANGUAGES_SUPPORTED, "en")) {
translated <- AMR:::translate_into_language(AMR::antimicrobials$name, language = lang, only_affect_ab_names = TRUE)
expect_false(any(translated %like_case% "(cillinee|mycinee|cinaa|cillinaa)"), info = lang)
}
})