Marc Kupietz | 8cc6fd6 | 2021-03-05 10:49:48 +0100 | [diff] [blame] | 1 | test_that("queryStringToLabel works correctly", { |
| 2 | expect_equivalent(queryStringToLabel( |
| 3 | c( |
| 4 | "referTo=x & textClass = /natur.*/ & creationDate in 2013", |
| 5 | "referTo=x & textClass = /natur.*/ & creationDate in 2014" |
| 6 | ) |
| 7 | ), |
| 8 | c("2013", "2014")) |
| 9 | |
| 10 | expect_equivalent(queryStringToLabel( |
| 11 | c( |
| 12 | "referTo=x & textClass = /natur.*/ & pubDate in 2013", |
| 13 | "referTo=x & textClass = /freizeit.*/ & pubDate in 2014" |
Marc Kupietz | cc8c538 | 2021-12-22 17:23:22 +0100 | [diff] [blame] | 14 | ), |
| 15 | pubDateOnly = T |
Marc Kupietz | 8cc6fd6 | 2021-03-05 10:49:48 +0100 | [diff] [blame] | 16 | ), |
| 17 | c("2013", "2014")) |
| 18 | |
| 19 | expect_equivalent(queryStringToLabel( |
| 20 | c( |
| 21 | "referTo=x & textClass = /natur.*/ & creationDate in 2013", |
| 22 | "referTo=x & textClass = /freizeit.*/ & creationDate in 2014" |
Marc Kupietz | cc8c538 | 2021-12-22 17:23:22 +0100 | [diff] [blame] | 23 | ), |
| 24 | pubDateOnly = T |
Marc Kupietz | 8cc6fd6 | 2021-03-05 10:49:48 +0100 | [diff] [blame] | 25 | ), |
| 26 | c("2013", "2014")) |
| 27 | |
| 28 | expect_equivalent(queryStringToLabel( |
| 29 | c( |
| 30 | "referTo=x & textClass = /natur.*/ & creationDate in 2013", |
| 31 | "referTo=x & textClass = /freizeit.*/ & creationDate in 2014" |
Marc Kupietz | cc8c538 | 2021-12-22 17:23:22 +0100 | [diff] [blame] | 32 | ), |
| 33 | excludePubDate = T |
Marc Kupietz | 8cc6fd6 | 2021-03-05 10:49:48 +0100 | [diff] [blame] | 34 | ), |
| 35 | c("/natur.*/", "/freizeit.*/")) |
| 36 | }) |
Marc Kupietz | cc8c538 | 2021-12-22 17:23:22 +0100 | [diff] [blame] | 37 | |
| 38 | test_that("geom_freq_by_year_ci works correctly", { |
| 39 | df <- |
| 40 | structure( |
| 41 | list( |
| 42 | condition = c( |
| 43 | "textDomain = /Wirtschaft.*/", |
| 44 | "textDomain = /Wirtschaft.*/", |
| 45 | "textDomain = /Wirtschaft.*/", |
| 46 | "textDomain = /Wirtschaft.*/", |
| 47 | "textDomain = /Wirtschaft.*/", |
| 48 | "textDomain = /Wirtschaft.*/", |
| 49 | "textDomain = /Wirtschaft.*/", |
| 50 | "textDomain != /Wirtschaft.*/", |
| 51 | "textDomain != /Wirtschaft.*/", |
| 52 | "textDomain != /Wirtschaft.*/", |
| 53 | "textDomain != /Wirtschaft.*/", |
| 54 | "textDomain != /Wirtschaft.*/", |
| 55 | "textDomain != /Wirtschaft.*/", |
| 56 | "textDomain != /Wirtschaft.*/" |
| 57 | ), |
| 58 | year = c( |
| 59 | 2005L, |
| 60 | 2006L, |
| 61 | 2007L, |
| 62 | 2008L, |
| 63 | 2009L, |
| 64 | 2010L, |
| 65 | 2011L, |
| 66 | 2005L, |
| 67 | 2006L, |
| 68 | 2007L, |
| 69 | 2008L, |
| 70 | 2009L, |
| 71 | 2010L, |
| 72 | 2011L |
| 73 | ), |
| 74 | query = c( |
| 75 | "[tt/l=Heuschrecke]", |
| 76 | "[tt/l=Heuschrecke]", |
| 77 | "[tt/l=Heuschrecke]", |
| 78 | "[tt/l=Heuschrecke]", |
| 79 | "[tt/l=Heuschrecke]", |
| 80 | "[tt/l=Heuschrecke]", |
| 81 | "[tt/l=Heuschrecke]", |
| 82 | "[tt/l=Heuschrecke]", |
| 83 | "[tt/l=Heuschrecke]", |
| 84 | "[tt/l=Heuschrecke]", |
| 85 | "[tt/l=Heuschrecke]", |
| 86 | "[tt/l=Heuschrecke]", |
| 87 | "[tt/l=Heuschrecke]", |
| 88 | "[tt/l=Heuschrecke]" |
| 89 | ), |
| 90 | totalResults = c( |
| 91 | 531L, |
| 92 | 823L, |
| 93 | 1130L, |
| 94 | 496L, |
| 95 | 302L, |
| 96 | 159L, |
| 97 | 122L, |
| 98 | 2831L, |
| 99 | 2245L, |
| 100 | 2477L, |
| 101 | 2010L, |
| 102 | 1697L, |
| 103 | 1142L, |
| 104 | 1829L |
| 105 | ), |
| 106 | vc = c( |
| 107 | "textDomain = /Wirtschaft.*/ & pubDate in 2005", |
| 108 | "textDomain = /Wirtschaft.*/ & pubDate in 2006", |
| 109 | "textDomain = /Wirtschaft.*/ & pubDate in 2007", |
| 110 | "textDomain = /Wirtschaft.*/ & pubDate in 2008", |
| 111 | "textDomain = /Wirtschaft.*/ & pubDate in 2009", |
| 112 | "textDomain = /Wirtschaft.*/ & pubDate in 2010", |
| 113 | "textDomain = /Wirtschaft.*/ & pubDate in 2011", |
| 114 | "textDomain != /Wirtschaft.*/ & pubDate in 2005", |
| 115 | "textDomain != /Wirtschaft.*/ & pubDate in 2006", |
| 116 | "textDomain != /Wirtschaft.*/ & pubDate in 2007", |
| 117 | "textDomain != /Wirtschaft.*/ & pubDate in 2008", |
| 118 | "textDomain != /Wirtschaft.*/ & pubDate in 2009", |
| 119 | "textDomain != /Wirtschaft.*/ & pubDate in 2010", |
| 120 | "textDomain != /Wirtschaft.*/ & pubDate in 2011" |
| 121 | ), |
| 122 | webUIRequestUrl = c( |
| 123 | "https://korapt.ids-mannheim.de/?q=%5btt%2fl%3dHeuschrecke%5d&cq=textDomain%20%3d%20%2fWirtschaft.%2a%2f%20%26%20pubDate%20in%202005&ql=poliqarp", |
| 124 | "https://korapt.ids-mannheim.de/?q=%5btt%2fl%3dHeuschrecke%5d&cq=textDomain%20%3d%20%2fWirtschaft.%2a%2f%20%26%20pubDate%20in%202006&ql=poliqarp", |
| 125 | "https://korapt.ids-mannheim.de/?q=%5btt%2fl%3dHeuschrecke%5d&cq=textDomain%20%3d%20%2fWirtschaft.%2a%2f%20%26%20pubDate%20in%202007&ql=poliqarp", |
| 126 | "https://korapt.ids-mannheim.de/?q=%5btt%2fl%3dHeuschrecke%5d&cq=textDomain%20%3d%20%2fWirtschaft.%2a%2f%20%26%20pubDate%20in%202008&ql=poliqarp", |
| 127 | "https://korapt.ids-mannheim.de/?q=%5btt%2fl%3dHeuschrecke%5d&cq=textDomain%20%3d%20%2fWirtschaft.%2a%2f%20%26%20pubDate%20in%202009&ql=poliqarp", |
| 128 | "https://korapt.ids-mannheim.de/?q=%5btt%2fl%3dHeuschrecke%5d&cq=textDomain%20%3d%20%2fWirtschaft.%2a%2f%20%26%20pubDate%20in%202010&ql=poliqarp", |
| 129 | "https://korapt.ids-mannheim.de/?q=%5btt%2fl%3dHeuschrecke%5d&cq=textDomain%20%3d%20%2fWirtschaft.%2a%2f%20%26%20pubDate%20in%202011&ql=poliqarp", |
| 130 | "https://korapt.ids-mannheim.de/?q=%5btt%2fl%3dHeuschrecke%5d&cq=textDomain%20%21%3d%20%2fWirtschaft.%2a%2f%20%26%20pubDate%20in%202005&ql=poliqarp", |
| 131 | "https://korapt.ids-mannheim.de/?q=%5btt%2fl%3dHeuschrecke%5d&cq=textDomain%20%21%3d%20%2fWirtschaft.%2a%2f%20%26%20pubDate%20in%202006&ql=poliqarp", |
| 132 | "https://korapt.ids-mannheim.de/?q=%5btt%2fl%3dHeuschrecke%5d&cq=textDomain%20%21%3d%20%2fWirtschaft.%2a%2f%20%26%20pubDate%20in%202007&ql=poliqarp", |
| 133 | "https://korapt.ids-mannheim.de/?q=%5btt%2fl%3dHeuschrecke%5d&cq=textDomain%20%21%3d%20%2fWirtschaft.%2a%2f%20%26%20pubDate%20in%202008&ql=poliqarp", |
| 134 | "https://korapt.ids-mannheim.de/?q=%5btt%2fl%3dHeuschrecke%5d&cq=textDomain%20%21%3d%20%2fWirtschaft.%2a%2f%20%26%20pubDate%20in%202009&ql=poliqarp", |
| 135 | "https://korapt.ids-mannheim.de/?q=%5btt%2fl%3dHeuschrecke%5d&cq=textDomain%20%21%3d%20%2fWirtschaft.%2a%2f%20%26%20pubDate%20in%202010&ql=poliqarp", |
| 136 | "https://korapt.ids-mannheim.de/?q=%5btt%2fl%3dHeuschrecke%5d&cq=textDomain%20%21%3d%20%2fWirtschaft.%2a%2f%20%26%20pubDate%20in%202011&ql=poliqarp" |
| 137 | ), |
| 138 | total = c( |
| 139 | 35980430L, |
| 140 | 43834111L, |
| 141 | 45318302L, |
| 142 | 48021215L, |
| 143 | 43445640L, |
| 144 | 37850216L, |
| 145 | 43208130L, |
| 146 | 734690498L, |
| 147 | 754436010L, |
| 148 | 837243512L, |
| 149 | 870913993L, |
| 150 | 840473763L, |
| 151 | 758631859L, |
| 152 | 1650860702L |
| 153 | ), |
| 154 | f = c( |
| 155 | 1.4758022625077e-05, |
| 156 | 1.87753322977167e-05, |
| 157 | 2.49347382874142e-05, |
| 158 | 1.0328768232957e-05, |
| 159 | 6.95121535785869e-06, |
| 160 | 4.20076862969553e-06, |
| 161 | 2.82354269902447e-06, |
| 162 | 3.85332328062857e-06, |
| 163 | 2.97573282590262e-06, |
| 164 | 2.9585179992413e-06, |
| 165 | 2.30792020355103e-06, |
| 166 | 2.0190993160128e-06, |
| 167 | 1.50534147287901e-06, |
| 168 | 1.10790692260358e-06 |
| 169 | ), |
| 170 | conf.low = c( |
| 171 | 13.541726123006, |
| 172 | 17.5246639403598, |
| 173 | 23.5119781061303, |
| 174 | 9.44895282189122, |
| 175 | 6.19934083242504, |
| 176 | 3.58441307384462, |
| 177 | 2.35445121482762, |
| 178 | 3.71330289674541, |
| 179 | 2.85451040064217, |
| 180 | 2.84369529096211, |
| 181 | 2.20864478463198, |
| 182 | 1.92471184006826, |
| 183 | 1.41988948639017, |
| 184 | 1.05798679123886 |
| 185 | ), |
| 186 | conf.high = c( |
| 187 | 16.0822620637798, |
| 188 | 20.1144124716816, |
| 189 | 26.4429033931224, |
| 190 | 11.2894924346856, |
| 191 | 7.79280444795191, |
| 192 | 4.92066150039394, |
| 193 | 3.38358495629102, |
| 194 | 3.9985973655165, |
| 195 | 3.10207445836027, |
| 196 | 3.07795241551153, |
| 197 | 2.41163153037033, |
| 198 | 2.11808565716224, |
| 199 | 1.59589532013765, |
| 200 | 1.1601678685439 |
| 201 | ), |
| 202 | ipm = c( |
| 203 | 14.758022625077, |
| 204 | 18.7753322977167, |
| 205 | 24.9347382874142, |
| 206 | 10.328768232957, |
| 207 | 6.95121535785869, |
| 208 | 4.20076862969553, |
| 209 | 2.82354269902447, |
| 210 | 3.85332328062857, |
| 211 | 2.97573282590262, |
| 212 | 2.9585179992413, |
| 213 | 2.30792020355103, |
| 214 | 2.0190993160128, |
| 215 | 1.50534147287901, |
| 216 | 1.10790692260358 |
| 217 | ) |
| 218 | ), |
| 219 | class = "data.frame", |
| 220 | row.names = c(NA,-14L) |
| 221 | ) |
| 222 | gpt <- df %>% ggplot(aes(year, ipm, fill = condition, color = condition)) + |
| 223 | geom_freq_by_year_ci() |
| 224 | expect_equal(gpt[["labels"]][["url"]], "webUIRequestUrl") |
| 225 | expect_equal(gpt[["data"]][["query"]][14], "[tt/l=Heuschrecke]") |
| 226 | }) |