A bundle is used to combine several objects (partition, context, features, cooccurrences objects) into one S4 class object. Typically, a class inheriting from the bundle superclass will be used. When working with a context_bundle, a features_bundle, a cooccurrences_bundle, or a context_bundle, a similar set of standard methods is available to perform transformations.

# S4 method for bundle
name(x) <- value

# S4 method for bundle
length(x)

# S4 method for bundle
names(x)

# S4 method for bundle,vector
names(x) <- value

# S4 method for bundle
unique(x)

# S4 method for bundle,bundle
+(e1, e2)

# S4 method for bundle,textstat
+(e1, e2)

# S4 method for bundle
[[(x, i)

# S4 method for bundle
[[(x, i) <- value

# S4 method for bundle
$(x, name)

# S4 method for bundle
$(x, name) <- value

# S4 method for bundle
sample(x, size)

# S4 method for list
as.bundle(object, ...)

# S4 method for textstat
as.bundle(object)

# S3 method for bundle
as.data.table(x, keep.rownames, col, ...)

# S4 method for bundle
as.matrix(x, col)

# S4 method for bundle
subset(x, ...)

# S4 method for bundle
as.list(x)

# S3 method for bundle
as.list(x, ...)

# S4 method for bundle
get_corpus(x)

Arguments

x

a bundle object

value

character string with a name to be assigned

e1

object 1

e2

object 2

i

An integer value to index a bundle object.

name

The name of an object in the bundle object.

size

number of items to choose to generate a sample

object

A bundle object.

...

Further parameters

keep.rownames

Required argument to safeguard consistency with S3 method definition in the data.table package. Unused in this context.

col

columns of the data.table to use to generate an object.

Slots

corpus

The CWB corpus the objects in the bundle are based on, a length 1 character vector.

objects

An object of class list.

p_attribute

Object of class character.

encoding

The encoding of the corpus.

Author

Andreas Blaette

Examples

parties <- s_attributes("GERMAPARLMINI", "party") parties <- parties[-which(parties == "NA")] party_bundle <- partition_bundle("GERMAPARLMINI", s_attribute = "party") length(party_bundle)
#> [1] 6
names(party_bundle)
#> [1] "B90_DIE_GRUENEN" "CDU_CSU" "DIE_LINKE" "FDP" #> [5] "NA" "SPD"
get_corpus(party_bundle)
#> [1] "GERMAPARLMINI"
party_bundle <- enrich(party_bundle, p_attribute = "word") summary(party_bundle)
#> name size p_attribute unique #> 1 B90_DIE_GRUENEN 23052 word 4186 #> 2 CDU_CSU 66490 word 8486 #> 3 DIE_LINKE 22542 word 4531 #> 4 FDP 31505 word 4930 #> 5 NA 31310 word 5032 #> 6 SPD 47302 word 6692
parties_big <- party_bundle[[c("CDU_CSU", "SPD")]] summary(parties_big)
#> name size p_attribute unique #> 1 CDU_CSU 66490 word 8486 #> 2 SPD 47302 word 6692
p <- partition("GERMAPARLMINI", date = "2009-11-11")
#> ... get encoding: latin1
#> ... get cpos and strucs
pb <- partition_bundle(p, s_attribute = "party") names(pb)
#> [1] "B90_DIE_GRUENEN" "CDU_CSU" "DIE_LINKE" "FDP" #> [5] "NA" "SPD"
pb[["NA"]] <- NULL names(pb)
#> [1] "B90_DIE_GRUENEN" "CDU_CSU" "DIE_LINKE" "FDP" #> [5] "SPD"
pb <- partition_bundle("GERMAPARLMINI", s_attribute = "party") pb$SPD # access partition names "SPD" in partition_bundle pb
#> ** partition object **
#> corpus: GERMAPARLMINI
#> name: SPD
#> s-attributes: party = SPD
#> cpos:
#> 908 pairs of corpus positions
#> size:
#> 47302 tokens
#> count:
#> not available
pb <- partition_bundle("GERMAPARLMINI", s_attribute = "party") pb$"NA" <- NULL # quotation needed if name is "NA" use("polmineR")
#> ... activating corpus: GERMAPARLMINI (version: 0.0.1 | build date: 2019-02-23)
#> ... activating corpus: REUTERS
pb <- partition_bundle("REUTERS", s_attribute = "id") coocs <- cooccurrences(pb, query = "oil", cqp = FALSE)
#> Warning: No hits for query oil (returning NULL)
dt <- as.data.table(coocs, col = "ll") m <- as.matrix(dt[, 2:ncol(dt)], rownames = dt[["token"]])