| context-class {polmineR} | R Documentation |
Context class.
Description
Class to organize information of context analysis.
Usage
## S4 method for signature 'context'
length(x)
## S4 method for signature 'context'
p_attributes(.Object)
## S4 method for signature 'context'
count(.Object)
## S4 method for signature 'context'
sample(x, size)
## S4 method for signature 'context'
enrich(
.Object,
s_attribute = NULL,
p_attribute = NULL,
decode = FALSE,
stat = FALSE,
verbose = TRUE,
...
)
## S4 method for signature 'context'
as.regions(x, node = TRUE)
## S4 method for signature 'context'
trim(
.Object,
s_attribute = NULL,
positivelist = NULL,
p_attribute = p_attributes(.Object),
regex = FALSE,
stoplist = NULL,
fn = NULL,
verbose = TRUE,
progress = TRUE,
...
)
Arguments
x |
A |
.Object |
A |
size |
An |
s_attribute |
The s-attribute(s) to add to |
p_attribute |
The p-attribute(s) to add to |
decode |
A |
stat |
A |
verbose |
A |
... |
To maintain backwards compatibility if argument |
node |
A logical value, whether to include the node (i.e. query matches) in the region matrix
generated when creating a |
positivelist |
Tokens that are required to be present to keep a match. |
regex |
A |
stoplist |
Tokens that are used to exclude a match. |
fn |
A function that will be applied on context tables splitted by match_id. |
progress |
A |
Details
Objects of the class context include a data.table in the
slot cpos. The data.table will at least include the columns "match_id",
"cpos" and "position".
The length-method will return the number of hits that were achieved.
The enrich()-method can be used to add additional information to
the data.table in the cpos-slot of a context-object.
Slots
queryThe query examined (
character).countAn
integervalue, the number of hits for the query.partitionThe
partitionthecontextobject is based on.size_partitionThe size of the partition, a length-one
integervector.leftA length-one
integervalue, the number of tokens to the left of the query match.rightAn
integervalue, the number of tokens to the right of the query match.sizeA length-one
integervalue, the number of tokens covered by thecontext-object, i.e. the number of tokens in the right and left context of the node as well as query matches.size_matchA length-one
integervalue, the number of tokens matches by the query. Identical with the value in slotcountif the query is not a CQP query.size_coiA length-one
integervalue, the number of tokens in the right and left context of the node (excluding query matches).size_refA length-one
integervalue, the number of tokens in the partition, without tokens matched and the tokens in the left and right context.boundaryAn s-attribute (
character).p_attributeThe p-attribute of the query (
character).corpusThe CWB corpus used (
character).statA
data.table, the statistics of the analysis.encodingObject of class
character, encoding of the corpus.cposA
data.table, with the columns match_id, cpos, position, word_id.methodA
character-vector, statistical test used.callObject of class
character, call that generated the object.
Examples
# Keep matches for 'oil' only if first position to the left is 'crude'
.fn <- function(x) if (x[position == -1L][["word"]] == "crude") x else NULL
crude_oil <- context("REUTERS", "oil") %>%
enrich(p_attribute = "word", decode = TRUE) %>%
trim(fn = .fn)