♻️💄 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/man/KorAPConnection-class.Rd b/man/KorAPConnection-class.Rd
index a7da86f..a29ef7b 100644
--- a/man/KorAPConnection-class.Rd
+++ b/man/KorAPConnection-class.Rd
@@ -61,7 +61,7 @@
To use authorization based on an access token
in subsequent queries, initialize your KorAP connection with:
-\if{html}{\out{<div class="sourceCode">}}\preformatted{kco <- new("KorAPConnection", accessToken="<access token>")
+\if{html}{\out{<div class="sourceCode">}}\preformatted{kco <- KorAPConnection(accessToken="<access token>")
}\if{html}{\out{</div>}}
In order to make the API
@@ -72,13 +72,13 @@
}\if{html}{\out{</div>}}
This will store it in your keyring using the
-\link[keyring:keyring-package]{keyring::keyring-package}. Subsequent new("KorAPConnection") calls will
+\link[keyring:keyring-package]{keyring::keyring-package}. Subsequent KorAPConnection() calls will
then automatically retrieve the token from your keying. To stop using a
persisted token, call \code{clearAccessToken(kco)}. Please note that for
DeReKo, authorized queries will behave differently inside and outside the
IDS, because of the special license situation. This concerns also cached
results which do not take into account from where a request was issued. If
-you experience problems or unexpected results, please try \code{kco <- new("KorAPConnection", cache=FALSE)} or use
+you experience problems or unexpected results, please try \code{kco <- KorAPConnection(cache=FALSE)} or use
\code{\link[=clearCache]{clearCache()}} to clear the cache completely.
An alternative to using an access token is to use a browser-based oauth2 workflow
@@ -116,7 +116,7 @@
}
\description{
\code{KorAPConnection} objects represent the connection to a KorAP server.
-New \code{KorAPConnection} objects can be created by \code{new("KorAPConnection")}.
+New \code{KorAPConnection} objects can be created by \code{KorAPConnection()}.
}
\section{Slots}{
@@ -151,14 +151,14 @@
\examples{
\dontrun{
-kcon <- new("KorAPConnection", verbose = TRUE)
+kcon <- KorAPConnection(verbose = TRUE)
kq <- corpusQuery(kcon, "Ameisenplage")
kq <- fetchAll(kq)
}
\dontrun{
-kcon <- new("KorAPConnection", verbose = TRUE, accessToken="e739u6eOzkwADQPdVChxFg")
+kcon <- KorAPConnection(verbose = TRUE, accessToken="e739u6eOzkwADQPdVChxFg")
kq <- corpusQuery(kcon, "Ameisenplage", metadataOnly=FALSE)
kq <- fetchAll(kq)
kq@collectedMatches$snippet
diff --git a/man/KorAPQuery-class.Rd b/man/KorAPQuery-class.Rd
index 1e3682d..792919e 100644
--- a/man/KorAPQuery-class.Rd
+++ b/man/KorAPQuery-class.Rd
@@ -117,7 +117,7 @@
\item{collectedMatches}{matches already fetched from the KorAP-API-server}
-\item{kco}{\code{\link[=KorAPConnection]{KorAPConnection()}} object (obtained e.g. from \code{new("KorAPConnection")}}
+\item{kco}{\code{\link[=KorAPConnection]{KorAPConnection()}} object (obtained e.g. from \code{KorAPConnection()}}
\item{query}{string that contains the corpus query. The query language depends on the \code{ql} parameter. Either \code{query} must be provided or \code{KorAPUrl}.}
@@ -192,7 +192,7 @@
\dontrun{
# Fetch metadata of every query hit for "Ameisenplage" and show a summary
-new("KorAPConnection") \%>\% corpusQuery("Ameisenplage") \%>\% fetchAll()
+KorAPConnection() \%>\% corpusQuery("Ameisenplage") \%>\% fetchAll()
}
\dontrun{
@@ -200,7 +200,7 @@
# Use the copy of a KorAP-web-frontend URL for an API query of "Ameise" in a virtual corpus
# and show the number of query hits (but don't fetch them).
-new("KorAPConnection", verbose = TRUE) \%>\%
+KorAPConnection(verbose = TRUE) \%>\%
corpusQuery(KorAPUrl =
"https://korap.ids-mannheim.de/?q=Ameise&cq=pubDate+since+2017&ql=poliqarp")
}
@@ -208,7 +208,7 @@
\dontrun{
# Plot the time/frequency curve of "Ameisenplage"
-new("KorAPConnection", verbose=TRUE) \%>\%
+KorAPConnection(verbose=TRUE) \%>\%
{ . ->> kco } \%>\%
corpusQuery("Ameisenplage") \%>\%
fetchAll() \%>\%
@@ -225,25 +225,25 @@
}
\dontrun{
-q <- new("KorAPConnection") \%>\% corpusQuery("Ameisenplage") \%>\% fetchNext()
+q <- KorAPConnection() \%>\% corpusQuery("Ameisenplage") \%>\% fetchNext()
q@collectedMatches
}
\dontrun{
-q <- new("KorAPConnection") \%>\% corpusQuery("Ameisenplage") \%>\% fetchAll()
+q <- KorAPConnection() \%>\% corpusQuery("Ameisenplage") \%>\% fetchAll()
q@collectedMatches
}
\dontrun{
-q <- new("KorAPConnection") \%>\% corpusQuery("Ameisenplage") \%>\% fetchRest()
+q <- KorAPConnection() \%>\% corpusQuery("Ameisenplage") \%>\% fetchRest()
q@collectedMatches
}
\dontrun{
-new("KorAPConnection", verbose = TRUE) \%>\%
+KorAPConnection(verbose = TRUE) \%>\%
frequencyQuery(c("Mücke", "Schnake"), paste0("pubDate in ", 2000:2003))
}
diff --git a/man/association-score-functions.Rd b/man/association-score-functions.Rd
index d8dfdad..93d3457 100644
--- a/man/association-score-functions.Rd
+++ b/man/association-score-functions.Rd
@@ -59,7 +59,7 @@
\examples{
\dontrun{
-new("KorAPConnection", verbose = TRUE) \%>\%
+KorAPConnection(verbose = TRUE) \%>\%
collocationScoreQuery("Perlen", c("verziertes", "Säue"),
scoreFunctions = append(defaultAssociationScoreFunctions(),
list(localMI = function(O1, O2, O, N, E, window_size) {
diff --git a/man/auth-KorAPConnection-method.Rd b/man/auth-KorAPConnection-method.Rd
index cf06c01..bdb0993 100644
--- a/man/auth-KorAPConnection-method.Rd
+++ b/man/auth-KorAPConnection-method.Rd
@@ -31,7 +31,7 @@
}
\examples{
\dontrun{
-kco <- new("KorAPConnection", verbose = TRUE) \%>\% auth()
+kco <- KorAPConnection(verbose = TRUE) \%>\% auth()
df <- collocationAnalysis(kco, "focus([marmot/p=ADJA] {Ameisenplage})",
leftContextSize=1, rightContextSize=0)
}
diff --git a/man/clearAccessToken-KorAPConnection-method.Rd b/man/clearAccessToken-KorAPConnection-method.Rd
index 2dfa4b5..a6c665a 100644
--- a/man/clearAccessToken-KorAPConnection-method.Rd
+++ b/man/clearAccessToken-KorAPConnection-method.Rd
@@ -19,7 +19,7 @@
\examples{
\dontrun{
-kco <- new("KorAPConnection")
+kco <- KorAPConnection()
kco <- clearAccessToken(kco)
}
diff --git a/man/collocationAnalysis-KorAPConnection-method.Rd b/man/collocationAnalysis-KorAPConnection-method.Rd
index 57b048f..1554ff7 100644
--- a/man/collocationAnalysis-KorAPConnection-method.Rd
+++ b/man/collocationAnalysis-KorAPConnection-method.Rd
@@ -31,7 +31,7 @@
)
}
\arguments{
-\item{kco}{\code{\link[=KorAPConnection]{KorAPConnection()}} object (obtained e.g. from \code{new("KorAPConnection")}}
+\item{kco}{\code{\link[=KorAPConnection]{KorAPConnection()}} object (obtained e.g. from \code{KorAPConnection()}}
\item{node}{target word}
@@ -101,7 +101,7 @@
\dontrun{
# Find top collocates of "Packung" inside and outside the sports domain.
- new("KorAPConnection", verbose = TRUE) \%>\%
+ KorAPConnection(verbose = TRUE) \%>\%
collocationAnalysis("Packung", vc=c("textClass=sport", "textClass!=sport"),
leftContextSize=1, rightContextSize=1, topCollocatesLimit=20) \%>\%
dplyr::filter(logDice >= 5)
@@ -111,7 +111,7 @@
# Identify the most prominent light verb construction with "in ... setzen".
# Note that, currently, the use of focus function disallows exactFrequencies.
-new("KorAPConnection", verbose = TRUE) \%>\%
+KorAPConnection(verbose = TRUE) \%>\%
collocationAnalysis("focus(in [tt/p=NN] {[tt/l=setzen]})",
leftContextSize=1, rightContextSize=0, exactFrequencies=FALSE, topCollocatesLimit=20)
}
diff --git a/man/collocationScoreQuery-KorAPConnection-method.Rd b/man/collocationScoreQuery-KorAPConnection-method.Rd
index 5e10b7b..b9e0e94 100644
--- a/man/collocationScoreQuery-KorAPConnection-method.Rd
+++ b/man/collocationScoreQuery-KorAPConnection-method.Rd
@@ -22,7 +22,7 @@
)
}
\arguments{
-\item{kco}{\code{\link[=KorAPConnection]{KorAPConnection()}} object (obtained e.g. from \code{new("KorAPConnection")}}
+\item{kco}{\code{\link[=KorAPConnection]{KorAPConnection()}} object (obtained e.g. from \code{KorAPConnection()}}
\item{node}{target word}
@@ -58,13 +58,13 @@
\examples{
\dontrun{
-new("KorAPConnection", verbose = TRUE) \%>\%
+KorAPConnection(verbose = TRUE) \%>\%
collocationScoreQuery("Grund", "triftiger")
}
\dontrun{
-new("KorAPConnection", verbose = TRUE) \%>\%
+KorAPConnection(verbose = TRUE) \%>\%
collocationScoreQuery("Grund", c("guter", "triftiger"),
scoreFunctions = list(localMI = function(O1, O2, O, N, E, window_size) { O * log2(O/E) }) )
}
@@ -73,7 +73,7 @@
library(highcharter)
library(tidyr)
-new("KorAPConnection", verbose = TRUE) \%>\%
+KorAPConnection(verbose = TRUE) \%>\%
collocationScoreQuery("Team", "agil", vc = paste("pubDate in", c(2014:2018)),
lemmatizeNodeQuery = TRUE, lemmatizeCollocateQuery = TRUE) \%>\%
pivot_longer(14:last_col(), names_to = "measure", values_to = "score") \%>\%
diff --git a/man/corpusStats-KorAPConnection-method.Rd b/man/corpusStats-KorAPConnection-method.Rd
index 74aca03..055585b 100644
--- a/man/corpusStats-KorAPConnection-method.Rd
+++ b/man/corpusStats-KorAPConnection-method.Rd
@@ -8,7 +8,7 @@
\S4method{corpusStats}{KorAPConnection}(kco, vc = "", verbose = kco@verbose, as.df = FALSE)
}
\arguments{
-\item{kco}{\code{\link[=KorAPConnection]{KorAPConnection()}} object (obtained e.g. from \code{new("KorAPConnection")}}
+\item{kco}{\code{\link[=KorAPConnection]{KorAPConnection()}} object (obtained e.g. from \code{KorAPConnection()}}
\item{vc}{string describing the virtual corpus. An empty string (default) means the whole corpus, as far as it is license-wise accessible.}
@@ -26,7 +26,7 @@
\dontrun{
-kco <- new("KorAPConnection")
+kco <- KorAPConnection()
corpusStats(kco, "pubDate in 2017 & textType=/Zeitung.*/")
}
diff --git a/man/hc_add_onclick_korap_search.Rd b/man/hc_add_onclick_korap_search.Rd
index 925c5f7..fcfaa1b 100644
--- a/man/hc_add_onclick_korap_search.Rd
+++ b/man/hc_add_onclick_korap_search.Rd
@@ -26,7 +26,7 @@
library(highcharter)
library(tidyr)
-new("KorAPConnection", verbose = TRUE) \%>\%
+KorAPConnection(verbose = TRUE) \%>\%
collocationScoreQuery("Team", "agil", vc = paste("pubDate in", c(2014:2018)),
lemmatizeNodeQuery = TRUE, lemmatizeCollocateQuery = TRUE) \%>\%
pivot_longer(c("O", "E")) \%>\%
diff --git a/man/hc_freq_by_year_ci.Rd b/man/hc_freq_by_year_ci.Rd
index 2d64e43..1d155c5 100644
--- a/man/hc_freq_by_year_ci.Rd
+++ b/man/hc_freq_by_year_ci.Rd
@@ -38,14 +38,14 @@
year <- c(1990:2018)
alternatives <- c("macht []{0,3} Sinn", "ergibt []{0,3} Sinn")
-new("KorAPConnection", verbose = TRUE) \%>\%
+KorAPConnection(verbose = TRUE) \%>\%
frequencyQuery(query = alternatives,
vc = paste("textType = /Zeit.*/ & pubDate in", year),
as.alternatives = TRUE) \%>\%
hc_freq_by_year_ci(as.alternatives = TRUE)
-kco <- new("KorAPConnection", verbose = TRUE)
+kco <- KorAPConnection(verbose = TRUE)
expand_grid(
condition = c("textDomain = /Wirtschaft.*/", "textDomain != /Wirtschaft.*/"),
year = (2005:2011)
diff --git a/man/misc-functions.Rd b/man/misc-functions.Rd
index d9433a3..4c21101 100644
--- a/man/misc-functions.Rd
+++ b/man/misc-functions.Rd
@@ -74,7 +74,7 @@
\dontrun{
library(ggplot2)
-kco <- new("KorAPConnection", verbose=TRUE)
+kco <- KorAPConnection(verbose=TRUE)
expand_grid(year=2015:2018, alternatives=c("Hate Speech", "Hatespeech")) \%>\%
bind_cols(corpusQuery(kco, .$alternatives, sprintf("pubDate in \%d", .$year))) \%>\%
mutate(total=corpusStats(kco, vc=vc)$tokens) \%>\%
@@ -84,11 +84,11 @@
}
\dontrun{
-new("KorAPConnection") \%>\% frequencyQuery("Test", paste0("pubDate in ", 2000:2002)) \%>\% ipm()
+KorAPConnection() \%>\% frequencyQuery("Test", paste0("pubDate in ", 2000:2002)) \%>\% ipm()
}
\dontrun{
-new("KorAPConnection") \%>\%
+KorAPConnection() \%>\%
frequencyQuery(c("Tollpatsch", "Tolpatsch"),
vc=paste0("pubDate in ", 2000:2002),
as.alternatives = TRUE) \%>\%
@@ -100,7 +100,7 @@
\dontrun{
library(ggplot2)
-kco <- new("KorAPConnection", verbose=TRUE)
+kco <- KorAPConnection(verbose=TRUE)
expand_grid(condition = c("textDomain = /Wirtschaft.*/", "textDomain != /Wirtschaft.*/"),
year = (2005:2011)) \%>\%
diff --git a/man/persistAccessToken-KorAPConnection-method.Rd b/man/persistAccessToken-KorAPConnection-method.Rd
index b66457e..094acee 100644
--- a/man/persistAccessToken-KorAPConnection-method.Rd
+++ b/man/persistAccessToken-KorAPConnection-method.Rd
@@ -20,10 +20,10 @@
}
\examples{
\dontrun{
-kco <- new("KorAPConnection", accessToken="e739u6eOzkwADQPdVChxFg")
+kco <- KorAPConnection(accessToken="e739u6eOzkwADQPdVChxFg")
persistAccessToken(kco)
-kco <- new("KorAPConnection") \%>\% auth(app_id="<my application id>") \%>\% persistAccessToken()
+kco <- KorAPConnection() \%>\% auth(app_id="<my application id>") \%>\% persistAccessToken()
}
}
diff --git a/man/textMetadata-KorAPConnection-method.Rd b/man/textMetadata-KorAPConnection-method.Rd
index bc1bbca..170f3e0 100644
--- a/man/textMetadata-KorAPConnection-method.Rd
+++ b/man/textMetadata-KorAPConnection-method.Rd
@@ -8,7 +8,7 @@
\S4method{textMetadata}{KorAPConnection}(kco, textSigle, verbose = kco@verbose)
}
\arguments{
-\item{kco}{\code{\link[=KorAPConnection]{KorAPConnection()}} object (obtained e.g. from \code{new("KorAPConnection")})}
+\item{kco}{\code{\link[=KorAPConnection]{KorAPConnection()}} object (obtained e.g. from \code{KorAPConnection()})}
\item{textSigle}{unique text id (concatenation of corpus, document and text ids, separated by \code{/}, e.g. ) or vector thereof}
@@ -24,7 +24,7 @@
}
\examples{
\dontrun{
-new("KorAPConnection") \%>\% textMetadata(c("WUD17/A97/08542", "WUD17/B96/57558", "WUD17/A97/08541"))
+KorAPConnection() \%>\% textMetadata(c("WUD17/A97/08542", "WUD17/B96/57558", "WUD17/A97/08541"))
}
}