Marc Kupietz | 0bb2152 | 2020-02-04 11:27:25 +0100 | [diff] [blame] | 1 | library(RKorAPClient) |
Marc Kupietz | 781d26f | 2023-05-13 10:39:59 +0200 | [diff] [blame] | 2 | library(httr) |
| 3 | library(kableExtra) |
| 4 | library(dplyr) |
Marc Kupietz | 0bb2152 | 2020-02-04 11:27:25 +0100 | [diff] [blame] | 5 | |
Marc Kupietz | 781d26f | 2023-05-13 10:39:59 +0200 | [diff] [blame] | 6 | query = 'V\u00F6ner' # "Portable packages must use only ASCII characters in their demos." |
Marc Kupietz | 0bb2152 | 2020-02-04 11:27:25 +0100 | [diff] [blame] | 7 | |
Marc Kupietz | 781d26f | 2023-05-13 10:39:59 +0200 | [diff] [blame] | 8 | korap_app <-oauth_app("test-korap-client", key = "773NHGM76N7P9b6rLfmpM4", secret = NULL) |
| 9 | korap_endpoint <- oauth_endpoint(NULL, |
| 10 | "settings/oauth/authorize", |
| 11 | "api/v1.0/oauth2/token", |
| 12 | base_url = "https://korap.ids-mannheim.de") |
| 13 | token_bundle = oauth2.0_token(korap_endpoint, korap_app, scope = "search match_info", cache = FALSE) |
| 14 | |
| 15 | new("KorAPConnection", verbose = TRUE, accessToken = token_bundle[["credentials"]][["access_token"]]) %>% |
| 16 | corpusQuery(query, fields = c("textSigle", "pubDate", "corpusTitle", "snippet"), |
| 17 | metadataOnly = FALSE) %>% |
Marc Kupietz | 0bb2152 | 2020-02-04 11:27:25 +0100 | [diff] [blame] | 18 | fetchAll() %>% |
Marc Kupietz | 781d26f | 2023-05-13 10:39:59 +0200 | [diff] [blame] | 19 | 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() |