The method returns a data.table with the number of matches of a query or multiple queries (optionally frequencies) in a corpus or subcorpus as partitioned by one or two s-attributes.

dispersion(.Object, ...)

# S4 method for class 'slice'
dispersion(
  .Object,
  query,
  s_attribute,
  cqp = FALSE,
  p_attribute = getOption("polmineR.p_attribute"),
  freq = FALSE,
  fill = TRUE,
  mc = FALSE,
  progress = FALSE,
  verbose = FALSE,
  ...
)

# S4 method for class 'partition'
dispersion(
  .Object,
  query,
  s_attribute,
  cqp = FALSE,
  p_attribute = getOption("polmineR.p_attribute"),
  freq = FALSE,
  fill = TRUE,
  mc = FALSE,
  progress = TRUE,
  verbose = FALSE,
  ...
)

# S4 method for class 'subcorpus'
dispersion(
  .Object,
  query,
  s_attribute,
  cqp = FALSE,
  p_attribute = getOption("polmineR.p_attribute"),
  freq = FALSE,
  fill = FALSE,
  mc = FALSE,
  progress = TRUE,
  verbose = FALSE,
  ...
)

# S4 method for class 'corpus'
dispersion(
  .Object,
  query,
  s_attribute,
  cqp = is.cqp,
  p_attribute = getOption("polmineR.p_attribute"),
  freq = FALSE,
  fill = TRUE,
  mc = FALSE,
  progress = FALSE,
  verbose = FALSE,
  ...
)

# S4 method for class 'character'
dispersion(
  .Object,
  query,
  s_attribute,
  cqp = is.cqp,
  p_attribute = getOption("polmineR.p_attribute"),
  freq = FALSE,
  fill = TRUE,
  mc = FALSE,
  progress = TRUE,
  verbose = TRUE,
  ...
)

# S4 method for class 'hits'
dispersion(
  .Object,
  source,
  s_attribute,
  freq = FALSE,
  fill = TRUE,
  verbose = TRUE,
  ...
)

# S4 method for class 'remote_corpus'
dispersion(.Object, ...)

# S4 method for class 'remote_subcorpus'
dispersion(.Object, ...)

Arguments

.Object

A corpus, subcorpus or partition object or a corpus provided by a character string.

...

Further parameters.

query

A character vector stating one or multiple queries.

s_attribute

A character vector (length 1 or 2) providing s-attributes.

cqp

If logical, whether the query is a CQP query, if it is a function that is passed in, the function will be applied to the query to guess whether query is a CQP query

p_attribute

Length one character vector, the p-attribute that will be looked up (typically 'word' or 'lemma').

freq

A logical value, whether to calculate normalized frequencies.

fill

A logical value, whether to report zero matches. Defaults to TRUE. But note that if there are few matches and many values of the s-attribute(s), the resulting data structure is sparse and potentially bloated.

mc

A logical value, whether to use multicore.

progress

A logical value, whether to show progress.

verbose

A logical value, whether to be verbose.

source

The source of the evaluation the hits reported in .Object are based on, a corpus, subcorpus or partition object.

Value

A data.table.

A data.table.

Details

Augmenting the data.table with zeros for subcorpora that do not yield query matches (argument fill = TRUE) may require adding many new columns. A respective warning issued by the data.table package is supplemented an additional explanatory note of the polmineR package.

See also

The worker behind the dispersion-method is the hits-method.

count

Author

Andreas Blaette

Examples

use("polmineR")
#> ✔ corpus loaded: GERMAPARLMINI (version: 0.1.0 | build date: 2023-04-16)
dispersion("GERMAPARLMINI", query = "Integration", s_attribute = "date")
#>          query       date count
#>         <char>     <char> <int>
#> 1: Integration 2009-10-27     1
#> 2: Integration 2009-10-28     0
#> 3: Integration 2009-11-10     7
#> 4: Integration 2009-11-11    15
#> 5: Integration 2009-11-12     0

test <- partition("GERMAPARLMINI", date = ".*", p_attribute = NULL, regex = TRUE)
#> ... get cpos and strucs
integration <- dispersion(
  test, query = "Integration",
  p_attribute = "word", s_attribute = "date"
)
integration <- dispersion(test, "Integration", s_attribute = c("date", "party"))
integration <- dispersion(test, '"Integration.*"', s_attribute = "date", cqp = TRUE)