query,kRp.corpus-method {tm.plugin.koRpus} | R Documentation |
Apply query() to all texts in kRp.corpus objects
Description
This method calls query
on all tagged text objects
inside the given object.
Usage
## S4 method for signature 'kRp.corpus'
query(
obj,
var,
query,
rel = "eq",
as.df = TRUE,
ignore.case = TRUE,
perl = FALSE,
regexp_var = "token"
)
Arguments
obj |
An object of class |
var |
A character string naming a column in the tagged text. If set to
|
query |
A character vector (for words), regular expression,
or single number naming values to be matched in the variable.
Can also be a vector of two numbers to query a range of frequency data,
or a list of named lists for multiple queries (see
"Query lists" section of |
rel |
A character string defining the relation of the queried value and desired results.
Must either be |
as.df |
Logical, if |
ignore.case |
Logical, passed through to |
perl |
Logical, passed through to |
regexp_var |
A character string naming the column to query if |
Value
Depending on the arguments, might include whole objects, lists, single values etc.
Examples
# use readCorpus() to create an object of class kRp.corpus
# code is only run when the english language package can be loaded
if(require("koRpus.lang.en", quietly = TRUE)){
myCorpus <- readCorpus(
dir=file.path(
path.package("tm.plugin.koRpus"), "examples", "corpus", "Edwards"
),
hierarchy=list(
Source=c(
Wikipedia_prev="Wikipedia (old)",
Wikipedia_new="Wikipedia (new)"
)
),
# use tokenize() so examples run without a TreeTagger installation
tagger="tokenize",
lang="en"
)
query(myCorpus, var="lttr", query="7", rel="gt")
} else {}