♻️💄 simplify KorAPConnection class instantiations to modern syntax
Update all class instantiations from `new("KorAPConnection")` to `KorAPConnection()`.
This is possible with R >= 4.0.
Change-Id: I01131fb32045e084cafbb9e05cd8ba99f8f20f1b
diff --git a/demo/Rmd/ca.Rmd b/demo/Rmd/ca.Rmd
index a4016a5..eb9ad8c 100644
--- a/demo/Rmd/ca.Rmd
+++ b/demo/Rmd/ca.Rmd
@@ -13,7 +13,7 @@
library(kableExtra)
library(DT)
library(tidyverse)
-kco <- new("KorAPConnection", verbose=T)
+kco <- KorAPConnection(verbose=T)
if (!exists('ca')) {
ca <- kco %>%
collocationAnalysis(
diff --git a/demo/adjectiveCollocates.R b/demo/adjectiveCollocates.R
index 3d69eaa..346199b 100644
--- a/demo/adjectiveCollocates.R
+++ b/demo/adjectiveCollocates.R
@@ -2,7 +2,7 @@
library(kableExtra)
-new("KorAPConnection", verbose = TRUE) %>%
+KorAPConnection(verbose = TRUE) %>%
auth() %>%
collocationAnalysis("focus([marmot/p=ADJA] {Gendern})", leftContextSize=1, rightContextSize=0) %>%
mutate(collocate = paste0('<a href="', webUIRequestUrl, '">', collocate, '</a>')) %>%
diff --git a/demo/alternativesOverTime.R b/demo/alternativesOverTime.R
index 07019bd..1f70feb 100755
--- a/demo/alternativesOverTime.R
+++ b/demo/alternativesOverTime.R
@@ -5,7 +5,7 @@
library(RKorAPClient)
library(ggplot2)
-alternativesOverTime <- function(alternatives, years, kco = new("KorAPConnection", verbose=TRUE)) {
+alternativesOverTime <- function(alternatives, years, kco = KorAPConnection(verbose=TRUE)) {
df <- expand_grid(Variant = alternatives, year = years) %>%
cbind(frequencyQuery(kco, .$Variant, sprintf("textType = /Zeit.*/ & pubDate in %d", .$year), as.alternatives=TRUE)) %>%
rename(share=f)
diff --git a/demo/collocation_score_by_country.R b/demo/collocation_score_by_country.R
index 9d6dc69..ccb2f51 100644
--- a/demo/collocation_score_by_country.R
+++ b/demo/collocation_score_by_country.R
@@ -9,7 +9,7 @@
df <- expand_grid(node = NODE, collocate = COLLOCATES, country = COUNTRIES) %>%
mutate(vc = sprintf(VC, country))
-g <- new("KorAPConnection", verbose=TRUE) %>%
+g <- KorAPConnection(verbose=TRUE) %>%
collocationScoreQuery(df$node, df$collocate, df$vc, smoothingConstant = 0) %>%
bind_cols(df %>% select(country)) %>%
ggplot(aes(x = country, y = logDice, label = sprintf("(%d)", O), fill = collocate)) +
diff --git a/demo/conditionsOverTime.R b/demo/conditionsOverTime.R
index ccd5592..4b96e3d 100644
--- a/demo/conditionsOverTime.R
+++ b/demo/conditionsOverTime.R
@@ -7,7 +7,7 @@
library(RKorAPClient)
library(ggplot2)
-conditionsOverTime <- function(query, conditions, years, kco = new("KorAPConnection", verbose = TRUE)) {
+conditionsOverTime <- function(query, conditions, years, kco = KorAPConnection(verbose = TRUE)) {
g <- expand_grid(condition = conditions, year = years) %>%
cbind(frequencyQuery(kco, query, sprintf("%s & pubDate in %d", .$condition, .$year))) %>%
ipm() %>%
diff --git a/demo/displayKwics.R b/demo/displayKwics.R
index cab5807..edb6185 100644
--- a/demo/displayKwics.R
+++ b/demo/displayKwics.R
@@ -4,7 +4,7 @@
query = 'V\u00F6ner' # "Portable packages must use only ASCII characters in their demos."
-new("KorAPConnection", verbose = TRUE) %>%
+KorAPConnection(verbose = TRUE) %>%
auth() %>%
corpusQuery(query, fields = c("textSigle", "pubDate", "corpusTitle", "snippet"),
metadataOnly = FALSE) %>%
diff --git a/demo/frequenciesOverDomains.R b/demo/frequenciesOverDomains.R
index 6607893..8da5cc8 100755
--- a/demo/frequenciesOverDomains.R
+++ b/demo/frequenciesOverDomains.R
@@ -5,7 +5,7 @@
library(RKorAPClient)
library(ggplot2)
-freqPerDomain <- function(query, con = new("KorAPConnection", verbose = TRUE)) {
+freqPerDomain <- function(query, con = KorAPConnection(verbose = TRUE)) {
g <- corpusQuery(con, query = query, vc="") %>%
fetchAll() %>%
slot("collectedMatches") %>%
diff --git a/demo/frequenciesOverTime.R b/demo/frequenciesOverTime.R
index aadd0d2..3772b67 100644
--- a/demo/frequenciesOverTime.R
+++ b/demo/frequenciesOverTime.R
@@ -5,7 +5,7 @@
library(RKorAPClient)
library(ggplot2)
-freqPerYear <- function(query, kco = new("KorAPConnection", verbose = TRUE)) {
+freqPerYear <- function(query, kco = KorAPConnection(verbose = TRUE)) {
g <- data.frame(year = 2000:2018) %>%
cbind(frequencyQuery(kco, query, sprintf("pubDate in %d", .$year))) %>%
{ . ->> df } %>%
diff --git a/demo/frequency_by_country_ggplot.R b/demo/frequency_by_country_ggplot.R
index 514e8cf..f37b437 100644
--- a/demo/frequency_by_country_ggplot.R
+++ b/demo/frequency_by_country_ggplot.R
@@ -6,7 +6,7 @@
vcs <- sprintf("textType=/Zeit.*/ & pubPlaceKey=%s", countries) # limit virtual corpus to newspapers and magazines
-g <- new("KorAPConnection", verbose=TRUE) %>%
+g <- KorAPConnection(verbose=TRUE) %>%
frequencyQuery(query, vc=vcs) %>%
ipm() %>%
mutate(Land = countries) %>%
diff --git a/demo/frequency_by_country_highcharts.R b/demo/frequency_by_country_highcharts.R
index c04ea7d..5529e13 100644
--- a/demo/frequency_by_country_highcharts.R
+++ b/demo/frequency_by_country_highcharts.R
@@ -8,7 +8,7 @@
VCS <- sprintf("textType=/Zeit.*/ & pubPlaceKey=%s", COUNTRIES) # limit virtual corpus to newspapers and magazines
-df <- new("KorAPConnection", verbose=TRUE) %>%
+df <- KorAPConnection(verbose=TRUE) %>%
frequencyQuery(QUERIES, vc=VCS) %>%
ipm() %>%
mutate(country = rep(COUNTRIES, length(QUERIES)))
diff --git a/demo/highcharter-example.R b/demo/highcharter-example.R
index b6167f7..2661ec2 100644
--- a/demo/highcharter-example.R
+++ b/demo/highcharter-example.R
@@ -5,7 +5,7 @@
years = c(2000:2010),
as.alternatives = length(query) > 1,
vc = "textType = /Zeit.*/ & availability!=QAO-NC-LOC:ids & pubDate in",
- kco = new("KorAPConnection", verbose=TRUE) ) {
+ kco = KorAPConnection(verbose=TRUE) ) {
hc <-
frequencyQuery(kco, query, paste(vc, years), as.alternatives=as.alternatives) %>%
hc_freq_by_year_ci(as.alternatives)
diff --git a/demo/light-verb-construction-ca.R b/demo/light-verb-construction-ca.R
index fa8093f..e902f16 100644
--- a/demo/light-verb-construction-ca.R
+++ b/demo/light-verb-construction-ca.R
@@ -9,7 +9,7 @@
cat(file=mdFile, sprintf("---\ntitle: LVC analysis of %s\n---\n\n", lvLemma))
-new("KorAPConnection", verbose = TRUE) %>%
+KorAPConnection(verbose = TRUE) %>%
collocationAnalysis(
sprintf("focus(in [tt/p=NN] {[tt/l=%s]})", lvLemma),
leftContextSize = 1,
diff --git a/demo/mosaicplot.R b/demo/mosaicplot.R
index d8ea3b7..8c50351 100644
--- a/demo/mosaicplot.R
+++ b/demo/mosaicplot.R
@@ -8,7 +8,7 @@
library(tibble)
library(dplyr)
-mosaicplot <- function(query, vc, kco = new("KorAPConnection", verbose = TRUE)) {
+mosaicplot <- function(query, vc, kco = KorAPConnection(verbose = TRUE)) {
frequencyQuery(
query = query,
vc = vc,
diff --git a/demo/pluralGenderVariants.R b/demo/pluralGenderVariants.R
index ef9d310..44745de 100644
--- a/demo/pluralGenderVariants.R
+++ b/demo/pluralGenderVariants.R
@@ -49,7 +49,7 @@
vc = "referTo ratskorpus-2023-1 & pubDate in",
suffixes = c('Innen', '[\\*]innen"', '[_]innen"', ' innen'),
prefixes = c('', '"', '"', ''),
- kco = new("KorAPConnection", verbose=TRUE) %>% auth()) {
+ kco = KorAPConnection(verbose=TRUE) %>% auth()) {
hc <-
frequencyQuery(kco, paste0(prefixes, word, suffixes), paste(vc, years), as.alternatives=as.alternatives) %>%
unravelPunctuationGenderCases(kco = kco) %>%
diff --git a/demo/recursiveCA.R b/demo/recursiveCA.R
index ce2be8b..720b00c 100644
--- a/demo/recursiveCA.R
+++ b/demo/recursiveCA.R
@@ -6,7 +6,7 @@
nodeWordform <- 'aufmerksam'
mdFile <- tempfile(nodeWordform, fileext = ".md")
-new("KorAPConnection", verbose = TRUE) %>%
+KorAPConnection(verbose = TRUE) %>%
collocationAnalysis(
nodeWordform,
leftContextSize = 2,
diff --git a/demo/regional.R b/demo/regional.R
index e0c3df8..81ddae1 100755
--- a/demo/regional.R
+++ b/demo/regional.R
@@ -39,7 +39,7 @@
map <- fetchMaps(c("DEU_1", "AUT_0", "CHE_0", "LUX_0", "BEL_3", "ITA_1", "LIE_0"), c(0, 0, 0, 0, 34, 17, 0))
-geoDistrib <- function(query, kco = new("KorAPConnection", verbose=TRUE)) {
+geoDistrib <- function(query, kco = KorAPConnection(verbose=TRUE)) {
regions <- readRDS("demo/data/regions.rds")
regions$freq <- NA
regions$url <- NA
diff --git a/demo/relativeTextpositionBoxplot.R b/demo/relativeTextpositionBoxplot.R
index 02823da..6bb71a1 100644
--- a/demo/relativeTextpositionBoxplot.R
+++ b/demo/relativeTextpositionBoxplot.R
@@ -2,7 +2,7 @@
library(highcharter)
library(tidyverse)
-kco <- new("KorAPConnection", verbose = TRUE)
+kco <- KorAPConnection(verbose = TRUE)
set.seed(7)
diff --git a/demo/writtenVsSpoken.R b/demo/writtenVsSpoken.R
index 87b93b4..31391ff 100644
--- a/demo/writtenVsSpoken.R
+++ b/demo/writtenVsSpoken.R
@@ -2,7 +2,7 @@
# install_github("KorAP/RKorAPClient")
library(RKorAPClient)
library(ggplot2)
-g <- new("KorAPConnection", verbose=TRUE) %>%
+g <- KorAPConnection(verbose=TRUE) %>%
frequencyQuery("sozusagen/i", vc=c("corpusSigle=FOLK", "corpusSigle!=FOLK")) %>%
ipm() %>%
mutate(corpus=c("FOLK", "DeReKo")) %>%