Marc Kupietz | 5d9e3a2 | 2020-03-23 09:03:29 +0100 | [diff] [blame] | 1 | test_that("Alternatives over time highcharter example works", { |
Marc Kupietz | 06f3596 | 2020-06-04 18:50:55 +0200 | [diff] [blame] | 2 | year <- c(2013:2018) |
Marc Kupietz | 5d9e3a2 | 2020-03-23 09:03:29 +0100 | [diff] [blame] | 3 | alternatives <- c("macht []{0,3} Sinn", "ergibt []{0,3} Sinn") |
Marc Kupietz | 5d9e3a2 | 2020-03-23 09:03:29 +0100 | [diff] [blame] | 4 | hc <- new("KorAPConnection", verbose = TRUE) %>% |
| 5 | frequencyQuery( |
| 6 | query = alternatives, |
| 7 | vc = paste("textType = /Zeit.*/ & pubDate in", year), |
| 8 | as.alternatives = TRUE |
| 9 | ) %>% |
| 10 | hc_freq_by_year_ci(as.alternatives = TRUE) |
| 11 | expect_true(all(class(hc) %in% c("highchart", "htmlwidget"))) |
| 12 | }) |
| 13 | |
| 14 | test_that("Multiple queries over time highcharter example works", { |
| 15 | year <- c(2013:2018) |
| 16 | alternatives <- c("macht []{0,3} Sinn", "ergibt []{0,3} Sinn") |
| 17 | |
| 18 | hc <- new("KorAPConnection", verbose = TRUE) %>% |
| 19 | frequencyQuery( |
| 20 | query = alternatives, |
| 21 | vc = paste("textType = /Zeit.*/ & pubDate in", year), |
| 22 | as.alternatives = FALSE |
| 23 | ) %>% |
| 24 | hc_freq_by_year_ci(as.alternatives = FALSE) |
| 25 | expect_true(all(class(hc) %in% c("highchart", "htmlwidget"))) |
| 26 | }) |
| 27 | |
| 28 | test_that("Single query in multiple over time highcharter example works", { |
| 29 | year <- c(2013:2018) |
| 30 | alternatives <- c("macht []{0,3} Sinn", "ergibt []{0,3} Sinn") |
| 31 | |
| 32 | hc <- new("KorAPConnection", verbose = TRUE) %>% |
| 33 | frequencyQuery( |
| 34 | query = alternatives, |
| 35 | vc = paste("textType = /Zeit.*/ & pubDate in", year), |
| 36 | as.alternatives = FALSE |
| 37 | ) %>% |
| 38 | hc_freq_by_year_ci(as.alternatives = FALSE) |
| 39 | expect_true(all(class(hc) %in% c("highchart", "htmlwidget"))) |
| 40 | }) |
| 41 | |
| 42 | test_that("Single query over time highcharter example works", { |
| 43 | year <- c(2013:2018) |
| 44 | q <- c("macht []{0,3} Sinn") |
| 45 | |
| 46 | hc <- new("KorAPConnection", verbose = TRUE) %>% |
| 47 | frequencyQuery( |
| 48 | query = q, |
| 49 | vc = paste("textType = /Zeit.*/ & pubDate in", year), |
| 50 | as.alternatives = FALSE |
| 51 | ) %>% |
| 52 | hc_freq_by_year_ci(as.alternatives = FALSE) |
| 53 | expect_true(all(class(hc) %in% c("highchart", "htmlwidget"))) |
| 54 | }) |
| 55 | |
| 56 | test_that("Auto conditions over time highcharter example works", { |
| 57 | kco <- new("KorAPConnection", verbose=TRUE) |
| 58 | hc <- expand_grid( |
| 59 | myconditions = c("textDomain = /Wirtschaft.*/", |
| 60 | "textDomain != /Wirtschaft.*/"), |
Marc Kupietz | 06f3596 | 2020-06-04 18:50:55 +0200 | [diff] [blame] | 61 | year = (2011:2013) |
Marc Kupietz | 5d9e3a2 | 2020-03-23 09:03:29 +0100 | [diff] [blame] | 62 | ) %>% |
| 63 | cbind(frequencyQuery( |
| 64 | kco, |
| 65 | c("[tt/l=Heuschrecke]", "Ameise"), |
| 66 | paste(.$myconditions, "& pubDate in", .$year) |
| 67 | )) %>% |
| 68 | hc_freq_by_year_ci() |
| 69 | expect_true(all(class(hc) %in% c("highchart", "htmlwidget"))) |
| 70 | }) |
| 71 | |
| 72 | test_that("Single condition over time highcharter example works", { |
| 73 | kco <- new("KorAPConnection", verbose=TRUE) |
| 74 | hc <- expand_grid( |
| 75 | condition = c("textDomain = /Wirtschaft.*/"), |
Marc Kupietz | 06f3596 | 2020-06-04 18:50:55 +0200 | [diff] [blame] | 76 | year = (2011:2013) |
Marc Kupietz | 5d9e3a2 | 2020-03-23 09:03:29 +0100 | [diff] [blame] | 77 | ) %>% |
| 78 | cbind(frequencyQuery( |
| 79 | kco, |
| 80 | c("[tt/l=Heuschrecke]", "Ameise"), |
| 81 | paste(.$condition, "& pubDate in", .$year), |
| 82 | )) %>% |
| 83 | hc_freq_by_year_ci() |
| 84 | expect_true(all(class(hc) %in% c("highchart", "htmlwidget"))) |
| 85 | }) |
| 86 | |
| 87 | test_that("Multiple conditions over time highcharter example works", { |
| 88 | kco <- new("KorAPConnection", verbose=TRUE) |
| 89 | hc <- expand_grid( |
| 90 | condition = c("textDomain = /Wirtschaft.*/", |
| 91 | "textDomain != /Wirtschaft.*/"), |
Marc Kupietz | 06f3596 | 2020-06-04 18:50:55 +0200 | [diff] [blame] | 92 | year = (2011:2013) |
Marc Kupietz | 5d9e3a2 | 2020-03-23 09:03:29 +0100 | [diff] [blame] | 93 | ) %>% |
| 94 | cbind(frequencyQuery( |
| 95 | kco, |
| 96 | c("[tt/l=Heuschrecke]", "Ameise"), |
| 97 | paste(.$condition, "& pubDate in", .$year), |
| 98 | )) %>% |
| 99 | hc_freq_by_year_ci() |
| 100 | expect_true(all(class(hc) %in% c("highchart", "htmlwidget"))) |
| 101 | }) |
| 102 | |
| 103 | test_that("Multiple conditions and queries over time highcharter example works", { |
| 104 | kco <- new("KorAPConnection", verbose=TRUE) |
| 105 | hc <- expand_grid( |
| 106 | qx = c("[tt/l=Heuschrecke]", "Ameise"), |
| 107 | condition = c("textDomain = /Wirtschaft.*/", |
| 108 | "textDomain != /Wirtschaft.*/"), |
Marc Kupietz | 06f3596 | 2020-06-04 18:50:55 +0200 | [diff] [blame] | 109 | year = (2011:2013) |
Marc Kupietz | 5d9e3a2 | 2020-03-23 09:03:29 +0100 | [diff] [blame] | 110 | ) %>% |
| 111 | cbind(frequencyQuery( |
| 112 | kco, |
| 113 | .$qx, |
| 114 | paste(.$condition, "& pubDate in", .$year), |
| 115 | )) %>% |
| 116 | hc_freq_by_year_ci() |
| 117 | expect_true(all(class(hc) %in% c("highchart", "htmlwidget"))) |
| 118 | }) |
Marc Kupietz | 8cc6fd6 | 2021-03-05 10:49:48 +0100 | [diff] [blame^] | 119 | |
| 120 | test_that("collocationScoreQuery works iwth hchart and hc_add_onclick_korap_search", { |
| 121 | kco <- new("KorAPConnection", cache = TRUE, verbose = TRUE) |
| 122 | df <- collocationScoreQuery(kco,"Ameisenplage", "heimgesucht", leftContextSize=0, rightContextSize=1) |
| 123 | hc <- hchart(df, type="spline", hcaes(label, logDice)) |
| 124 | hc <- hc_add_onclick_korap_search(hc) |
| 125 | expect_true(all(class(hc) %in% c("highchart", "htmlwidget"))) |
| 126 | }) |