Learn R Programming

polmineR (version 0.7.9)

decode: Decode Structural Attribute or Entire Corpus.

Description

If a s_attribute is a character vector providing one or several structural attributes, the return value is a data.table with the left and right corpus positions in the first and second columns ("cpos_left" and "cpos_right"). Values of further columns are the decoded s-attributes. The name of the s-attribute is the column name. An error is thrown if the lengths of structural attributes differ (i.e. if there is a nested data structure).

Usage

decode(.Object, ...)

# S4 method for character decode(.Object, s_attribute = NULL, verbose = TRUE, ...)

Arguments

.Object

the corpus to decode (character vector)

...

further parameters

s_attribute

the s-attribute to decode

verbose

logical

Value

a data.table

Details

If s_attribute is NULL, the token stream is decoded for all positional attributes that are present. Structural attributes are reported in additional columns. Decoding the entire corpus may be useful to make a transition to processing data following the 'tidy' approach, or to manipulate the corpus data and to re-encode the corpus.

The return value is a data.table.

Examples

Run this code
# NOT RUN {
use("polmineR")

# Scenario 1: Decode one or two s-attributes
dt <- decode("GERMAPARLMINI", s_attribute = "date")
dt <- decode("GERMAPARLMINI", s_attribute = c("date", "speaker"))

# Scenario 2: Decode corpus entirely
dt <- decode("GERMAPARLMINI")
# }

Run the code above in your browser using DataLab