mirror of
https://github.com/msberends/AMR.git
synced 2026-05-14 03:10:50 +02:00
Revert mo_matching_score.R; fix #288 in mo.R pre-filter instead
Issue #288: when the abbreviated-genus pre-filter (≤3 char genus) yields exactly one candidate whose species (and subspecies) word(s) exactly match the input, narrow filtr to that single candidate and set minimum_matching_score = 0. This bypasses the automatic 0.55 cutoff that only runs in the is.null() branch, so "S. apiospermum" resolves to Scedosporium apiospermum without touching the validated scoring formula. https://claude.ai/code/session_01VH4Ju4Xq9aW1AHuoVbjGEo
This commit is contained in:
12
R/mo.R
12
R/mo.R
@@ -352,6 +352,18 @@ as.mo <- function(x,
|
||||
(MO_lookup_current$species_first == substr(x_parts[2], 1, 1) |
|
||||
MO_lookup_current$subspecies_first == substr(x_parts[2], 1, 1) |
|
||||
MO_lookup_current$subspecies_first == substr(x_parts[3], 1, 1)))
|
||||
# Issue #288: if the species (and subspecies) word(s) in the input exactly match
|
||||
# exactly one candidate, use only that candidate and bypass the 0.55 cutoff.
|
||||
# This prevents prevalent bacteria from outranking a rarer organism whose species
|
||||
# epithet is an unambiguous exact match, e.g. "S. apiospermum" → Scedosporium.
|
||||
sp_exact <- tolower(MO_lookup_current$species[filtr]) == x_parts[2]
|
||||
if (length(x_parts) == 3) {
|
||||
sp_exact <- sp_exact & tolower(MO_lookup_current$subspecies[filtr]) == x_parts[3]
|
||||
}
|
||||
if (sum(sp_exact) == 1) {
|
||||
filtr <- filtr[sp_exact]
|
||||
minimum_matching_score <- 0
|
||||
}
|
||||
} else {
|
||||
filtr <- which(MO_lookup_current$full_first == substr(x_parts[1], 1, 1) |
|
||||
MO_lookup_current$species_first == substr(x_parts[2], 1, 1) |
|
||||
|
||||
Reference in New Issue
Block a user