Get hits for queries, optionally with s-attribute values.
hits(.Object, ...)
# S4 method for class 'corpus'
hits(
.Object,
query,
cqp = FALSE,
check = TRUE,
s_attribute,
p_attribute = "word",
size = FALSE,
freq = FALSE,
decode = TRUE,
fill = FALSE,
mc = 1L,
verbose = TRUE,
progress = FALSE,
...
)
# S4 method for class 'character'
hits(
.Object,
query,
cqp = FALSE,
check = TRUE,
s_attribute,
p_attribute = "word",
size = FALSE,
freq = FALSE,
decode = TRUE,
mc = FALSE,
verbose = TRUE,
progress = FALSE,
...
)
# S4 method for class 'subcorpus'
hits(
.Object,
query,
cqp = FALSE,
check = TRUE,
s_attribute,
p_attribute = "word",
size = FALSE,
freq = FALSE,
fill = FALSE,
decode = TRUE,
mc = FALSE,
progress = FALSE,
verbose = TRUE,
...
)
# S4 method for class 'partition'
hits(
.Object,
query,
cqp = FALSE,
check = TRUE,
s_attribute,
p_attribute = "word",
size = FALSE,
freq = FALSE,
fill = FALSE,
decode = TRUE,
mc = FALSE,
progress = FALSE,
verbose = TRUE
)
# S4 method for class 'partition_bundle'
hits(
.Object,
query,
cqp = FALSE,
check = TRUE,
p_attribute = getOption("polmineR.p_attribute"),
s_attribute,
size = TRUE,
freq = FALSE,
mc = getOption("polmineR.mc"),
progress = FALSE,
verbose = TRUE,
...
)
# S4 method for class 'context'
hits(.Object, s_attribute = NULL, verbose = TRUE, ...)
# S4 method for class 'remote_corpus'
hits(.Object, ...)
# S4 method for class 'remote_subcorpus'
hits(.Object, ...)A length-one character vector with a corpus ID, a
partition or partition_bundle object
Further arguments (used for backwards compatibility).
A character vector (optionally named, see details) with one or
more queries.
Either a logical value (TRUE if query is a CQP query), or a
function to check whether query is a CQP query or not.
A logical value, whether to check validity of CQP query using
check_cqp_query.
A character vector of s-attributes that will be
used to breakdown counts for matches for query/queries.
A character vector stating a p-attribute.
A logical value, whether to report the size of subcorpus.
A logcial value, whether to report relative frequencies.
A logical value, whether to decode s-attributes. If FALSE,
the integer values of strucs are reported in the table with matches.
A logical value, whethet to report counts (optionally
frequencies) for combinations of s-attributes where not matchers occurr.
A logical value, whether to use multicore.
A logical value, whether to output messages.
A logical value, whether to show progress bar.
A hits class object.
If the character vector provided by query is named, these names will be
reported in the data.table that is returned rather than the queries.
If freq is TRUE, the data.table returned in the DT-slot will
deliberately include the subsets of the partition/corpus with no hits
(query is NA, count is 0).
See the documentation of the hits class
(hits-class) for details.
use(pkg = "RcppCWB", corpus = "REUTERS")
#> ✔ corpus loaded: REUTERS
# get hits for corpus object
y <- corpus("REUTERS") %>% hits(query = "oil")
y <- corpus("REUTERS") %>% hits(query = c("oil", "barrel"))
y <- corpus("REUTERS") %>% hits(query = "oil", s_attribute = "places", freq = TRUE)
#> ℹ getting sizes
#> ... getting sizes
#> ✔ getting sizes [11ms]
#>
#> ℹ calculate frequencies
#> ✔ calculate frequencies [6ms]
#>
# specify corpus by corpus ID
y <- hits("REUTERS", query = "oil")
y <- hits("REUTERS", query = "oil", s_attribute = "places", freq = TRUE)
#> ℹ getting sizes
#> ... getting sizes
#> ✔ getting sizes [12ms]
#>
#> ℹ calculate frequencies
#> ✔ calculate frequencies [6ms]
#>
# get hits for partition
p <- partition("REUTERS", places = "saudi-arabia", regex = TRUE)
#> ... get cpos and strucs
y <- hits(p, query = "oil", s_attribute = "id")
# get hits for subcorpus
y <- corpus("REUTERS") %>%
subset(grep("saudi-arabia", places)) %>%
hits(query = "oil")