diff --git a/R/utils.R b/R/utils.R index b920b32..cc48762 100644 --- a/R/utils.R +++ b/R/utils.R @@ -11,40 +11,3 @@ format_num <- function(x) { big.mark = ",", scientific = FALSE, trim = TRUE ) } - -#' @noRd -to_singular <- function(plural) { - # ipcr and wipo are funky exceptions. On assignees and other_references - # we only want to remove the "s", not the "es" - - if (plural == "ipcr") { - singular <- "ipc" - } else if (plural == "wipo") { - singular <- plural - } else if (endsWith(plural, "classes")) { - singular <- sub("es$", "", plural) - } else { - singular <- sub("s$", "", plural) - } - singular -} - - -#' @noRd -to_plural <- function(singular) { - # wipo endpoint returns singular wipo as the entity - - # remove the patent/ and publication/ from nested endpoints when present - singular <- sub("^(patent|publication)/", "", singular) - - if (singular == "ipc") { - plural <- "ipcr" - } else if (singular == "wipo") { - plural <- singular - } else if (endsWith(singular, "s")) { - plural <- paste0(singular, "es") - } else { - plural <- paste0(singular, "s") - } - plural -} diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R deleted file mode 100644 index 88ec753..0000000 --- a/tests/testthat/test-utils.R +++ /dev/null @@ -1,15 +0,0 @@ -context("utils") - -test_that("we can convert endpoints to their plural form and back", { - skip_on_cran() - - eps <- get_endpoints() - z <- vapply(eps, function(x) { - to_singular(to_plural(x)) - }, FUN.VALUE = character(1), USE.NAMES = FALSE) - - # we now need to unnest the endpoints for the comparison to work - unnested_eps <- gsub("^(patent|publication)/", "", eps) - - expect_equal(unnested_eps, z) -})