corpusPartition: Define corpus parts for a dispersion analysis

View source: R/dispersionQuery.R

corpusPartitionR Documentation

Define corpus parts for a dispersion analysis

Description

Discover metadata groups and their token counts, or define a custom partition. Discovery checks the base corpus independently of query hits, so that parts without hits are retained without downloading the corpus.

Usage

corpusPartition(
  kco,
  by,
  values = NULL,
  vc = "",
  parts = NULL,
  classify = NULL,
  fields = NULL,
  verbose = kco@verbose,
  cacheAs = NULL,
  regex = NULL
)

Arguments

kco

A KorAPConnection() object.

by

Metadata field. The aliases source, year and region stand for corpusTitle, pubDate (publication year) and pubPlaceKey respectively.

values

Vector of metadata values; optional names label the parts. If neither values nor parts is supplied, discover the groups automatically. Four-digit values for pubDate or creationDate define years. Other fields use literal equality. Use the stored region keys, not place names. Corpus titles may include publication years. To group annual corpora by source, use by = "source", as in demo("dispersion"). Custom parts and a matching classify function support other groupings.

vc

Base virtual corpus. All parts are intersected with this corpus.

parts

Alternatively, a uniquely named vector of virtual-corpus definitions. For sampling arbitrary definitions, also provide classify.

classify

Optional function of a matches data frame returning one part label per row, or NA for excluded/missing metadata. Its membership rules must agree with parts. Multivalued fields require an explicit classifier.

fields

Metadata fields needed by classify; defaults to by.

verbose

Whether to print progress.

cacheAs

Optional result file; see frequencyQuery().

regex

Optional trailing-suffix grouping rule for automatic discovery; see dispersionAnalysis,KorAPQuery-method. Defaults to removing a year suffix for by = "source".

Value

A tibble of class KorAPCorpusPartition with part, value, vc, and tokens columns. Attributes record the metadata mapping, base corpus, server, index revision, covered tokens and excluded tokens. Overlapping parts are rejected by comparing their summed sizes with their union. An incomplete inventory explicitly restricts the population to its union, with a warning; it does not silently stand for the whole base corpus.

Examples

## Not run: 
kco <- KorAPConnection()
years <- corpusPartition(kco, "year", 2020:2022, vc = "referTo ratskorpus")
countries <- corpusPartition(kco, "region", c("DE", "AT", "CH"))
dispersionQuery(kco, "NutzerInnen", partitions = list(year = years))

## End(Not run)

RKorAPClient documentation built on Nov. 12, 2026, 5:11 p.m.