blob: b51a4cd66ba21e44562306c97b5802a7ad68c6d3 [file] [log] [blame]
Marc Kupietz5d9e3a22020-03-23 09:03:29 +01001test_that("Alternatives over time highcharter example works", {
Marc Kupietz83d0af32022-02-24 12:49:28 +01002 skip_if_offline()
Marc Kupietz06f35962020-06-04 18:50:55 +02003 year <- c(2013:2018)
Marc Kupietz5d9e3a22020-03-23 09:03:29 +01004 alternatives <- c("macht []{0,3} Sinn", "ergibt []{0,3} Sinn")
Marc Kupietz5d9e3a22020-03-23 09:03:29 +01005 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", {
Marc Kupietz83d0af32022-02-24 12:49:28 +010016 skip_if_offline()
Marc Kupietz5d9e3a22020-03-23 09:03:29 +010017 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
30test_that("Single query in multiple over time highcharter example works", {
Marc Kupietz83d0af32022-02-24 12:49:28 +010031 skip_if_offline()
Marc Kupietz5d9e3a22020-03-23 09:03:29 +010032 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
45test_that("Single query over time highcharter example works", {
Marc Kupietz83d0af32022-02-24 12:49:28 +010046 skip_if_offline()
Marc Kupietz5d9e3a22020-03-23 09:03:29 +010047 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
60test_that("Auto conditions over time highcharter example works", {
Marc Kupietz83d0af32022-02-24 12:49:28 +010061 skip_if_offline()
Marc Kupietz5d9e3a22020-03-23 09:03:29 +010062 kco <- new("KorAPConnection", verbose=TRUE)
63 hc <- expand_grid(
64 myconditions = c("textDomain = /Wirtschaft.*/",
65 "textDomain != /Wirtschaft.*/"),
Marc Kupietz06f35962020-06-04 18:50:55 +020066 year = (2011:2013)
Marc Kupietz5d9e3a22020-03-23 09:03:29 +010067 ) %>%
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
77test_that("Single condition over time highcharter example works", {
Marc Kupietz83d0af32022-02-24 12:49:28 +010078 skip_if_offline()
Marc Kupietz5d9e3a22020-03-23 09:03:29 +010079 kco <- new("KorAPConnection", verbose=TRUE)
80 hc <- expand_grid(
81 condition = c("textDomain = /Wirtschaft.*/"),
Marc Kupietz06f35962020-06-04 18:50:55 +020082 year = (2011:2013)
Marc Kupietz5d9e3a22020-03-23 09:03:29 +010083 ) %>%
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
93test_that("Multiple conditions over time highcharter example works", {
Marc Kupietz83d0af32022-02-24 12:49:28 +010094 skip_if_offline()
Marc Kupietz5d9e3a22020-03-23 09:03:29 +010095 kco <- new("KorAPConnection", verbose=TRUE)
96 hc <- expand_grid(
97 condition = c("textDomain = /Wirtschaft.*/",
98 "textDomain != /Wirtschaft.*/"),
Marc Kupietz06f35962020-06-04 18:50:55 +020099 year = (2011:2013)
Marc Kupietz5d9e3a22020-03-23 09:03:29 +0100100 ) %>%
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
110test_that("Multiple conditions and queries over time highcharter example works", {
Marc Kupietz83d0af32022-02-24 12:49:28 +0100111 skip_if_offline()
Marc Kupietz5d9e3a22020-03-23 09:03:29 +0100112 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 Kupietz06f35962020-06-04 18:50:55 +0200117 year = (2011:2013)
Marc Kupietz5d9e3a22020-03-23 09:03:29 +0100118 ) %>%
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 Kupietz8cc6fd62021-03-05 10:49:48 +0100127
Marc Kupietz83d0af32022-02-24 12:49:28 +0100128test_that("collocationScoreQuery works with hchart and hc_add_onclick_korap_search", {
129 skip_if_offline()
Marc Kupietz8cc6fd62021-03-05 10:49:48 +0100130 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})