| corpusStats,KorAPConnection-method | R Documentation |
Retrieve information about corpus size (documents, tokens, sentences, paragraphs) for the entire corpus or a virtual corpus subset.
## S4 method for signature 'KorAPConnection'
corpusStats(kco, vc = "", verbose = kco@verbose, as.df = FALSE, cacheAs = NULL)
kco |
|
vc |
string describing the virtual corpus. An empty string (default) means the whole corpus, as far as it is license-wise accessible. |
verbose |
logical. If |
as.df |
return result as data frame instead of as S4 object? |
cacheAs |
path to an RDS file to keep the result in. If the file exists and records the same call, it is read back instead of contacting the server; otherwise the query is run and its result stored there. Unlike the connection's |
Object containing corpus statistics with the following information:
vcVirtual corpus definition used (empty string for entire corpus)
documentsTotal number of documents in the (virtual) corpus
tokensTotal number of word tokens in the (virtual) corpus
sentencesTotal number of sentences in the (virtual) corpus
paragraphsTotal number of paragraphs in the (virtual) corpus
webUIRequestUrlURL to view this corpus subset in KorAP web interface
When as.df=TRUE, returns a data frame with these columns.
When as.df=FALSE (default), returns a KorAPCorpusStats object with these values as slots.
# Get statistics for entire corpus kcon <- KorAPConnection() stats <- corpusStats(kcon) # Get statistics for a specific time period stats <- corpusStats(kcon, "pubDate in 2020") # Access the number of tokens stats@tokens
## Not run:
kco <- KorAPConnection()
# Get statistics for entire corpus (returns S4 object)
stats <- corpusStats(kco)
stats@tokens # Access number of tokens
# Get statistics for newspaper texts from 2017 (as data frame)
df <- corpusStats(kco, "pubDate in 2017 & textType=/Zeitung.*/", as.df = TRUE)
df$documents # Access number of documents
# Compare corpus sizes across years
years <- 2015:2020
sizes <- sapply(years, function(y) {
corpusStats(kco, paste("pubDate in", y))@tokens
})
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.