Marc Kupietz | dbd431a | 2021-08-29 12:17:45 +0200 | [diff] [blame] | 1 | library(RKorAPClient) |
Marc Kupietz | 163a6fa | 2022-09-06 10:54:24 +0200 | [diff] [blame^] | 2 | library(tidyverse) |
Marc Kupietz | dbd431a | 2021-08-29 12:17:45 +0200 | [diff] [blame] | 3 | library(knitr) |
Marc Kupietz | 163a6fa | 2022-09-06 10:54:24 +0200 | [diff] [blame^] | 4 | library(rmarkdown) |
| 5 | |
| 6 | lvLemma <- "nehmen" |
| 7 | |
| 8 | mdFile <- tempfile(lvLemma, fileext = ".md") |
| 9 | |
| 10 | cat(file=mdFile, sprintf("---\ntitle: LVC analysis of %s\n---\n\n", lvLemma)) |
| 11 | |
Marc Kupietz | dbd431a | 2021-08-29 12:17:45 +0200 | [diff] [blame] | 12 | new("KorAPConnection", verbose = TRUE) %>% |
| 13 | collocationAnalysis( |
Marc Kupietz | 163a6fa | 2022-09-06 10:54:24 +0200 | [diff] [blame^] | 14 | sprintf("focus(in [tt/p=NN] {[tt/l=%s]})", lvLemma), |
Marc Kupietz | dbd431a | 2021-08-29 12:17:45 +0200 | [diff] [blame] | 15 | leftContextSize = 1, |
| 16 | rightContextSize = 0, |
| 17 | exactFrequencies = FALSE, |
| 18 | searchHitsSampleLimit = 1000, |
| 19 | topCollocatesLimit = 20 |
| 20 | ) %>% |
Marc Kupietz | 163a6fa | 2022-09-06 10:54:24 +0200 | [diff] [blame^] | 21 | mutate(LVC = sprintf("[in %s %s](%s)", collocate, lvLemma, webUIRequestUrl)) %>% |
Marc Kupietz | dbd431a | 2021-08-29 12:17:45 +0200 | [diff] [blame] | 22 | select(LVC, logDice, pmi, ll) %>% |
| 23 | head(10) %>% |
Marc Kupietz | 163a6fa | 2022-09-06 10:54:24 +0200 | [diff] [blame^] | 24 | kable(format = "pipe", digits = 2) %>% |
| 25 | cat(file = mdFile, sep = "\n", append = TRUE) |
Marc Kupietz | dbd431a | 2021-08-29 12:17:45 +0200 | [diff] [blame] | 26 | |
Marc Kupietz | 163a6fa | 2022-09-06 10:54:24 +0200 | [diff] [blame^] | 27 | rmarkdown::render(mdFile) |
| 28 | browseURL(str_replace(mdFile, "\\.md$", ".html")) |