1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-13 02:32:07 +02:00

expert rules 12.0

This commit is contained in:
2022-11-14 15:20:39 +01:00
parent 7ca44fb756
commit f6862a139d
35 changed files with 433 additions and 128 deletions

12
R/ab.R
View File

@ -132,7 +132,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
x_unknown_ATCs <- character(0)
note_if_more_than_one_found <- function(found, index, from_text) {
if (initial_search == TRUE && isTRUE(length(from_text) > 1)) {
if (isTRUE(initial_search) && isTRUE(length(from_text) > 1)) {
abnames <- ab_name(from_text, tolower = TRUE, initial_search = FALSE)
if (ab_name(found[1L], language = NULL) %like% "(clavulanic acid|avibactam)") {
abnames <- abnames[!abnames %in% c("clavulanic acid", "avibactam")]
@ -175,13 +175,13 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
x_new[is.na(x)] <- NA
already_known[is.na(x)] <- FALSE
if (initial_search == TRUE && sum(already_known) < length(x)) {
if (isTRUE(initial_search) && sum(already_known) < length(x)) {
progress <- progress_ticker(n = sum(!already_known), n_min = 25, print = info) # start if n >= 25
on.exit(close(progress))
}
for (i in which(!already_known)) {
if (initial_search == TRUE) {
if (isTRUE(initial_search)) {
progress$tick()
}
@ -316,7 +316,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
# INITIAL SEARCH - More uncertain results ----
if (initial_search == TRUE && fast_mode == FALSE) {
if (isTRUE(initial_search) && fast_mode == FALSE) {
# only run on first try
# try by removing all spaces
@ -487,12 +487,12 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1])
}
if (initial_search == TRUE && sum(already_known) < length(x)) {
if (isTRUE(initial_search) && sum(already_known) < length(x)) {
close(progress)
}
# save to package env to save time for next time
if (initial_search == TRUE) {
if (isTRUE(initial_search)) {
AMR_env$ab_previously_coerced <- AMR_env$ab_previously_coerced[which(!AMR_env$ab_previously_coerced$x %in% x), , drop = FALSE]
AMR_env$ab_previously_coerced <- unique(rbind(AMR_env$ab_previously_coerced,
data.frame(