Always select textSigle in corpus queries
Resolves #24
Change-Id: Iba859868b3e21ad3fb3d840f92441e65369a2f86
diff --git a/R/KorAPQuery.R b/R/KorAPQuery.R
index adc4024..db5ad6f 100644
--- a/R/KorAPQuery.R
+++ b/R/KorAPQuery.R
@@ -185,6 +185,9 @@
if (metadataOnly) {
fields <- fields[!fields %in% contentFields]
}
+ if (!"textSigle" %in% fields) {
+ fields <- c(fields, "textSigle")
+ }
request <-
paste0('?q=',
url_encode(enc2utf8(query)),
diff --git a/tests/testthat/test-corpusQuery.R b/tests/testthat/test-corpusQuery.R
index 82011f4..f80a825 100644
--- a/tests/testthat/test-corpusQuery.R
+++ b/tests/testthat/test-corpusQuery.R
@@ -188,4 +188,24 @@
expect_gt(min(nchar(df$KED.rcpnt)), 5)
})
+test_that("corpusQuery token API works when textSigle field is deselected", {
+ skip_if_offline()
+ kco <- new("KorAPConnection", accessToken = NULL, verbose = TRUE)
+ q <- corpusQuery(kco, "focus([tt/p=ADJA] {Newstickeritis})",
+ vc = "corpusSigle=/W.D17/",
+ fields = c("tokens"),
+ metadataOnly = FALSE)
+ q <- fetchNext(q)
+ matches <-q@collectedMatches
+ expect_gt(nrow(matches), 10)
+ unique_matches <- unique(matches$tokens$match)
+ expect_equal(length(unique_matches), 1)
+ expect_equal(unique_matches[[1]], "Newstickeritis")
+
+ left_contexts <- matches$tokens$left
+ expect_true(TRUE %in% grepl("reine", left_contexts))
+
+ right_contexts <- matches$tokens$right
+ expect_true(TRUE %in% grepl("Begriff", right_contexts))
+})