blob: 56b576f42b7e2f4c6b1562661d831aa9e53e9b30 [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)
Marc Kupietzfc340302019-11-14 12:09:03 +01007library(plotly)
Marc Kupietze457d992019-09-29 18:17:05 +02008
Marc Kupietzfc340302019-11-14 12:09:03 +01009freqPerYear <- function(query, kco = new("KorAPConnection", verbose = TRUE)) {
10 g <- data.frame(year = 2000:2018) %>%
11 cbind(frequencyQuery(kco, query, sprintf("pubDate in %d", .$year))) %>%
12 { . ->> df } %>%
13 ipm() %>%
14 ggplot(aes(year, ipm)) +
15 geom_freq_by_year_ci() +
Marc Kupietze457d992019-09-29 18:17:05 +020016 xlab("TIME") +
Marc Kupietzfc340302019-11-14 12:09:03 +010017 ylab(sprintf("Observed frequency/million of \u201c%s\u201d", query))
18 p <- RKorAPClient::ggplotly(g)
19 print(p)
Marc Kupietze457d992019-09-29 18:17:05 +020020 df
21}
22#df <- freqPerYear("Car-Bikini")
23#df <- freqPerYear("[tt/p=ART & opennlp/p=ART] [tt/l=teilweise] [tt/p=NN]")
24df <- freqPerYear("Buschzulage")
25