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