blob: 1269760c25fcf4028e675bb1bfd78ba3d5145987 [file] [log] [blame]
Marc Kupietz5d9e3a22020-03-23 09:03:29 +01001test_that("Alternatives over time highcharter example works", {
2 year <- c(1990:2018)
3 alternatives <- c("macht []{0,3} Sinn", "ergibt []{0,3} Sinn")
4
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
15test_that("Multiple queries over time highcharter example works", {
16 year <- c(2013:2018)
17 alternatives <- c("macht []{0,3} Sinn", "ergibt []{0,3} Sinn")
18
19 hc <- new("KorAPConnection", verbose = TRUE) %>%
20 frequencyQuery(
21 query = alternatives,
22 vc = paste("textType = /Zeit.*/ & pubDate in", year),
23 as.alternatives = FALSE
24 ) %>%
25 hc_freq_by_year_ci(as.alternatives = FALSE)
26 expect_true(all(class(hc) %in% c("highchart", "htmlwidget")))
27})
28
29test_that("Single query in multiple over time highcharter example works", {
30 year <- c(2013:2018)
31 alternatives <- c("macht []{0,3} Sinn", "ergibt []{0,3} Sinn")
32
33 hc <- new("KorAPConnection", verbose = TRUE) %>%
34 frequencyQuery(
35 query = alternatives,
36 vc = paste("textType = /Zeit.*/ & pubDate in", year),
37 as.alternatives = FALSE
38 ) %>%
39 hc_freq_by_year_ci(as.alternatives = FALSE)
40 expect_true(all(class(hc) %in% c("highchart", "htmlwidget")))
41})
42
43test_that("Single query over time highcharter example works", {
44 year <- c(2013:2018)
45 q <- c("macht []{0,3} Sinn")
46
47 hc <- new("KorAPConnection", verbose = TRUE) %>%
48 frequencyQuery(
49 query = q,
50 vc = paste("textType = /Zeit.*/ & pubDate in", year),
51 as.alternatives = FALSE
52 ) %>%
53 hc_freq_by_year_ci(as.alternatives = FALSE)
54 expect_true(all(class(hc) %in% c("highchart", "htmlwidget")))
55})
56
57test_that("Auto conditions over time highcharter example works", {
58 kco <- new("KorAPConnection", verbose=TRUE)
59 hc <- expand_grid(
60 myconditions = c("textDomain = /Wirtschaft.*/",
61 "textDomain != /Wirtschaft.*/"),
62 year = (2009:2013)
63 ) %>%
64 cbind(frequencyQuery(
65 kco,
66 c("[tt/l=Heuschrecke]", "Ameise"),
67 paste(.$myconditions, "& pubDate in", .$year)
68 )) %>%
69 hc_freq_by_year_ci()
70 expect_true(all(class(hc) %in% c("highchart", "htmlwidget")))
71})
72
73test_that("Single condition over time highcharter example works", {
74 kco <- new("KorAPConnection", verbose=TRUE)
75 hc <- expand_grid(
76 condition = c("textDomain = /Wirtschaft.*/"),
77 year = (2009:2013)
78 ) %>%
79 cbind(frequencyQuery(
80 kco,
81 c("[tt/l=Heuschrecke]", "Ameise"),
82 paste(.$condition, "& pubDate in", .$year),
83 )) %>%
84 hc_freq_by_year_ci()
85 expect_true(all(class(hc) %in% c("highchart", "htmlwidget")))
86})
87
88test_that("Multiple conditions over time highcharter example works", {
89 kco <- new("KorAPConnection", verbose=TRUE)
90 hc <- expand_grid(
91 condition = c("textDomain = /Wirtschaft.*/",
92 "textDomain != /Wirtschaft.*/"),
93 year = (2009:2013)
94 ) %>%
95 cbind(frequencyQuery(
96 kco,
97 c("[tt/l=Heuschrecke]", "Ameise"),
98 paste(.$condition, "& pubDate in", .$year),
99 )) %>%
100 hc_freq_by_year_ci()
101 expect_true(all(class(hc) %in% c("highchart", "htmlwidget")))
102})
103
104test_that("Multiple conditions and queries over time highcharter example works", {
105 kco <- new("KorAPConnection", verbose=TRUE)
106 hc <- expand_grid(
107 qx = c("[tt/l=Heuschrecke]", "Ameise"),
108 condition = c("textDomain = /Wirtschaft.*/",
109 "textDomain != /Wirtschaft.*/"),
110 year = (2009:2013)
111 ) %>%
112 cbind(frequencyQuery(
113 kco,
114 .$qx,
115 paste(.$condition, "& pubDate in", .$year),
116 )) %>%
117 hc_freq_by_year_ci()
118 expect_true(all(class(hc) %in% c("highchart", "htmlwidget")))
119})
120
121test_that("Conditions over time ggplotly example works", {
122 kco <- new("KorAPConnection")
123 p <- expand_grid(
124 condition = c("textDomain = /Wirtschaft.*/",
125 "textDomain != /Wirtschaft.*/"),
126 year = (2009:2013)
127 ) %>%
128 cbind(frequencyQuery(
129 kco,
130 "[tt/l=Heuschrecke]",
131 paste(.$condition, "& pubDate in", .$year)
132 )) %>%
133 ipm() %>%
134 ggplot(aes(
135 x = year,
136 y = ipm,
137 fill = condition,
138 colour = condition
139 )) +
140 geom_freq_by_year_ci()
141 pp <- ggplotly(p)
142 expect_error(print(pp), NA)
143})