| Title: | 'KorAP' Web Service Client Package |
|---|---|
| Description: | A client package that makes the 'KorAP' web service API accessible from R. The corpus analysis platform 'KorAP' has been developed as a scientific tool to make potentially large, stratified and multiply annotated corpora, such as the 'German Reference Corpus DeReKo' or the 'Corpus of the Contemporary Romanian Language CoRoLa', accessible for linguists to let them verify hypotheses and to find interesting patterns in real language use. The 'RKorAPClient' package provides access to 'KorAP' and the corpora behind it for user-created R code, as a programmatic alternative to the 'KorAP' web user-interface. You can learn more about 'KorAP' and use it directly on 'DeReKo' at <https://korap.ids-mannheim.de/>. |
| Authors: | Marc Kupietz [aut, cre], Nils Diewald [ctb], Leibniz Institute for the German Language [cph, fnd] |
| Maintainer: | Marc Kupietz <[email protected]> |
| License: | BSD_2_clause + file LICENSE |
| Version: | 1.2.1.9000 |
| Built: | 2026-05-17 08:18:01 UTC |
| Source: | https://github.com/korap/rkorapclient |
Functions to calculate different collocation association scores between
a node (target word) and words in a window around the it.
The functions are primarily used by collocationScoreQuery().
pmi: pointwise mutual information
mi2: pointwise mutual information squared (Daille 1994), also referred to as mutual dependency (Thanopoulos et al. 2002)
mi3: pointwise mutual information cubed (Daille 1994), also referred to as log-frequency biased mutual dependency) (Thanopoulos et al. 2002)
logDice: log-Dice coefficient, a heuristic measure that is popular in lexicography (Rychlý 2008)
ll: log-likelihood (Dunning 1993) using Stefan Evert's (2004) simplified implementation
defaultAssociationScoreFunctions() pmi(O1, O2, O, N, E, window_size) mi2(O1, O2, O, N, E, window_size) mi3(O1, O2, O, N, E, window_size) logDice(O1, O2, O, N, E, window_size) ll(O1, O2, O, N, E, window_size)defaultAssociationScoreFunctions() pmi(O1, O2, O, N, E, window_size) mi2(O1, O2, O, N, E, window_size) mi3(O1, O2, O, N, E, window_size) logDice(O1, O2, O, N, E, window_size) ll(O1, O2, O, N, E, window_size)
O1 |
observed absolute frequency of node |
O2 |
observed absolute frequency of collocate |
O |
observed absolute frequency of collocation |
N |
corpus size |
E |
expected absolute frequency of collocation (already adjusted to window size) |
window_size |
total window size around node (left neighbour count + right neighbour count) |
association score
Daille, B. (1994): Approche mixte pour l’extraction automatique de terminologie: statistiques lexicales et filtres linguistiques. PhD thesis, Université Paris 7.
Thanopoulos, A., Fakotakis, N., Kokkinakis, G. (2002): Comparative evaluation of collocation extraction metrics. In: Proc. of LREC 2002: 620–625.
Rychlý, Pavel (2008): A lexicographer-friendly association score. In Proceedings of Recent Advances in Slavonic Natural Language Processing, RASLAN, 6–9. https://www.fi.muni.cz/usr/sojka/download/raslan2008/13.pdf.
Dunning, T. (1993): Accurate methods for the statistics of surprise and coincidence. Comput. Linguist. 19, 1 (March 1993), 61-74.
Evert, Stefan (2004): The Statistics of Word Cooccurrences: Word Pairs and Collocations. PhD dissertation, IMS, University of Stuttgart. Published in 2005, URN urn:nbn:de:bsz:93-opus-23714. Free PDF available from https://purl.org/stefan.evert/PUB/Evert2004phd.pdf
Other collocation analysis functions:
collocationAnalysis,KorAPConnection-method,
collocationScoreQuery,KorAPConnection-method,
synsemanticStopwords()
## Not run: KorAPConnection(verbose = TRUE) %>% collocationScoreQuery("Perlen", c("verziertes", "Säue"), scoreFunctions = append(defaultAssociationScoreFunctions(), list(localMI = function(O1, O2, O, N, E, window_size) { O * log2(O/E) }))) ## End(Not run)## Not run: KorAPConnection(verbose = TRUE) %>% collocationScoreQuery("Perlen", c("verziertes", "Säue"), scoreFunctions = append(defaultAssociationScoreFunctions(), list(localMI = function(O1, O2, O, N, E, window_size) { O * log2(O/E) }))) ## End(Not run)
Authorize RKorAPClient to make KorAP queries and download results on behalf of the user.
## S4 method for signature 'KorAPConnection' auth( kco, app_id = generic_kor_app_id, app_secret = NULL, scope = kco@oauthScope )## S4 method for signature 'KorAPConnection' auth( kco, app_id = generic_kor_app_id, app_secret = NULL, scope = kco@oauthScope )
kco |
KorAPConnection object |
app_id |
OAuth2 application id. Defaults to the generic KorAP client application id. |
app_secret |
OAuth2 application secret. Used with confidential client applications. Defaults to |
scope |
OAuth2 scope. Defaults to "search match_info". |
KorAPConnection object with access token set in @accessToken.
persistAccessToken(), clearAccessToken()
Other initialization functions:
KorAPConnection-class,
clearAccessToken,KorAPConnection-method,
persistAccessToken,KorAPConnection-method
## Not run: kco <- KorAPConnection(verbose = TRUE) %>% auth() df <- collocationAnalysis(kco, "focus([marmot/p=ADJA] {Ameisenplage})", leftContextSize = 1, rightContextSize = 0 ) ## End(Not run)## Not run: kco <- KorAPConnection(verbose = TRUE) %>% auth() df <- collocationAnalysis(kco, "focus([marmot/p=ADJA] {Ameisenplage})", leftContextSize = 1, rightContextSize = 0 ) ## End(Not run)
Using prop.test(), ci adds three columns to a data frame:
relative frequency (f)
lower bound of a confidence interval (ci.low)
upper bound of a confidence interval
Convenience function for converting frequency tables to instances per million.
Convenience function for converting frequency tables of alternative variants
(generated with as.alternatives=TRUE) to percent.
Converts a vector of query or vc strings to typically appropriate legend labels by clipping off prefixes and suffixes that are common to all query strings.
Experimental convenience function for plotting typical frequency by year graphs with confidence intervals using ggplot2. Warning: This function may be moved to a new package.
ci(df, x = totalResults, N = total, conf.level = 0.95) ipm(df) percent(df) queryStringToLabel(data, pubDateOnly = FALSE, excludePubDate = FALSE) geom_freq_by_year_ci(mapping = aes(ymin = conf.low, ymax = conf.high), ...)ci(df, x = totalResults, N = total, conf.level = 0.95) ipm(df) percent(df) queryStringToLabel(data, pubDateOnly = FALSE, excludePubDate = FALSE) geom_freq_by_year_ci(mapping = aes(ymin = conf.low, ymax = conf.high), ...)
df |
table returned from |
x |
column with the observed absolute frequency. |
N |
column with the total frequencies |
conf.level |
confidence level of the returned confidence interval. Must be a single number between 0 and 1. |
data |
string or vector of query or vc definition strings |
pubDateOnly |
discard all but the publication date |
excludePubDate |
discard publication date constraints |
mapping |
Set of aesthetic mappings created by aes() or aes_(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping. |
... |
Other arguments passed to geom_ribbon, geom_line, and geom_click_point. |
Given a table with columns f, conf.low, and conf.high, ipm ads a column ipm
und multiplies conf.low and conf.high with 10^6.
original table with additional column ipm and converted columns conf.low and conf.high
original table with converted columns f, conf.low and conf.high
string or vector of strings with clipped off common prefixes and suffixes
ci is already included in frequencyQuery()
## Not run: library(ggplot2) 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) %>% ci() %>% ggplot(aes(x=year, y=f, fill=query, color=query, ymin=conf.low, ymax=conf.high)) + geom_point() + geom_line() + geom_ribbon(alpha=.3) ## End(Not run) ## Not run: KorAPConnection() %>% frequencyQuery("Test", paste0("pubDate in ", 2000:2002)) %>% ipm() ## End(Not run) ## Not run: KorAPConnection() %>% frequencyQuery(c("Tollpatsch", "Tolpatsch"), vc=paste0("pubDate in ", 2000:2002), as.alternatives = TRUE) %>% percent() ## End(Not run) queryStringToLabel(paste("textType = /Zeit.*/ & pubDate in", c(2010:2019))) queryStringToLabel(c("[marmot/m=mood:subj]", "[marmot/m=mood:ind]")) queryStringToLabel(c("wegen dem [tt/p=NN]", "wegen des [tt/p=NN]")) ## Not run: library(ggplot2) kco <- KorAPConnection(verbose=TRUE) expand_grid(condition = c("textDomain = /Wirtschaft.*/", "textDomain != /Wirtschaft.*/"), year = (2005:2011)) %>% cbind(frequencyQuery(kco, "[tt/l=Heuschrecke]", paste0(.$condition," & pubDate in ", .$year))) %>% ipm() %>% ggplot(aes(year, ipm, fill = condition, color = condition)) + geom_freq_by_year_ci() ## End(Not run)## Not run: library(ggplot2) 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) %>% ci() %>% ggplot(aes(x=year, y=f, fill=query, color=query, ymin=conf.low, ymax=conf.high)) + geom_point() + geom_line() + geom_ribbon(alpha=.3) ## End(Not run) ## Not run: KorAPConnection() %>% frequencyQuery("Test", paste0("pubDate in ", 2000:2002)) %>% ipm() ## End(Not run) ## Not run: KorAPConnection() %>% frequencyQuery(c("Tollpatsch", "Tolpatsch"), vc=paste0("pubDate in ", 2000:2002), as.alternatives = TRUE) %>% percent() ## End(Not run) queryStringToLabel(paste("textType = /Zeit.*/ & pubDate in", c(2010:2019))) queryStringToLabel(c("[marmot/m=mood:subj]", "[marmot/m=mood:ind]")) queryStringToLabel(c("wegen dem [tt/p=NN]", "wegen des [tt/p=NN]")) ## Not run: library(ggplot2) kco <- KorAPConnection(verbose=TRUE) expand_grid(condition = c("textDomain = /Wirtschaft.*/", "textDomain != /Wirtschaft.*/"), year = (2005:2011)) %>% cbind(frequencyQuery(kco, "[tt/l=Heuschrecke]", paste0(.$condition," & pubDate in ", .$year))) %>% ipm() %>% ggplot(aes(year, ipm, fill = condition, color = condition)) + geom_freq_by_year_ci() ## End(Not run)
Clear access token from keyring and KorAPConnection object
## S4 method for signature 'KorAPConnection' clearAccessToken(kco)## S4 method for signature 'KorAPConnection' clearAccessToken(kco)
kco |
KorAPConnection object |
KorAPConnection object with access token set to NULL.
Other initialization functions:
KorAPConnection-class,
auth,KorAPConnection-method,
persistAccessToken,KorAPConnection-method
## Not run: kco <- KorAPConnection() kco <- clearAccessToken(kco) ## End(Not run)## Not run: kco <- KorAPConnection() kco <- clearAccessToken(kco) ## End(Not run)
Clears the local cache of API responses for the current RKorAPClient version. Useful when you want to force fresh data retrieval or free up disk space.
## S4 method for signature 'KorAPConnection' clearCache(kco)## S4 method for signature 'KorAPConnection' clearCache(kco)
kco |
KorAPConnection object |
Invisible NULL (function called for side effects)
## Not run: kco <- KorAPConnection() clearCache(kco) ## End(Not run)## Not run: kco <- KorAPConnection() clearCache(kco) ## End(Not run)
Performs a collocation analysis for the given node (or query) in the given virtual corpus.
## S4 method for signature 'KorAPConnection' collocationAnalysis( kco, node, vc = "", lemmatizeNodeQuery = FALSE, minOccur = 5, leftContextSize = 5, rightContextSize = 5, topCollocatesLimit = 200, searchHitsSampleLimit = 20000, ignoreCollocateCase = FALSE, withinSpan = ifelse(exactFrequencies, "base/s=s", ""), exactFrequencies = TRUE, stopwords = append(RKorAPClient::synsemanticStopwords(), node), seed = 7, expand = length(vc) != length(node), maxRecurse = 0, addExamples = FALSE, thresholdScore = "logDice", threshold = 2, localStopwords = c(), collocateFilterRegex = "^[:alnum:]+-?[:alnum:]*$", queryMissingScores = FALSE, missingScoreQuantile = 0.05, vcLabel = NA_character_, ... )## S4 method for signature 'KorAPConnection' collocationAnalysis( kco, node, vc = "", lemmatizeNodeQuery = FALSE, minOccur = 5, leftContextSize = 5, rightContextSize = 5, topCollocatesLimit = 200, searchHitsSampleLimit = 20000, ignoreCollocateCase = FALSE, withinSpan = ifelse(exactFrequencies, "base/s=s", ""), exactFrequencies = TRUE, stopwords = append(RKorAPClient::synsemanticStopwords(), node), seed = 7, expand = length(vc) != length(node), maxRecurse = 0, addExamples = FALSE, thresholdScore = "logDice", threshold = 2, localStopwords = c(), collocateFilterRegex = "^[:alnum:]+-?[:alnum:]*$", queryMissingScores = FALSE, missingScoreQuantile = 0.05, vcLabel = NA_character_, ... )
kco |
|
node |
target word |
vc |
string describing the virtual corpus in which the query should be performed. An empty string (default) means the whole corpus, as far as it is license-wise accessible. |
lemmatizeNodeQuery |
if TRUE, node query will be lemmatized, i.e. |
minOccur |
minimum absolute number of observed co-occurrences to consider a collocate candidate |
leftContextSize |
size of the left context window |
rightContextSize |
size of the right context window |
topCollocatesLimit |
limit analysis to the n most frequent collocates in the search hits sample |
searchHitsSampleLimit |
limit the size of the search hits sample |
ignoreCollocateCase |
logical, set to TRUE if collocate case should be ignored |
withinSpan |
KorAP span specification (see https://korap.ids-mannheim.de/doc/ql/poliqarp-plus?embedded=true#spans) for collocations to be searched within. Defaults to |
exactFrequencies |
if FALSE, extrapolate observed co-occurrence frequencies from frequencies in search hits sample, otherwise retrieve exact co-occurrence frequencies |
stopwords |
vector of stopwords not to be considered as collocates |
seed |
seed for random page collecting order |
expand |
if TRUE, |
maxRecurse |
apply collocation analysis recursively |
addExamples |
If TRUE, examples for instances of collocations will be added in a column |
thresholdScore |
association score function (see |
threshold |
minimum value of |
localStopwords |
vector of stopwords that will not be considered as collocates in the current function call, but that will not be passed to recursive calls |
collocateFilterRegex |
allow only collocates matching the regular expression |
queryMissingScores |
if TRUE, attempt to retrieve corpus-based association scores for vc/collocate combinations that would otherwise be imputed, by re-querying the KorAP backend without applying the collocate frequency threshold |
missingScoreQuantile |
lower quantile (evaluated per association measure) that anchors the adaptive floor used for imputing missing scores between virtual corpora; a robust spread is subtracted from this anchor so the imputed values stay below the weakest observed scores |
vcLabel |
optional label override for the current virtual corpus (used internally when named VC collections are expanded) |
... |
more arguments will be passed to |
The collocation analysis is currently implemented on the client side, as some of the functionality is not yet provided by the KorAP backend. Mainly for this reason it is very slow (several minutes, up to hours), but on the other hand very flexible. You can, for example, perform the analysis in arbitrary virtual corpora, use complex node queries, and look for expression-internal collocates using the focus function (see examples and demo).
To increase speed at the cost of accuracy and possible false negatives, you can decrease searchHitsSampleLimit and/or topCollocatesLimit and/or set exactFrequencies to FALSE.
Note that some outdated non-DeReKo back-ends might not yet support returning tokenized matches (warning issued). In this case, the client library will fall back to client-side tokenization which might be slightly less accurate. This might lead to false negatives and to frequencies that differ from corresponding ones acquired via the web user interface.
A tibble where each row represents a candidate collocate for the requested node. Columns include (depending on the selected association measures):
node, collocate, vc, label: identifiers for the query node, collocate, virtual corpus, and optional label.
Frequency and contingency information such as frequency, O, O1, O2, E, leftContextSize, rightContextSize, and w.
Association measures (e.g. logDice, ll, mi, ...), one column per requested scorer.
Per-labelled association scores produced by multi-VC comparisons using the pattern <measure>_<label>.
Ranks per label/measure with the pattern rank_<label>_<measure> (1 is best) and the corresponding percentile ranks percentile_rank_<label>_<measure>.
Pairwise contrasts for two-label comparisons, e.g. delta_<measure>, delta_rank_<measure>, and delta_percentile_rank_<measure>.
Summary columns describing the strongest labels per measure (winner_*, runner_up_*, loser_*, and max_delta_*).
Optional helper columns such as query, example, or url when example retrieval is requested.
Other collocation analysis functions:
association-score-functions,
collocationScoreQuery,KorAPConnection-method,
synsemanticStopwords()
## Not run: # Find top collocates of "Packung" inside and outside the sports domain. KorAPConnection(verbose = TRUE) |> collocationAnalysis("Packung", vc = c("textClass=sport", "textClass!=sport"), leftContextSize = 1, rightContextSize = 1, topCollocatesLimit = 20 ) |> dplyr::filter(logDice >= 5) ## End(Not run) ## Not run: # Identify the most prominent light verb construction with "in ... setzen". # Note that, currently, the use of focus function disallows exactFrequencies. KorAPConnection(verbose = TRUE) |> collocationAnalysis("focus(in [tt/p=NN] {[tt/l=setzen]})", leftContextSize = 1, rightContextSize = 0, exactFrequencies = FALSE, topCollocatesLimit = 20 ) ## End(Not run)## Not run: # Find top collocates of "Packung" inside and outside the sports domain. KorAPConnection(verbose = TRUE) |> collocationAnalysis("Packung", vc = c("textClass=sport", "textClass!=sport"), leftContextSize = 1, rightContextSize = 1, topCollocatesLimit = 20 ) |> dplyr::filter(logDice >= 5) ## End(Not run) ## Not run: # Identify the most prominent light verb construction with "in ... setzen". # Note that, currently, the use of focus function disallows exactFrequencies. KorAPConnection(verbose = TRUE) |> collocationAnalysis("focus(in [tt/p=NN] {[tt/l=setzen]})", leftContextSize = 1, rightContextSize = 0, exactFrequencies = FALSE, topCollocatesLimit = 20 ) ## End(Not run)
Computes various collocation association scores
based on frequencyQuery()s for a target word and a collocate.
## S4 method for signature 'KorAPConnection' collocationScoreQuery( kco, node, collocate, vc = "", lemmatizeNodeQuery = FALSE, lemmatizeCollocateQuery = FALSE, leftContextSize = 5, rightContextSize = 5, scoreFunctions = defaultAssociationScoreFunctions(), smoothingConstant = 0.5, observed = NA, ignoreCollocateCase = FALSE, withinSpan = "base/s=s" )## S4 method for signature 'KorAPConnection' collocationScoreQuery( kco, node, collocate, vc = "", lemmatizeNodeQuery = FALSE, lemmatizeCollocateQuery = FALSE, leftContextSize = 5, rightContextSize = 5, scoreFunctions = defaultAssociationScoreFunctions(), smoothingConstant = 0.5, observed = NA, ignoreCollocateCase = FALSE, withinSpan = "base/s=s" )
kco |
|
node |
target word |
collocate |
collocate of target word |
vc |
string describing the virtual corpus in which the query should be performed. An empty string (default) means the whole corpus, as far as it is license-wise accessible. |
lemmatizeNodeQuery |
logical, set to TRUE if node query should be lemmatized, i.e. |
lemmatizeCollocateQuery |
logical, set to TRUE if collocate query should be lemmatized, i.e. |
leftContextSize |
size of the left context window |
rightContextSize |
size of the right context window |
scoreFunctions |
named list of score functions of the form function(O1, O2, O, N, E, window_size), see e.g. pmi |
smoothingConstant |
smoothing constant will be added to all observed values |
observed |
if collocation frequencies are already known (or estimated from a sample) they can be passed as a vector here, otherwise: NA |
ignoreCollocateCase |
logical, set to TRUE if collocate case should be ignored |
withinSpan |
KorAP span specification (see https://korap.ids-mannheim.de/doc/ql/poliqarp-plus?embedded=true#spans) for collocations to be searched within. Defaults to |
tibble with query KorAP web request URL, all observed values and association scores
Other collocation analysis functions:
association-score-functions,
collocationAnalysis,KorAPConnection-method,
synsemanticStopwords()
## Not run: KorAPConnection(verbose = TRUE) |> collocationScoreQuery("Grund", "triftiger") ## End(Not run) ## Not run: KorAPConnection(verbose = TRUE) |> collocationScoreQuery("Grund", c("guter", "triftiger"), scoreFunctions = list(localMI = function(O1, O2, O, N, E, window_size) { O * log2(O/E) }) ) ## End(Not run) ## Not run: library(highcharter) library(tidyr) 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") |> hchart(type="spline", hcaes(label, score, group=measure)) |> hc_add_onclick_korap_search() ## End(Not run)## Not run: KorAPConnection(verbose = TRUE) |> collocationScoreQuery("Grund", "triftiger") ## End(Not run) ## Not run: KorAPConnection(verbose = TRUE) |> collocationScoreQuery("Grund", c("guter", "triftiger"), scoreFunctions = list(localMI = function(O1, O2, O, N, E, window_size) { O * log2(O/E) }) ) ## End(Not run) ## Not run: library(highcharter) library(tidyr) 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") |> hchart(type="spline", hcaes(label, score, group=measure)) |> hc_add_onclick_korap_search() ## End(Not run)
corpusQuery performs a corpus query via a connection to a KorAP-API-server
## S4 method for signature 'KorAPConnection' corpusQuery( kco, query = if (missing(KorAPUrl)) { stop("At least one of the parameters query and KorAPUrl must be specified.", call. = FALSE) } else { httr2::url_parse(KorAPUrl)$query$q }, vc = if (missing(KorAPUrl)) "" else httr2::url_parse(KorAPUrl)$query$cq, KorAPUrl, metadataOnly = TRUE, ql = if (missing(KorAPUrl)) "poliqarp" else httr2::url_parse(KorAPUrl)$query$ql, fields = c("corpusSigle", "textSigle", "pubDate", "pubPlace", "availability", "textClass", "snippet", "tokens"), accessRewriteFatal = TRUE, verbose = kco@verbose, expand = length(vc) != length(query), as.df = FALSE, context = NULL )## S4 method for signature 'KorAPConnection' corpusQuery( kco, query = if (missing(KorAPUrl)) { stop("At least one of the parameters query and KorAPUrl must be specified.", call. = FALSE) } else { httr2::url_parse(KorAPUrl)$query$q }, vc = if (missing(KorAPUrl)) "" else httr2::url_parse(KorAPUrl)$query$cq, KorAPUrl, metadataOnly = TRUE, ql = if (missing(KorAPUrl)) "poliqarp" else httr2::url_parse(KorAPUrl)$query$ql, fields = c("corpusSigle", "textSigle", "pubDate", "pubPlace", "availability", "textClass", "snippet", "tokens"), accessRewriteFatal = TRUE, verbose = kco@verbose, expand = length(vc) != length(query), as.df = FALSE, context = NULL )
kco |
|
query |
string that contains the corpus query. The query language depends on the |
vc |
string describing the virtual corpus in which the query should be performed. An empty string (default) means the whole corpus, as far as it is license-wise accessible. |
KorAPUrl |
instead of providing the query and vc string parameters, you can also simply copy a KorAP query URL from your browser and use it here (and in |
metadataOnly |
logical that determines whether queries should return only metadata without any snippets. This can also be useful to prevent access rewrites. Note that the default value is TRUE.
If you want your corpus queries to return not only metadata, but also KWICS, you need to authorize
your RKorAPClient application as explained in the
authorization section
of the RKorAPClient Readme on GitHub and set the |
ql |
string to choose the query language (see section on Query Parameters in the Kustvakt-Wiki for possible values. |
fields |
character vector specifying which metadata fields to retrieve for each match. Available fields depend on the corpus. For DeReKo (German Reference Corpus), possible fields include:
Use |
accessRewriteFatal |
abort if query or given vc had to be rewritten due to insufficient rights (not yet implemented). |
verbose |
print some info |
expand |
logical that decides if |
as.df |
return result as data frame instead of as S4 object? |
context |
string that specifies the size of the left and the right context returned in |
Depending on the as.df parameter, a tibble or a KorAPQuery() object that, among other information, contains the total number of results in @totalResults. The resulting object can be used to fetch all query results (with fetchAll()) or the next page of results (with fetchNext()).
A corresponding URL to be used within a web browser is contained in @webUIRequestUrl
Please make sure to check $collection$rewrites to see if any unforeseen access rewrites of the query's virtual corpus had to be performed.
https://ids-pub.bsz-bw.de/frontdoor/index/index/docId/9026
KorAPConnection(), fetchNext(), fetchRest(), fetchAll(), corpusStats()
Other corpus search functions:
fetchAll,KorAPQuery-method,
fetchAnnotations,KorAPQuery-method,
fetchNext,KorAPQuery-method
## Not run: # Fetch basic metadata for "Ameisenplage" KorAPConnection() |> corpusQuery("Ameisenplage") |> fetchAll() # Fetch specific metadata fields for bibliographic analysis query <- KorAPConnection() |> corpusQuery("Ameisenplage", fields = c("textSigle", "author", "title", "pubDate", "pubPlace", "textType")) results <- fetchAll(query) results@collectedMatches ## End(Not run) ## Not run: # 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). KorAPConnection(verbose = TRUE) |> corpusQuery( KorAPUrl = "https://korap.ids-mannheim.de/?q=Ameise&cq=pubDate+since+2017&ql=poliqarp" ) ## End(Not run) ## Not run: # Plot the time/frequency curve of "Ameisenplage" KorAPConnection(verbose = TRUE) |> { . ->> kco } |> corpusQuery("Ameisenplage") |> fetchAll() |> slot("collectedMatches") |> mutate(year = lubridate::year(pubDate)) |> dplyr::select(year) |> group_by(year) |> summarise(Count = dplyr::n()) |> mutate(Freq = mapply(function(f, y) { f / corpusStats(kco, paste("pubDate in", y))@tokens }, Count, year)) |> dplyr::select(-Count) |> complete(year = min(year):max(year), fill = list(Freq = 0)) |> plot(type = "l") ## End(Not run)## Not run: # Fetch basic metadata for "Ameisenplage" KorAPConnection() |> corpusQuery("Ameisenplage") |> fetchAll() # Fetch specific metadata fields for bibliographic analysis query <- KorAPConnection() |> corpusQuery("Ameisenplage", fields = c("textSigle", "author", "title", "pubDate", "pubPlace", "textType")) results <- fetchAll(query) results@collectedMatches ## End(Not run) ## Not run: # 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). KorAPConnection(verbose = TRUE) |> corpusQuery( KorAPUrl = "https://korap.ids-mannheim.de/?q=Ameise&cq=pubDate+since+2017&ql=poliqarp" ) ## End(Not run) ## Not run: # Plot the time/frequency curve of "Ameisenplage" KorAPConnection(verbose = TRUE) |> { . ->> kco } |> corpusQuery("Ameisenplage") |> fetchAll() |> slot("collectedMatches") |> mutate(year = lubridate::year(pubDate)) |> dplyr::select(year) |> group_by(year) |> summarise(Count = dplyr::n()) |> mutate(Freq = mapply(function(f, y) { f / corpusStats(kco, paste("pubDate in", y))@tokens }, Count, year)) |> dplyr::select(-Count) |> complete(year = min(year):max(year), fill = list(Freq = 0)) |> plot(type = "l") ## End(Not run)
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)## S4 method for signature 'KorAPConnection' corpusStats(kco, vc = "", verbose = kco@verbose, as.df = FALSE)
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? |
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)## 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)
fetchAll fetches all results of a KorAP query.
## S4 method for signature 'KorAPQuery' fetchAll(kqo, verbose = kqo@korapConnection@verbose, ...)## S4 method for signature 'KorAPQuery' fetchAll(kqo, verbose = kqo@korapConnection@verbose, ...)
kqo |
object obtained from |
verbose |
print progress information if true |
... |
further arguments passed to |
The updated kqo object with all results in @collectedMatches
Other corpus search functions:
corpusQuery,KorAPConnection-method,
fetchAnnotations,KorAPQuery-method,
fetchNext,KorAPQuery-method
## Not run: # Fetch all metadata of every query hit for "Ameisenplage" and show a summary q <- KorAPConnection() |> corpusQuery("Ameisenplage") |> fetchAll() q@collectedMatches # Fetch also all KWICs q <- KorAPConnection() |> auth() |> corpusQuery("Ameisenplage", metadataOnly = FALSE) |> fetchAll() q@collectedMatches # Retrieve title and text sigle metadata of all texts published on 1958-03-12 q <- KorAPConnection() |> corpusQuery("<base/s=t>", # this matches each text once vc = "pubDate in 1958-03-12", fields = c("textSigle", "title"), ) |> fetchAll() q@collectedMatches ## End(Not run)## Not run: # Fetch all metadata of every query hit for "Ameisenplage" and show a summary q <- KorAPConnection() |> corpusQuery("Ameisenplage") |> fetchAll() q@collectedMatches # Fetch also all KWICs q <- KorAPConnection() |> auth() |> corpusQuery("Ameisenplage", metadataOnly = FALSE) |> fetchAll() q@collectedMatches # Retrieve title and text sigle metadata of all texts published on 1958-03-12 q <- KorAPConnection() |> corpusQuery("<base/s=t>", # this matches each text once vc = "pubDate in 1958-03-12", fields = c("textSigle", "title"), ) |> fetchAll() q@collectedMatches ## End(Not run)
S4 generic for fetching token annotations for collected matches. See specific methods, e.g. fetchAnnotations,KorAPQuery-method.
fetchAnnotations(kqo, foundry = "tt", overwrite = FALSE, verbose = kqo@korapConnection@verbose)fetchAnnotations(kqo, foundry = "tt", overwrite = FALSE, verbose = kqo@korapConnection@verbose)
kqo |
An object on which an annotation fetching method is defined. |
foundry |
Annotation foundry identifier. |
overwrite |
Logical flag controlling whether to overwrite existing annotations. |
verbose |
Logical flag for progress output. |
fetchAnnotations,KorAPQuery-method
## S4 method for signature 'KorAPQuery' fetchAnnotations( kqo, foundry = "tt", overwrite = FALSE, verbose = kqo@korapConnection@verbose )## S4 method for signature 'KorAPQuery' fetchAnnotations( kqo, foundry = "tt", overwrite = FALSE, verbose = kqo@korapConnection@verbose )
kqo |
object obtained from |
foundry |
string specifying the foundry to use for annotations (default: "tt" for Tree-Tagger) |
overwrite |
logical; if TRUE, re-fetch and replace any existing annotation columns. If FALSE (default), only add missing annotation layers and preserve already fetched ones (e.g., keep POS/lemma from a previous foundry while adding morph from another). |
verbose |
print progress information if true |
fetchAnnotations fetches annotations (only token annotations, for now)
for all matches in the @collectedMatches slot
of a KorAPQuery object and adds annotation columns directly to the @collectedMatches
data frame. The method uses the matchID from collected matches.
Important: For copyright-restricted corpora, users must be authorized via auth()
and the initial corpus query must have metadataOnly = FALSE to ensure snippets are
available for annotation parsing.
The method parses XML snippet annotations and adds linguistic columns to the data frame:
pos: data frame with left, match, right columns, each containing list vectors of part-of-speech tags
lemma: data frame with left, match, right columns, each containing list vectors of lemmas
morph: data frame with left, match, right columns, each containing list vectors of morphological tags
atokens: data frame with left, match, right columns, each containing list vectors of token text (from annotations)
annotation_snippet: original XML snippet from the annotation API
The updated kqo object with annotation columns
like pos, lemma, morph (and atokens and annotation_snippet)
in the @collectedMatches slot. Each column is a data frame
with left, match, and right columns containing list vectors of annotations
for the left context, matched tokens, and right context, respectively.
The original XML snippet for each match is also stored in annotation_snippet.
Other corpus search functions:
corpusQuery,KorAPConnection-method,
fetchAll,KorAPQuery-method,
fetchNext,KorAPQuery-method
## Not run: # Fetch annotations for matches using Tree-Tagger foundry # Note: Authorization required for copyright-restricted corpora q <- KorAPConnection() |> auth() |> corpusQuery("Ameisenplage", metadataOnly = FALSE) |> fetchNext(maxFetch = 10) |> fetchAnnotations() # Access linguistic annotations for match i: pos_tags <- q@collectedMatches$pos # Data frame with left/match/right columns for POS tags lemmas <- q@collectedMatches$lemma # Data frame with left/match/right columns for lemmas morphology <- q@collectedMatches$morph # Data frame with left/match/right columns for morphological tags atokens <- q@collectedMatches$atokens # Data frame with left/match/right columns for annotation token text # Original XML snippet for match i raw_snippet <- q@collectedMatches$annotation_snippet[[i]] # Access specific components: # POS tags for the matched tokens in match i match_pos <- q@collectedMatches$pos$match[[i]] # Lemmas for the left context in match i left_lemmas <- q@collectedMatches$lemma$left[[i]] # Token text for the right context in match i right_tokens <- q@collectedMatches$atokens$right[[i]] # Use a different foundry (e.g., MarMoT) q <- KorAPConnection() |> auth() |> corpusQuery("Ameisenplage", metadataOnly = FALSE) |> fetchNext(maxFetch = 10) |> fetchAnnotations(foundry = "marmot") q@collectedMatches$pos$left[1] # POS tags for the left context of the first match ## End(Not run)## Not run: # Fetch annotations for matches using Tree-Tagger foundry # Note: Authorization required for copyright-restricted corpora q <- KorAPConnection() |> auth() |> corpusQuery("Ameisenplage", metadataOnly = FALSE) |> fetchNext(maxFetch = 10) |> fetchAnnotations() # Access linguistic annotations for match i: pos_tags <- q@collectedMatches$pos # Data frame with left/match/right columns for POS tags lemmas <- q@collectedMatches$lemma # Data frame with left/match/right columns for lemmas morphology <- q@collectedMatches$morph # Data frame with left/match/right columns for morphological tags atokens <- q@collectedMatches$atokens # Data frame with left/match/right columns for annotation token text # Original XML snippet for match i raw_snippet <- q@collectedMatches$annotation_snippet[[i]] # Access specific components: # POS tags for the matched tokens in match i match_pos <- q@collectedMatches$pos$match[[i]] # Lemmas for the left context in match i left_lemmas <- q@collectedMatches$lemma$left[[i]] # Token text for the right context in match i right_tokens <- q@collectedMatches$atokens$right[[i]] # Use a different foundry (e.g., MarMoT) q <- KorAPConnection() |> auth() |> corpusQuery("Ameisenplage", metadataOnly = FALSE) |> fetchNext(maxFetch = 10) |> fetchAnnotations(foundry = "marmot") q@collectedMatches$pos$left[1] # POS tags for the left context of the first match ## End(Not run)
fetchNext fetches the next bunch of results of a KorAP query.
## S4 method for signature 'KorAPQuery' fetchNext( kqo, offset = kqo@nextStartIndex, maxFetch = maxResultsPerPage, verbose = kqo@korapConnection@verbose, randomizePageOrder = FALSE )## S4 method for signature 'KorAPQuery' fetchNext( kqo, offset = kqo@nextStartIndex, maxFetch = maxResultsPerPage, verbose = kqo@korapConnection@verbose, randomizePageOrder = FALSE )
kqo |
object obtained from |
offset |
start offset for query results to fetch |
maxFetch |
maximum number of query results to fetch |
verbose |
print progress information if true |
randomizePageOrder |
fetch result pages in pseudo random order if true. Use |
The kqo input object with updated slots collectedMatches, apiResponse, nextStartIndex, hasMoreMatches
https://ids-pub.bsz-bw.de/frontdoor/index/index/docId/9026
Other corpus search functions:
corpusQuery,KorAPConnection-method,
fetchAll,KorAPQuery-method,
fetchAnnotations,KorAPQuery-method
## Not run: q <- KorAPConnection() |> corpusQuery("Ameisenplage") |> fetchNext() q@collectedMatches ## End(Not run)## Not run: q <- KorAPConnection() |> corpusQuery("Ameisenplage") |> fetchNext() q@collectedMatches ## End(Not run)
Fetches the remaining results of a KorAP query.
## S4 method for signature 'KorAPQuery' fetchRest(kqo, verbose = kqo@korapConnection@verbose, ...)## S4 method for signature 'KorAPQuery' fetchRest(kqo, verbose = kqo@korapConnection@verbose, ...)
kqo |
object obtained from |
verbose |
print progress information if true |
... |
further arguments passed to |
The updated kqo object with remaining results in @collectedMatches
## Not run: q <- KorAPConnection() |> corpusQuery("Ameisenplage") |> fetchRest() q@collectedMatches ## End(Not run)## Not run: q <- KorAPConnection() |> corpusQuery("Ameisenplage") |> fetchRest() q@collectedMatches ## End(Not run)
frequencyQuery combines corpusQuery(), corpusStats() and
ci() to compute a tibble with the absolute and relative frequencies and
confidence intervals of one ore multiple search terms across one or multiple
virtual corpora.
## S4 method for signature 'KorAPConnection' frequencyQuery( kco, query, vc = "", conf.level = 0.95, as.alternatives = FALSE, ... )## S4 method for signature 'KorAPConnection' frequencyQuery( kco, query, vc = "", conf.level = 0.95, as.alternatives = FALSE, ... )
kco |
|
query |
corpus query string(s.) (can be a vector). The query language depends on the |
vc |
virtual corpus definition(s) (can be a vector) |
conf.level |
confidence level of the returned confidence interval (passed through |
as.alternatives |
LOGICAL that specifies if the query terms should be treated as alternatives. If |
... |
further arguments passed to or from other methods (see |
A tibble, with each row containing the following result columns for query and vc combinations:
query: the query string used for the frequency analysis.
totalResults: absolute frequency of query matches in the vc.
vc: virtual corpus used for the query.
webUIRequestUrl: URL of the corresponding web UI request with respect to query and vc.
total: total number of words in vc.
f: relative frequency of query matches in the vc.
conf.low: lower bound of the confidence interval for the relative frequency, given conf.level.
conf.high: upper bound of the confidence interval for the relative frequency, given conf.level.
## Not run: KorAPConnection(verbose = TRUE) |> frequencyQuery(c("Mücke", "Schnake"), paste0("pubDate in ", 2000:2003)) ## End(Not run)## Not run: KorAPConnection(verbose = TRUE) |> frequencyQuery(c("Mücke", "Schnake"), paste0("pubDate in ", 2000:2003)) ## End(Not run)
Adds on-click events to data points of highcharts that were constructed with
frequencyQuery() or collocationScoreQuery(). Clicks on data points
then launch KorAP web UI queries for the given query term and virtual corpus in
a separate tab.
hc_add_onclick_korap_search(hc)hc_add_onclick_korap_search(hc)
hc |
A highchart htmlwidget object generated by e.g. |
The input highchart object with added on-click events.
Other highcharter-helpers:
hc_freq_by_year_ci()
## Not run: library(highcharter) library(tidyr) KorAPConnection(verbose = TRUE) %>% collocationScoreQuery("Team", "agil", vc = paste("pubDate in", c(2014:2018)), lemmatizeNodeQuery = TRUE, lemmatizeCollocateQuery = TRUE) %>% pivot_longer(c("O", "E")) %>% hchart(type="spline", hcaes(label, value, group=name)) %>% hc_add_onclick_korap_search() ## End(Not run)## Not run: library(highcharter) library(tidyr) KorAPConnection(verbose = TRUE) %>% collocationScoreQuery("Team", "agil", vc = paste("pubDate in", c(2014:2018)), lemmatizeNodeQuery = TRUE, lemmatizeCollocateQuery = TRUE) %>% pivot_longer(c("O", "E")) %>% hchart(type="spline", hcaes(label, value, group=name)) %>% hc_add_onclick_korap_search() ## End(Not run)
Convenience function for plotting typical frequency by year graphs with confidence intervals using highcharter.
Warning: This function may be moved to a new package.
hc_freq_by_year_ci( df, as.alternatives = FALSE, ylabel = if (as.alternatives) "%" else "ipm", smooth = FALSE, ... )hc_freq_by_year_ci( df, as.alternatives = FALSE, ylabel = if (as.alternatives) "%" else "ipm", smooth = FALSE, ... )
df |
data frame like the value of a |
as.alternatives |
boolean decides whether queries should be treated as mutually exclusive and exhaustive wrt. to some meaningful class (e.g. spelling variants of a certain word form). |
ylabel |
defaults to |
smooth |
boolean decides whether the graph is smoothed using the highcharts plot types spline and areasplinerange. |
... |
additional arguments passed to |
A highchart htmlwidget object containing the frequency plot.
Other highcharter-helpers:
hc_add_onclick_korap_search()
## Not run: year <- c(1990:2018) alternatives <- c("macht []{0,3} Sinn", "ergibt []{0,3} Sinn") 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 <- KorAPConnection(verbose = TRUE) expand_grid( condition = c("textDomain = /Wirtschaft.*/", "textDomain != /Wirtschaft.*/"), year = (2005:2011) ) %>% cbind(frequencyQuery( kco, "[tt/l=Heuschrecke]", paste0(.$condition, " & pubDate in ", .$year) )) %>% hc_freq_by_year_ci() ## End(Not run)## Not run: year <- c(1990:2018) alternatives <- c("macht []{0,3} Sinn", "ergibt []{0,3} Sinn") 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 <- KorAPConnection(verbose = TRUE) expand_grid( condition = c("textDomain = /Wirtschaft.*/", "textDomain != /Wirtschaft.*/"), year = (2005:2011) ) %>% cbind(frequencyQuery( kco, "[tt/l=Heuschrecke]", paste0(.$condition, " & pubDate in ", .$year) )) %>% hc_freq_by_year_ci() ## End(Not run)
KorAPConnection() creates a connection to a KorAP server for corpus queries.
This is your starting point for all corpus analysis tasks.
KorAPUrl |
URL of the web user interface of the KorAP server instance you want to access.
Defaults to the environment variable |
apiVersion |
which version of KorAP's API you want to connect to. Defaults to "v1.0". |
apiUrl |
URL of the KorAP web service. If not provided, it will be constructed from KorAPUrl and apiVersion. |
accessToken |
OAuth2 access token. For queries on corpus parts with restricted access (e.g. textual queries on IPR protected data), you need to authorize your application with an access token. You can obtain an access token in the OAuth settings of your KorAP web interface. More details are explained in the authorization section of the RKorAPClient Readme on GitHub. To use authorization based on an access token in subsequent queries, initialize your KorAP connection with: kco <- KorAPConnection(accessToken="<access token>") In order to make the API
token persistent for the currently used persistAccessToken(kco) This will store it in your keyring using the
keyring::keyring-package. Subsequent KorAPConnection() calls will
then automatically retrieve the token from your keying. To stop using a
persisted token, call An alternative to using an access token is to use a browser-based oauth2 workflow
to obtain an access token. This can be done with the |
oauthClient |
OAuth2 client object. |
oauthScope |
OAuth2 scope. Defaults to "search match_info". |
authorizationSupported |
logical that indicates if authorization is supported/necessary for the current KorAP instance. Automatically set during initialization. |
userAgent |
user agent string. Defaults to "R-KorAP-Client". |
timeout |
timeout in seconds for API requests (this does not influence server internal timeouts). Defaults to 240 seconds. |
verbose |
logical that decides whether following operations will default to
be verbose. Defaults to FALSE. If not explicitly provided, this can be overridden
via environment variable |
cache |
logical that decides if API calls are cached locally. You can clear
the cache with |
Use KorAPConnection() to connect, then corpusQuery() to search, and
fetchAll() to retrieve results. For authorized access to restricted corpora,
use auth() or provide an accessToken.
The KorAPConnection object contains various configuration slots for advanced users: KorAPUrl (server URL), apiVersion, accessToken (OAuth2 token), timeout (request timeout), verbose (logging), cache (local caching), and other technical parameters. Most users can ignore these implementation details.
KorAPConnection() object that can be used e.g. with corpusQuery()
# Connect to KorAP kcon <- KorAPConnection() # Search for a term query <- corpusQuery(kcon, "Ameisenplage") # Get all results results <- fetchAll(query)
For access to restricted corpora, authorize your connection:
kcon <- KorAPConnection() |> auth()
Other initialization functions:
auth,KorAPConnection-method,
clearAccessToken,KorAPConnection-method,
persistAccessToken,KorAPConnection-method
Merge duplicate collocate rows and re-calculate association scores and URLs. Useful if collocation analyses were performed separately for collocates on the left and right side of a node.
mergeDuplicateCollocates(..., smoothingConstant = 0.5)mergeDuplicateCollocates(..., smoothingConstant = 0.5)
... |
tibbles with collocate rows returned from |
smoothingConstant |
original smoothing constant (to be added only once to the observed values) |
tibble with unique collocate rows
Persist current access token in keyring
## S4 method for signature 'KorAPConnection' persistAccessToken(kco, accessToken = kco@accessToken)## S4 method for signature 'KorAPConnection' persistAccessToken(kco, accessToken = kco@accessToken)
kco |
KorAPConnection object |
accessToken |
access token to be persisted. If not supplied, the current access token of the KorAPConnection object will be used. |
KorAPConnection object.
Other initialization functions:
KorAPConnection-class,
auth,KorAPConnection-method,
clearAccessToken,KorAPConnection-method
## Not run: kco <- KorAPConnection(accessToken = "e739u6eOzkwADQPdVChxFg") persistAccessToken(kco) kco <- KorAPConnection() %>% auth(app_id = "<my application id>") %>% persistAccessToken() ## End(Not run)## Not run: kco <- KorAPConnection(accessToken = "e739u6eOzkwADQPdVChxFg") persistAccessToken(kco) kco <- KorAPConnection() %>% auth(app_id = "<my application id>") %>% persistAccessToken() ## End(Not run)
Preliminary synsemantic stopwords function to be used in collocation analysis.
synsemanticStopwords(...)synsemanticStopwords(...)
... |
future arguments for language detection |
Currently only suitable for German. See stopwords package for other languages.
Vector of synsemantic stopwords.
Other collocation analysis functions:
association-score-functions,
collocationAnalysis,KorAPConnection-method,
collocationScoreQuery,KorAPConnection-method
Retrieves metadata for a text, identified by its sigle (id) using the corresponding KorAP API
(see Kustvakt Wiki).
To retrieve the metadata for every text in a virtual corpus, use corpusQuery()
with <base/s=t> as query, instead.
## S4 method for signature 'KorAPConnection' textMetadata(kco, textSigle, verbose = kco@verbose)## S4 method for signature 'KorAPConnection' textMetadata(kco, textSigle, verbose = kco@verbose)
kco |
|
textSigle |
unique text id (concatenation of corpus, document and text ids, separated by |
verbose |
logical. If |
Tibble with columns for each metadata property. In case of errors, such as non-existing texts/sigles, the tibble will also contain a column called errors.
If there are metadata columns you cannot make sense of, please ignore them. The function simply returns all the metadata it gets from the server.
## Not run: KorAPConnection() |> textMetadata(c("WUD17/A97/08542", "WUD17/B96/57558", "WUD17/A97/08541")) ## End(Not run)## Not run: KorAPConnection() |> textMetadata(c("WUD17/A97/08542", "WUD17/B96/57558", "WUD17/A97/08541")) ## End(Not run)