Adapt demos to simplified authorization
Change-Id: If29075378f77cc8872cbf59c3e3d92fe39b84fb6
diff --git a/demo/00Index b/demo/00Index
index 426b8b6..8a1200f 100644
--- a/demo/00Index
+++ b/demo/00Index
@@ -6,7 +6,7 @@
mosaicplot Visualize frequencies of alternative query terms in relation to other variables
shiny-frequency-curves Web application that plots frequency curves with highcharts and shiny
writtenVsSpoken Compare frequencies in written vs. spoken corpora
-displayKwics Display query results including KWICs (also demonstrates OAuth2 browser workflow with httr)
+displayKwics Display query results including KWICs (also demonstrates OAuth2 browser workflow)
light-verb-construction-ca Collocation analysis to identify light verb constructions matching the pattern "in NN setzen", with result rendered as HTML DataTable
highcharter-example Visualize frequencies of optionally alternative terms over time with interactive HTML and JavaScript elements using the package highcharter as wrapper for Highcharts
recursiveCA Show result dataframe of recursvie collocation analysis as pretty HTML tableb y Knitr via Markdown.
@@ -14,5 +14,5 @@
frequency_by_country_highcharts Plot frequencies depending on country of publication using highcharter.
collocation_score_by_country Plot collocation scores depending on country of publication using ggplot2.
pluralGenderVariants Plot frequencies of the plural gender variants of a word in the core corpus of the Council for German Orthography (OKK) over time.
-adjectiveCollocates Runtime OAuth2 browser flow demonstration using the httr2 package showing adjective collocates of 'Gendern'
+adjectiveCollocates Shows adjective collocates of 'Gendern'.
relativeTextpositionBoxplot Plot the relative text positions of a some adverbs as highcharter boxplot.
diff --git a/demo/adjectiveCollocates.R b/demo/adjectiveCollocates.R
index 4ef8fa9..3d69eaa 100644
--- a/demo/adjectiveCollocates.R
+++ b/demo/adjectiveCollocates.R
@@ -1,32 +1,13 @@
library(RKorAPClient)
-library(httr2)
library(kableExtra)
-demo_kor_app_id = "773NHGM76N7P9b6rLfmpM4"
-
-oauthorizeDemo <- function(kco, app_id = demo_kor_app_id) {
- if (is.null(kco@accessToken) || is.null(kco@welcome)) { # if access token is not set or invalid
- kco@accessToken <- ( # request one
- oauth_client(
- id = app_id, # for the demo application
- token_url = paste0(kco@apiUrl, "oauth2/token")
- ) %>%
- oauth_flow_auth_code(
- scope = "search match_info",
- auth_url = paste0(kco@KorAPUrl, "settings/oauth/authorize")
- )
- )$access_token
- }
- print(kco@accessToken)
- return(kco)
-}
new("KorAPConnection", verbose = TRUE) %>%
- oauthorizeDemo() %>%
+ auth() %>%
collocationAnalysis("focus([marmot/p=ADJA] {Gendern})", leftContextSize=1, rightContextSize=0) %>%
mutate(collocate = paste0('<a href="', webUIRequestUrl, '">', collocate, '</a>')) %>%
select(collocate, O, pmi, mi2, mi3, logDice, ll) %>%
- kable(escape = FALSE, caption = "Adjective collocates of 'Gendern'") %>%
+ kable(format = "html", escape = FALSE, caption = "Adjective collocates of 'Gendern'") %>%
kable_styling() %>%
print()
diff --git a/demo/displayKwics.R b/demo/displayKwics.R
index 4da6540..cab5807 100644
--- a/demo/displayKwics.R
+++ b/demo/displayKwics.R
@@ -1,24 +1,17 @@
library(RKorAPClient)
-library(httr)
library(kableExtra)
library(dplyr)
query = 'V\u00F6ner' # "Portable packages must use only ASCII characters in their demos."
-korap_app <-oauth_app("test-korap-client", key = "773NHGM76N7P9b6rLfmpM4", secret = NULL)
-korap_endpoint <- oauth_endpoint(NULL,
- "settings/oauth/authorize",
- "api/v1.0/oauth2/token",
- base_url = "https://korap.ids-mannheim.de")
-token_bundle = oauth2.0_token(korap_endpoint, korap_app, scope = "search match_info", cache = FALSE)
-
-new("KorAPConnection", verbose = TRUE, accessToken = token_bundle[["credentials"]][["access_token"]]) %>%
+new("KorAPConnection", verbose = TRUE) %>%
+ auth() %>%
corpusQuery(query, fields = c("textSigle", "pubDate", "corpusTitle", "snippet"),
metadataOnly = FALSE) %>%
fetchAll() %>%
slot("collectedMatches") %>%
dplyr::arrange(pubDate) %>%
dplyr::rename("kwic" = "snippet") %>%
- kable(escape = FALSE, caption = paste0("Query hits for '", query, "' ordered by date of publication")) %>%
+ kable(format = "html", escape = FALSE, caption = paste0("Query hits for '", query, "' ordered by date of publication")) %>%
kable_styling() %>%
print()
diff --git a/demo/pluralGenderVariants.R b/demo/pluralGenderVariants.R
index 8ff8c3b..ef9d310 100644
--- a/demo/pluralGenderVariants.R
+++ b/demo/pluralGenderVariants.R
@@ -1,10 +1,6 @@
library(RKorAPClient)
library(tidyverse)
library(purrrlyr)
-library(httr2)
-library(httpuv)
-
-demo_kor_app_id = "773NHGM76N7P9b6rLfmpM4"
# The challenge in searching gender variants with KorAP and DeReKo is that,
# firstly, some characters used for gender marking, especially punctuation marks,
@@ -47,29 +43,13 @@
}
}
-oauthorizeDemo <- function(kco, app_id = demo_kor_app_id) {
- if (is.null(kco@accessToken) || is.null(kco@welcome)) { # if access token is not set or invalid
- kco@accessToken <- ( # request one
- oauth_client(
- id = app_id, # for the demo application
- token_url = paste0(kco@apiUrl, "oauth2/token")
- ) %>%
- oauth_flow_auth_code(
- scope = "search match_info",
- auth_url = paste0(kco@KorAPUrl, "settings/oauth/authorize")
- )
- )$access_token
- }
- kco
-}
-
plotPluralGenderVariants <- function(word = "Nutzer",
years = c(1995:2022),
as.alternatives = FALSE,
vc = "referTo ratskorpus-2023-1 & pubDate in",
suffixes = c('Innen', '[\\*]innen"', '[_]innen"', ' innen'),
prefixes = c('', '"', '"', ''),
- kco = new("KorAPConnection", verbose=TRUE) %>% oauthorizeDemo()) {
+ kco = new("KorAPConnection", verbose=TRUE) %>% auth()) {
hc <-
frequencyQuery(kco, paste0(prefixes, word, suffixes), paste(vc, years), as.alternatives=as.alternatives) %>%
unravelPunctuationGenderCases(kco = kco) %>%