blob: 4ef8fa91f6a6578a6553c4132e422411cec5cc89 [file] [log] [blame]
Marc Kupietz381cb982023-05-13 15:06:32 +02001library(RKorAPClient)
2library(httr2)
3library(kableExtra)
4
5demo_kor_app_id = "773NHGM76N7P9b6rLfmpM4"
6
7oauthorizeDemo <- function(kco, app_id = demo_kor_app_id) {
8 if (is.null(kco@accessToken) || is.null(kco@welcome)) { # if access token is not set or invalid
9 kco@accessToken <- ( # request one
10 oauth_client(
11 id = app_id, # for the demo application
12 token_url = paste0(kco@apiUrl, "oauth2/token")
13 ) %>%
14 oauth_flow_auth_code(
15 scope = "search match_info",
16 auth_url = paste0(kco@KorAPUrl, "settings/oauth/authorize")
17 )
18 )$access_token
19 }
20 print(kco@accessToken)
21 return(kco)
22}
23
24new("KorAPConnection", verbose = TRUE) %>%
25 oauthorizeDemo() %>%
26 collocationAnalysis("focus([marmot/p=ADJA] {Gendern})", leftContextSize=1, rightContextSize=0) %>%
27 mutate(collocate = paste0('<a href="', webUIRequestUrl, '">', collocate, '</a>')) %>%
28 select(collocate, O, pmi, mi2, mi3, logDice, ll) %>%
29 kable(escape = FALSE, caption = "Adjective collocates of 'Gendern'") %>%
30 kable_styling() %>%
31 print()
32