Marc Kupietz | e457d99 | 2019-09-29 18:17:05 +0200 | [diff] [blame] | 1 | #!/usr/bin/env Rscript |
| 2 | # |
| 3 | # Plot frequency of query expressions over time |
| 4 | # |
| 5 | library(RKorAPClient) |
| 6 | library(ggplot2) |
| 7 | |
Marc Kupietz | fc34030 | 2019-11-14 12:09:03 +0100 | [diff] [blame] | 8 | freqPerYear <- 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 Kupietz | e457d99 | 2019-09-29 18:17:05 +0200 | [diff] [blame] | 15 | xlab("TIME") + |
Marc Kupietz | fc34030 | 2019-11-14 12:09:03 +0100 | [diff] [blame] | 16 | ylab(sprintf("Observed frequency/million of \u201c%s\u201d", query)) |
Marc Kupietz | 5fb892e | 2021-03-05 08:18:25 +0100 | [diff] [blame^] | 17 | print(g) |
Marc Kupietz | e457d99 | 2019-09-29 18:17:05 +0200 | [diff] [blame] | 18 | df |
| 19 | } |
| 20 | #df <- freqPerYear("Car-Bikini") |
| 21 | #df <- freqPerYear("[tt/p=ART & opennlp/p=ART] [tt/l=teilweise] [tt/p=NN]") |
| 22 | df <- freqPerYear("Buschzulage") |
| 23 | |