Add as.alternative parameter to frequencyQuery method
And also rename "tokens" to the more generic "total" in the result
tibble.
Change-Id: Iae2ec16307f993e5b95792f2f66c6a38dc9ff67d
diff --git a/demo/alternativesOverTime.R b/demo/alternativesOverTime.R
index dca55b3..eb85ac8 100755
--- a/demo/alternativesOverTime.R
+++ b/demo/alternativesOverTime.R
@@ -9,9 +9,7 @@
alternativesOverTime <- function(alternatives, years, kco = new("KorAPConnection", verbose=TRUE)) {
df <- expand_grid(Variant = alternatives, year = years) %>%
- cbind(corpusQuery(kco, .$Variant, sprintf("textType = /Zeit.*/ & pubDate in %d", .$year))) %>%
- group_by(year) %>% mutate(tokens = sum(totalResults)) %>%
- ci() %>%
+ cbind(frequencyQuery(kco, .$Variant, sprintf("textType = /Zeit.*/ & pubDate in %d", .$year), as.alternatives=TRUE)) %>%
rename(share=f)
g <- ggplot(data = df, mapping = aes(x = year, y = share, colour = Variant, fill = Variant)) +
geom_freq_by_year_ci() +
diff --git a/demo/frequenciesOverDomains.R b/demo/frequenciesOverDomains.R
index a991e25..cf02649 100755
--- a/demo/frequenciesOverDomains.R
+++ b/demo/frequenciesOverDomains.R
@@ -13,7 +13,7 @@
group_by(Domain) %>%
dplyr::filter(!is.na(Domain)) %>%
summarise(count = dplyr::n()) %>%
- mutate(tokens = (corpusStats(con, sprintf("textClass = /%s.*/", .$Domain)))$tokens) %>%
+ mutate(total = (corpusStats(con, sprintf("textClass = /%s.*/", .$Domain)))$tokens) %>%
ci(x = count) %>%
ipm() %>%
{ df <<- . } %>%