Marc Kupietz | dbd431a | 2021-08-29 12:17:45 +0200 | [diff] [blame] | 1 | test_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 | |
| 12 | test_that("collocationAnalysis works", { |
Marc Kupietz | a3fedbe | 2021-09-04 20:24:03 +0200 | [diff] [blame] | 13 | kco <- new("KorAPConnection", |
| 14 | accessToken = NULL, |
| 15 | verbose = TRUE) |
| 16 | df <- |
| 17 | collocationAnalysis( |
| 18 | kco, |
| 19 | "focus([tt/p=ADJA] {Newstickeritis})", |
| 20 | vc = "corpusSigle=/W.D17/", |
| 21 | leftContextSize = 1, |
| 22 | rightContextSize = 0, |
| 23 | searchHitsSampleLimit = 100, |
| 24 | topCollocatesLimit = 1, |
| 25 | exactFrequencies = FALSE |
| 26 | ) |
Marc Kupietz | dbd431a | 2021-08-29 12:17:45 +0200 | [diff] [blame] | 27 | expect_gt(df$O, df$E) |
| 28 | expect_gt(df$logDice, 1) |
| 29 | }) |
| 30 | |
| 31 | test_that("collocationAnalysis on unaccounted strings does not error out", { |
| 32 | kco <- new("KorAPConnection", cache = TRUE, verbose = TRUE) |
| 33 | df <- collocationAnalysis(kco, "XXXXXXXXAmeisenplage") |
| 34 | testthat::expect_equal(nrow(df), 0) |
| 35 | }) |