At least touch recursive CA in tests
Change-Id: I8d112d6df4bbde7cfa1f25da3dabd0094273eff5
diff --git a/R/collocationAnalysis.R b/R/collocationAnalysis.R
index d8df60b..36c7460 100644
--- a/R/collocationAnalysis.R
+++ b/R/collocationAnalysis.R
@@ -163,7 +163,7 @@
tibble()
}
}
- if (maxRecurse > 0 & any(!!as.name(thresholdScore) >= threshold)) {
+ if (maxRecurse > 0 & length(result) > 0 && any(!!as.name(thresholdScore) >= threshold)) {
recurseWith <- result %>%
filter(!!as.name(thresholdScore) >= threshold)
result <- collocationAnalysis(
diff --git a/tests/testthat/test-collocations.R b/tests/testthat/test-collocations.R
index 43f39a2..e2d1755 100644
--- a/tests/testthat/test-collocations.R
+++ b/tests/testthat/test-collocations.R
@@ -24,7 +24,8 @@
rightContextSize = 0,
searchHitsSampleLimit = 100,
topCollocatesLimit = 1,
- exactFrequencies = FALSE
+ exactFrequencies = FALSE,
+ maxRecurse = 2
),
"access token"
)
@@ -35,7 +36,7 @@
test_that("collocationAnalysis on unaccounted strings does not error out", {
kco <- new("KorAPConnection", accessToken = NULL, verbose = TRUE)
expect_warning(
- df <- collocationAnalysis(kco, "XXXXXXXXAmeisenplage", vc=c("corpusSigle=/WDD17/", "corpusSigle=/WUD17/")),
+ df <- collocationAnalysis(kco, "XXXXXXXXAmeisenplage", vc=c("corpusSigle=/WDD17/", "corpusSigle=/WUD17/"), maxRecurse = 2),
"access token"
)
testthat::expect_equal(nrow(df), 0)