count | R Documentation |
Count all tokens, or number of occurrences of a query (CQP syntax may be used), or matches for the query.
count(.Object, ...)
## S4 method for signature 'partition'
count(
.Object,
query = NULL,
cqp = is.cqp,
check = TRUE,
breakdown = FALSE,
decode = TRUE,
p_attribute = getOption("polmineR.p_attribute"),
mc = getOption("polmineR.cores"),
verbose = TRUE,
progress = FALSE,
phrases = NULL,
...
)
## S4 method for signature 'subcorpus'
count(
.Object,
query = NULL,
cqp = is.cqp,
check = TRUE,
breakdown = FALSE,
decode = TRUE,
p_attribute = getOption("polmineR.p_attribute"),
mc = getOption("polmineR.cores"),
verbose = TRUE,
progress = FALSE,
phrases = NULL,
...
)
## S4 method for signature 'partition_bundle'
count(
.Object,
query = NULL,
cqp = FALSE,
p_attribute = getOption("polmineR.p_attribute"),
phrases = NULL,
freq = FALSE,
total = TRUE,
mc = FALSE,
progress = FALSE,
verbose = FALSE,
...
)
## S4 method for signature 'subcorpus_bundle'
count(
.Object,
query = NULL,
cqp = FALSE,
p_attribute = NULL,
phrases = NULL,
freq = FALSE,
total = TRUE,
mc = FALSE,
progress = TRUE,
verbose = FALSE,
...
)
## S4 method for signature 'corpus'
count(
.Object,
query = NULL,
cqp = is.cqp,
check = TRUE,
p_attribute = getOption("polmineR.p_attribute"),
breakdown = FALSE,
sort = FALSE,
decode = TRUE,
verbose = TRUE,
...
)
## S4 method for signature 'character'
count(
.Object,
query = NULL,
cqp = is.cqp,
check = TRUE,
p_attribute = getOption("polmineR.p_attribute"),
breakdown = FALSE,
sort = FALSE,
decode = TRUE,
verbose = TRUE,
...
)
## S4 method for signature 'vector'
count(.Object, corpus, p_attribute, ...)
## S4 method for signature 'remote_corpus'
count(.Object, ...)
## S4 method for signature 'remote_subcorpus'
count(.Object, ...)
.Object |
A |
... |
Further arguments. If |
query |
A character vector (one or multiple terms), CQP syntax can be used. |
cqp |
Either logical ( |
check |
A |
breakdown |
Logical, whether to report number of occurrences for different matches for a query. |
decode |
Logical, whether to turn token ids into decoded strings (only if query is NULL). |
p_attribute |
The p-attribute(s) to use. |
mc |
Logical, whether to use multicore (defaults to |
verbose |
Logical, whether to be verbose. |
progress |
Logical, whether to show progress bar. |
phrases |
A |
freq |
Logical, if |
total |
Defaults to |
sort |
Logical, whether to sort table with counts (in stat slot). |
corpus |
The name of a CWB corpus. |
If .Object
is a partiton_bundle
, the data.table
returned will
have the queries in the columns, and as many rows as there are in the
partition_bundle
.
If .Object
is a length-one character
vector and query
is
NULL
, the count is performed for the whole partition.
If breakdown
is TRUE
and one query is supplied, the function
returns a frequency breakdown of the results of the query. If several queries
are supplied, frequencies for the individual queries are retrieved.
Multiple queries can be used for argument query
. Some care may be
necessary when summing up the counts for the individual queries. When the
CQP syntax is used, different queries may yield the same match result, so that
the sum of all individual query matches may overestimate the true number of
unique matches. In the case of overlapping matches, a warning message is
issued. Collapsing multiple CQP queries into a single query (separating the
individual queries by "|" and wrapping everything in round brackets) solves
this problem.
A data.table
if argument query is used, a count
-object,
if query is NULL
and .Object
is a character vector (referring
to a corpus) or a partition
, a count_bundle
-object, if .Object
is a partition_bundle
.
Baker, Paul (2006): Using Corpora in Discourse Analysis. London: continuum, p. 47-69 (ch. 3).
For a metadata-based breakdown of counts (i.e. tabulation by
s-attributes), see dispersion
. The hits
is the
worker behind the dispersion
method and offers a similar, yet more
low-level functionality as compared to the count
method. Using the
hits
method may be useful to obtain the data required for
flexible cross-tabulations.
use("polmineR")
use(pkg = "RcppCWB", corpus = "REUTERS")
debates <- partition("GERMAPARLMINI", date = ".*", regex=TRUE)
count(debates, query = "Arbeit") # get frequencies for one token
count(debates, c("Arbeit", "Freizeit", "Zukunft")) # get frequencies for multiple tokens
count("GERMAPARLMINI", query = c("Migration", "Integration"), p_attribute = "word")
debates <- partition_bundle(
"GERMAPARLMINI", s_attribute = "date", values = NULL,
mc = FALSE, verbose = FALSE
)
y <- count(debates, query = "Arbeit", p_attribute = "word")
y <- count(debates, query = c("Arbeit", "Migration", "Zukunft"), p_attribute = "word")
count("GERMAPARLMINI", '"Integration.*"', breakdown = TRUE)
P <- partition("GERMAPARLMINI", date = "2009-11-11")
count(P, '"Integration.*"', breakdown = TRUE)
sc <- corpus("GERMAPARLMINI") %>% subset(party == "SPD")
phr <- cpos(sc, query = '"Deutsche.*" "Bundestag.*"', cqp = TRUE) %>%
as.phrases(corpus = "GERMAPARLMINI", enc = "latin1")
cnt <- count(sc, phrases = phr, p_attribute = "word")
# Multiple queries and overlapping query matches. The first count
# operation will issue a warning that matches overlap, see the second
# example for a solution.
corpus("REUTERS") %>%
count(query = c('".*oil"', '"turmoil"'), cqp = TRUE)
corpus("REUTERS") %>%
count(query = '"(.*oil|turmoil)"', cqp =TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.