S4 class for organizing information for kwic/concordance output. A set of
standard generics (show
, as.character
, as.data.frame
,
length
, sample
, subset
) as well as indexing is implemented to process
kwic class objects (see 'Usage'). See section 'Details' for the
enrich
, view
and knit_print
methods.
# S4 method for kwic
show(object)# S4 method for kwic
knit_print(x,
pagelength = getOption("polmineR.pagelength"),
options = knitr::opts_chunk, ...)
# S4 method for kwic
as.character(x, fmt = "%s")
# S4 method for kwic,ANY,ANY,ANY
[(x, i)
# S4 method for kwic
subset(x, ...)
# S4 method for kwic
as.data.frame(x)
# S4 method for kwic
length(x)
# S4 method for kwic
sample(x, size)
# S4 method for kwic
enrich(.Object, s_attributes = NULL, table = FALSE,
...)
# S4 method for kwic
view(.Object)
A kwic
class object.
A kwic
class object.
The number of kwic lines displayed per page in the datatables htmlwidget that is returned.
Chunk options.
Used for backwards compatibility.
A format string passed into sprintf
to format the node of a KWIC display.
Single integer value, the kwic line for which the fulltext shall be inspected.
An integer
, subset size for sampling.
A kwic
class object.
Character vector of s-attributes with metainformation.
Logical, whether to turn cpos data.table
into data.frame
for output.
metadata
A character
vector with s-attributes of the metadata
that are to be displayed.
p_attribute
The p-attribute for which the context has been generated.
left
An integer
value, words to the left of the query match.
right
An integer
value, words to the right of the query match.
corpus
Length-one character
vector, the CWB corpus.
cpos
A data.table
with the columns "hit_no", "cpos", "position", "word_id", "word" and "direction".
table
A data.frame
, a table with columns "left", "node", "right", and metadata, if the object has been enriched.
encoding
A length-one character
vector with the encoding of the corpus.
labels
A character
vector with labels.
categories
A character
vector.
The knit_print
will be called by knitr when processing code
chunks in Rmarkdown documents to include a htmlwidget
into the
resulting html document. It may be necessary to explicitly state
"render=knit_print" in the chunk options.
The subset
-method will apply subset
to the table in
the slot table
, for filtering query results based on metadata (i.e.
s-attributes) that need to be present.
The enrich
method is used to generate the actual output for
the kwic method. If param table
is TRUE
, corpus positions will
be turned into a data.frame with the concordance lines. If param s_attributes
is a character vector with s-attributes, the respective s-attributes will be
added as columns to the table with concordance lines.
The constructor for generating kwic objects is the
kwic
method.
# NOT RUN {
use("polmineR")
K <- kwic("GERMAPARLMINI", "Integration")
length(K)
K_min <- K[1]
K_min <- K[1:5]
oil <- kwic("REUTERS", query = "oil")
as.character(oil)
# }
Run the code above in your browser using DataLab