CA: support named vc list and vcLabel parameter to specify labels
Change-Id: I983e589e9231f678141e8798effcfcc652ca63f5
diff --git a/tests/testthat/test-collocations.R b/tests/testthat/test-collocations.R
index a93ca57..448e061 100644
--- a/tests/testthat/test-collocations.R
+++ b/tests/testthat/test-collocations.R
@@ -245,6 +245,33 @@
expect_true(is.data.frame(result))
})
+test_that("collocationAnalysis honors named vc labels", {
+ skip_if_offline()
+ kco <- KorAPConnection(accessToken = NULL, cache = TRUE, verbose = FALSE)
+
+ named_vc <- c(
+ Western = "textType=/.*Western.*/ & pubDate in 2012",
+ Erotic = "textType=/.*(Erotik|Gay).*/ & pubDate in 2012",
+ Historic = "textType=/.*Historisch.*/ & pubDate in 2012"
+ )
+
+ expect_warning(
+ result <- collocationAnalysis(
+ kco,
+ "[tt/l=treffen]",
+ vc = named_vc,
+ searchHitsSampleLimit = 2,
+ topCollocatesLimit = 2
+ ),
+ "access token"
+ )
+
+ if (nrow(result) > 0) {
+ expect_true("label" %in% colnames(result))
+ expect_setequal(unique(result$label), names(named_vc))
+ }
+})
+
test_that("collocationAnalysis handles stopwords parameter", {
skip_if_offline()
kco <- KorAPConnection(accessToken = NULL, cache = TRUE, verbose = FALSE)