blob: aadd0d2ff3cc49d17a61bc6c536ef0ac2e76cda4 [file] [log] [blame]
Marc Kupietze457d992019-09-29 18:17:05 +02001#!/usr/bin/env Rscript
2#
3# Plot frequency of query expressions over time
4#
5library(RKorAPClient)
6library(ggplot2)
7
Marc Kupietzfc340302019-11-14 12:09:03 +01008freqPerYear <- function(query, kco = new("KorAPConnection", verbose = TRUE)) {
9 g <- data.frame(year = 2000:2018) %>%
10 cbind(frequencyQuery(kco, query, sprintf("pubDate in %d", .$year))) %>%
11 { . ->> df } %>%
12 ipm() %>%
13 ggplot(aes(year, ipm)) +
14 geom_freq_by_year_ci() +
Marc Kupietze457d992019-09-29 18:17:05 +020015 xlab("TIME") +
Marc Kupietzfc340302019-11-14 12:09:03 +010016 ylab(sprintf("Observed frequency/million of \u201c%s\u201d", query))
Marc Kupietz5fb892e2021-03-05 08:18:25 +010017 print(g)
Marc Kupietze457d992019-09-29 18:17:05 +020018 df
19}
20#df <- freqPerYear("Car-Bikini")
21#df <- freqPerYear("[tt/p=ART & opennlp/p=ART] [tt/l=teilweise] [tt/p=NN]")
22df <- freqPerYear("Buschzulage")
23