blob: b97424b81c91699c693b140706e89b572da58cb7 [file] [log] [blame]
Marc Kupietzdbd431a2021-08-29 12:17:45 +02001test_that("collocationScoreQuery works", {
2 kco <- new("KorAPConnection", cache = TRUE, verbose = TRUE)
3 df <- collocationScoreQuery(kco, "Ameisenplage", "heimgesucht", leftContextSize=0, rightContextSize=1)
4 expect_gt(df$logDice, 1)
5 expect_equal(df$ll, ll(df$O1, df$O2, df$O, df$N, df$E, df$w))
6 expect_equal(df$pmi, pmi(df$O1, df$O2, df$O, df$N, df$E, df$w))
7 expect_equal(df$mi2, mi2(df$O1, df$O2, df$O, df$N, df$E, df$w))
8 expect_equal(df$mi3, mi3(df$O1, df$O2, df$O, df$N, df$E, df$w))
9 expect_equal(df$logDice, logDice(df$O1, df$O2, df$O, df$N, df$E, df$w))
10})
11
Marc Kupietz581a29b2021-09-04 20:51:04 +020012
13test_that("collocationAnalysis works and warns about missing token", {
14 kco <- new("KorAPConnection",
15 accessToken = NULL,
16 verbose = TRUE)
17 expect_warning(
18 df <-
19 collocationAnalysis(
20 kco,
21 "focus([tt/p=ADJA] {Newstickeritis})",
22 vc = "corpusSigle=/W.D17/",
23 leftContextSize = 1,
24 rightContextSize = 0,
25 searchHitsSampleLimit = 100,
26 topCollocatesLimit = 1,
27 exactFrequencies = FALSE
28 ),
29 "access token"
Marc Kupietza3fedbe2021-09-04 20:24:03 +020030 )
Marc Kupietzdbd431a2021-08-29 12:17:45 +020031 expect_gt(df$O, df$E)
32 expect_gt(df$logDice, 1)
33})
34
35test_that("collocationAnalysis on unaccounted strings does not error out", {
Marc Kupietz581a29b2021-09-04 20:51:04 +020036 kco <- new("KorAPConnection", accessToken = NULL, verbose = TRUE)
37 expect_warning(
38 df <- collocationAnalysis(kco, "XXXXXXXXAmeisenplage"),
39 "access token"
40 )
Marc Kupietzdbd431a2021-08-29 12:17:45 +020041 testthat::expect_equal(nrow(df), 0)
42})