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) |
Marc Kupietz | fc34030 | 2019-11-14 12:09:03 +0100 | [diff] [blame] | 7 | library(plotly) |
Marc Kupietz | e457d99 | 2019-09-29 18:17:05 +0200 | [diff] [blame] | 8 | |
Marc Kupietz | fc34030 | 2019-11-14 12:09:03 +0100 | [diff] [blame] | 9 | freqPerYear <- 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 Kupietz | e457d99 | 2019-09-29 18:17:05 +0200 | [diff] [blame] | 16 | xlab("TIME") + |
Marc Kupietz | fc34030 | 2019-11-14 12:09:03 +0100 | [diff] [blame] | 17 | ylab(sprintf("Observed frequency/million of \u201c%s\u201d", query)) |
| 18 | p <- RKorAPClient::ggplotly(g) |
| 19 | print(p) |
Marc Kupietz | e457d99 | 2019-09-29 18:17:05 +0200 | [diff] [blame] | 20 | df |
| 21 | } |
| 22 | #df <- freqPerYear("Car-Bikini") |
| 23 | #df <- freqPerYear("[tt/p=ART & opennlp/p=ART] [tt/l=teilweise] [tt/p=NN]") |
| 24 | df <- freqPerYear("Buschzulage") |
| 25 | |