blob: 4da6540aeb50c184a18e0c496152fd361e1f1265 [file] [log] [blame]
Marc Kupietz0bb21522020-02-04 11:27:25 +01001library(RKorAPClient)
Marc Kupietz781d26f2023-05-13 10:39:59 +02002library(httr)
3library(kableExtra)
4library(dplyr)
Marc Kupietz0bb21522020-02-04 11:27:25 +01005
Marc Kupietz781d26f2023-05-13 10:39:59 +02006query = 'V\u00F6ner' # "Portable packages must use only ASCII characters in their demos."
Marc Kupietz0bb21522020-02-04 11:27:25 +01007
Marc Kupietz781d26f2023-05-13 10:39:59 +02008korap_app <-oauth_app("test-korap-client", key = "773NHGM76N7P9b6rLfmpM4", secret = NULL)
9korap_endpoint <- oauth_endpoint(NULL,
10 "settings/oauth/authorize",
11 "api/v1.0/oauth2/token",
12 base_url = "https://korap.ids-mannheim.de")
13token_bundle = oauth2.0_token(korap_endpoint, korap_app, scope = "search match_info", cache = FALSE)
14
15new("KorAPConnection", verbose = TRUE, accessToken = token_bundle[["credentials"]][["access_token"]]) %>%
16 corpusQuery(query, fields = c("textSigle", "pubDate", "corpusTitle", "snippet"),
17 metadataOnly = FALSE) %>%
Marc Kupietz0bb21522020-02-04 11:27:25 +010018 fetchAll() %>%
Marc Kupietz781d26f2023-05-13 10:39:59 +020019 slot("collectedMatches") %>%
20 dplyr::arrange(pubDate) %>%
21 dplyr::rename("kwic" = "snippet") %>%
22 kable(escape = FALSE, caption = paste0("Query hits for '", query, "' ordered by date of publication")) %>%
23 kable_styling() %>%
24 print()