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

(v1.4.0.9031) as.ab() fix

This commit is contained in:
2020-12-03 22:30:14 +01:00
parent e03b3c96d3
commit fdf29e6c5b
15 changed files with 41 additions and 24 deletions

6
R/ab.R
View File

@ -153,7 +153,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
}
if (isTRUE(flag_multiple_results) & x[i] %like% "[ ]") {
from_text <- suppressWarnings(ab_from_text(x[i], initial_search = FALSE, translate_ab = FALSE)[[1]])
from_text <- tryCatch(suppressWarnings(ab_from_text(x[i], initial_search = FALSE, translate_ab = FALSE)[[1]]),
error = function(e) character(0))
} else {
from_text <- character(0)
}
@ -345,7 +346,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
if (isTRUE(flag_multiple_results)) {
found <- from_text[1L]
} else {
found <- suppressWarnings(ab_from_text(x[i], initial_search = FALSE, translate_ab = FALSE)[[1]][1L])
found <- tryCatch(suppressWarnings(ab_from_text(x[i], initial_search = FALSE, translate_ab = FALSE)[[1]][1L]),
error = function(e) NA_character_)
}
if (!is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text)