blob: 51d73c1feb0ecf43b14ffcc1be7cc4a667d4575d [file] [log] [blame]
Marc Kupietzdbd431a2021-08-29 12:17:45 +02001library(RKorAPClient)
Marc Kupietz163a6fa2022-09-06 10:54:24 +02002library(tidyverse)
Marc Kupietzdbd431a2021-08-29 12:17:45 +02003library(knitr)
Marc Kupietz163a6fa2022-09-06 10:54:24 +02004library(rmarkdown)
5
6lvLemma <- "nehmen"
7
8mdFile <- tempfile(lvLemma, fileext = ".md")
9
10cat(file=mdFile, sprintf("---\ntitle: LVC analysis of %s\n---\n\n", lvLemma))
11
Marc Kupietzdbd431a2021-08-29 12:17:45 +020012new("KorAPConnection", verbose = TRUE) %>%
13 collocationAnalysis(
Marc Kupietz163a6fa2022-09-06 10:54:24 +020014 sprintf("focus(in [tt/p=NN] {[tt/l=%s]})", lvLemma),
Marc Kupietzdbd431a2021-08-29 12:17:45 +020015 leftContextSize = 1,
16 rightContextSize = 0,
17 exactFrequencies = FALSE,
18 searchHitsSampleLimit = 1000,
19 topCollocatesLimit = 20
20 ) %>%
Marc Kupietz163a6fa2022-09-06 10:54:24 +020021 mutate(LVC = sprintf("[in %s %s](%s)", collocate, lvLemma, webUIRequestUrl)) %>%
Marc Kupietzdbd431a2021-08-29 12:17:45 +020022 select(LVC, logDice, pmi, ll) %>%
23 head(10) %>%
Marc Kupietz163a6fa2022-09-06 10:54:24 +020024 kable(format = "pipe", digits = 2) %>%
25 cat(file = mdFile, sep = "\n", append = TRUE)
Marc Kupietzdbd431a2021-08-29 12:17:45 +020026
Marc Kupietz163a6fa2022-09-06 10:54:24 +020027rmarkdown::render(mdFile)
28browseURL(str_replace(mdFile, "\\.md$", ".html"))