blob: c0412ba78a7f35af755b62760e22870a829fb814 [file] [log] [blame]
Marc Kupietz5d9e3a22020-03-23 09:03:29 +01001test_that("Alternatives over time highcharter example works", {
Marc Kupietz06f35962020-06-04 18:50:55 +02002 year <- c(2013:2018)
Marc Kupietz5d9e3a22020-03-23 09:03:29 +01003 alternatives <- c("macht []{0,3} Sinn", "ergibt []{0,3} Sinn")
Marc Kupietz5d9e3a22020-03-23 09:03:29 +01004 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
14test_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
28test_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
42test_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
56test_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 Kupietz06f35962020-06-04 18:50:55 +020061 year = (2011:2013)
Marc Kupietz5d9e3a22020-03-23 09:03:29 +010062 ) %>%
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
72test_that("Single condition over time highcharter example works", {
73 kco <- new("KorAPConnection", verbose=TRUE)
74 hc <- expand_grid(
75 condition = c("textDomain = /Wirtschaft.*/"),
Marc Kupietz06f35962020-06-04 18:50:55 +020076 year = (2011:2013)
Marc Kupietz5d9e3a22020-03-23 09:03:29 +010077 ) %>%
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
87test_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 Kupietz06f35962020-06-04 18:50:55 +020092 year = (2011:2013)
Marc Kupietz5d9e3a22020-03-23 09:03:29 +010093 ) %>%
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
103test_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 Kupietz06f35962020-06-04 18:50:55 +0200109 year = (2011:2013)
Marc Kupietz5d9e3a22020-03-23 09:03:29 +0100110 ) %>%
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 Kupietz8cc6fd62021-03-05 10:49:48 +0100119
120test_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})