Skip to content

Commit cd17a92

Browse files
committed
Remove hardcode arguments to control() from control_ci()
1 parent 6c09964 commit cd17a92

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

NEWS.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# controller 0.0.0.9000
22

3-
* Adds `control()`, `control_ci()`, `control_fuzzy_boundary()` and
4-
`control_fuzzy_encoding()`
3+
* Adds `control()`, `control_ci()`, and `control_fuzzy()`
54
* Adds example dataset `colour_thesaurus`
65
* Adds `read_fish()`
76
* Adds a `NEWS.md` file to track changes to the package.

R/control.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@
3232
#' that couldn't be matched in `thesaurus`.
3333
#' @param coalesce If `TRUE` (the default), return only the closest matches in
3434
#' `x`. If `FALSE`, return all matches.
35-
#' @param ... For `control_ci()` and `control_fuzzy`, other arguments passed to
36-
#' `control()`.
35+
#' @param ... For `control_ci()` and `control_fuzzy()`, other arguments passed
36+
#' to `control()`. This includes fuzzy matching options (`fuzzy_boundary`,
37+
#' `fuzzy_encoding`) and output options (`quiet`, `warn_unmatched`,
38+
#' `coalesce`).
3739
#'
3840
#' @return
3941
#' If `coalesce = TRUE` (the default), a vector the same length as `x` with
@@ -158,8 +160,7 @@ control <- function(x, thesaurus,
158160
#' @rdname control
159161
#' @export
160162
control_ci <- function(x, thesaurus, thesaurus_cols = c(1, 2), ...) {
161-
control(x, thesaurus, thesaurus_cols, case_insensitive = TRUE,
162-
fuzzy_boundary = FALSE, fuzzy_encoding = FALSE, ...)
163+
control(x, thesaurus, thesaurus_cols, case_insensitive = TRUE, ...)
163164
}
164165

165166
#' @rdname control

tests/testthat/test-control.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,21 @@ test_that("control_fuzzy() combines all matching strategies", {
104104
c("foo bar", "foo bar", "baz")
105105
)
106106
})
107+
108+
test_that("control_ci() accepts fuzzy matching arguments", {
109+
df <- data.frame(canon = "foo bar", variant = "foo-bar")
110+
expect_equal(
111+
control_ci(c("foo bar", "foo_bar"), df,
112+
fuzzy_boundary = TRUE, quiet = TRUE, warn_unmatched = FALSE),
113+
c("foo bar", "foo bar")
114+
)
115+
})
116+
117+
test_that("control_ci() defaults to exact matching only", {
118+
df <- data.frame(canon = "foo bar", variant = "foo-bar")
119+
expect_equal(
120+
control_ci(c("foo bar", "foo_bar"), df,
121+
quiet = TRUE, warn_unmatched = FALSE),
122+
c("foo bar", "foo_bar")
123+
)
124+
})

0 commit comments

Comments
 (0)