Retrieve the word context of a token, optionally checking for boundaries of a XML region.
context(.Object, ...)# S4 method for slice
context(
.Object,
query,
cqp = is.cqp,
check = TRUE,
left = getOption("polmineR.left"),
right = getOption("polmineR.right"),
p_attribute = getOption("polmineR.p_attribute"),
region = NULL,
boundary = NULL,
stoplist = NULL,
positivelist = NULL,
regex = FALSE,
count = TRUE,
mc = getOption("polmineR.mc"),
verbose = FALSE,
progress = TRUE,
...
)
# S4 method for partition
context(
.Object,
query,
cqp = is.cqp,
check = TRUE,
left = getOption("polmineR.left"),
right = getOption("polmineR.right"),
p_attribute = getOption("polmineR.p_attribute"),
region = NULL,
boundary = NULL,
stoplist = NULL,
positivelist = NULL,
regex = FALSE,
count = TRUE,
mc = getOption("polmineR.mc"),
verbose = FALSE,
progress = TRUE,
...
)
# S4 method for subcorpus
context(
.Object,
query,
cqp = is.cqp,
check = TRUE,
left = getOption("polmineR.left"),
right = getOption("polmineR.right"),
p_attribute = getOption("polmineR.p_attribute"),
region = NULL,
boundary = NULL,
stoplist = NULL,
positivelist = NULL,
regex = FALSE,
count = TRUE,
mc = getOption("polmineR.mc"),
verbose = FALSE,
progress = TRUE,
...
)
# S4 method for matrix
context(
.Object,
corpus,
registry = Sys.getenv("CORPUS_REGISTRY"),
left,
right,
p_attribute,
region = NULL,
boundary = NULL
)
# S4 method for corpus
context(
.Object,
query,
cqp = is.cqp,
p_attribute = getOption("polmineR.p_attribute"),
region = NULL,
boundary = NULL,
left = getOption("polmineR.left"),
right = getOption("polmineR.right"),
stoplist = NULL,
positivelist = NULL,
regex = FALSE,
count = TRUE,
mc = getOption("polmineR.mc"),
verbose = FALSE,
progress = TRUE,
...
)
# S4 method for character
context(
.Object,
query,
cqp = is.cqp,
p_attribute = getOption("polmineR.p_attribute"),
region = NULL,
boundary = NULL,
left = getOption("polmineR.left"),
right = getOption("polmineR.right"),
stoplist = NULL,
positivelist = NULL,
regex = FALSE,
count = TRUE,
mc = getOption("polmineR.mc"),
verbose = FALSE,
progress = TRUE,
...
)
# S4 method for partition_bundle
context(
.Object,
query,
p_attribute,
stoplist = NULL,
positivelist = NULL,
regex = FALSE,
verbose = TRUE,
...
)
# S4 method for cooccurrences
context(.Object, query, check = TRUE, complete = FALSE)
depending on whether a partition or a partition_bundle serves as
input, the return will be a context object, or a context_bundle object.
Note that the number of objects in the context_bundle may differ from the
number of objects in the input bundle object: NULL objects that result
if no hit is obtained are dropped.
a partition or a partition_bundle object
Further parameters.
A query, which may by a character vector or a CQP query.
defaults to is.cqp-function, or provide TRUE/FALSE
A logical value, whether to check validity of CQP query using
check_cqp_query.
A single integer value defining the number of tokens to the
left of the query match to include in the context. Advanced usage: (a) If
left is a length-one character vector stating an s-attribute, the
context will be expanded to the (left) boundary of the region where the
match occurs. (b) If left is a named length-one integer vector, this
value is the number regions of the structural attribute referred to by the
vector's name to the left of the query match that are included in the
context.
A single integer value, a length-one character vector or a
named length-one integer value, with equivalent effects to argument
left.
The p-attribute of the query.
An s-attribute, given by a length-one character vector.
The context of query matches will be expanded to the left and right
boundary of the region where the match is located. If arguments left and
right are > 1, the left and right boundaries of the respective number of
regions will be identified.
If provided, a length-one character vector specifying a s-attribute. It will be checked that corpus positions do not extend beyond the region defined by the s-attribute.
Exclude match for query if stopword(s) is/are are present in context. See positivelist for further explanation.
A character vector or numeric/integer vector:
include a query hit only if token in positivelist is present. If
positivelist is a character vector, it may include regular expressions
(see parameter regex).
A logical value, defaults to FALSE - whether stoplist
and/or positivelist are regular expressions.
logical
Whether to use multicore; if NULL (default), the function will get
the value from the options.
Report progress? A logical value, defaults to TRUE.
A logical value, whether to show progress bar.
A length-one character vector stating a corpus ID.
The registry directory with the registry file for corpus.
enhance completely
Andreas Blaette
For formulating the query, CPQ syntax may be used (see examples). Statistical tests available are log-likelihood, t-test, pmi.
If .Object is a matrix, the context-method will call
RcppCWB::region_matrix_context(), the worker behind the
context()-method.
use("polmineR")
p <- partition("GERMAPARLMINI", interjection = "speech")
y <- context(p, query = "Integration", p_attribute = "word")
y <- context(p, query = "Integration", p_attribute = "word", positivelist = "Bildung")
y <- context(
p, query = "Integration", p_attribute = "word",
positivelist = c("[aA]rbeit.*", "Ausbildung"), regex = TRUE
)
Run the code above in your browser using DataLab