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 class 'bundle'
name(x) <- value

# S4 method for class 'bundle'
length(x)

# S4 method for class 'bundle'
names(x)

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

# S4 method for class 'bundle'
unique(x)

# S4 method for class 'bundle,bundle'
e1 + e2

# S4 method for class 'bundle,textstat'
e1 + e2

# S4 method for class 'bundle'
x[[i]]

# S4 method for class 'bundle,ANY,ANY,ANY'
x[i]

# S4 method for class 'bundle'
x[[i]] <- value

# S4 method for class 'bundle'
x$name

# S4 method for class 'bundle'
x$name <- value

# S4 method for class 'bundle'
sample(x, size)

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

# S4 method for class 'textstat'
as.bundle(object)

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

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

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

# S4 method for class 'bundle'
as.list(x)

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

# S4 method for class '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

integer or character values for indexing 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 xobjects 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

use("RcppCWB", "REUTERS")
#> ✔ corpus loaded: REUTERS

# generate bundle with articles in REUTERS corpus
b <- partition_bundle("REUTERS", s_attribute = "id")
#> ℹ s-attribute "id" has values: yes
#> ℹ get regions and get values
#> ✔ get regions and get values [6ms]
#> 
#> ℹ instantiate objects (n = 20)
#> ✔ instantiate objects (n = 20) [10ms]
#> 
#> ℹ assign names
#> ✔ assign names [6ms]
#> 

# basic operations
length(b)
#> [1] 20
names(b)
#>  [1] "127" "144" "191" "194" "211" "236" "237" "242" "246" "248" "273" "349"
#> [13] "352" "353" "368" "489" "502" "543" "704" "708"
get_corpus(b)
#> [1] "REUTERS"
summary(b)
#>    name size
#> 1   127   92
#> 2   144  444
#> 3   191   55
#> 4   194   69
#> 5   211   93
#> 6   236  465
#> 7   237  434
#> 8   242  164
#> 9   246  331
#> 10  248  349
#> 11  273  378
#> 12  349   92
#> 13  352  105
#> 14  353  103
#> 15  368  110
#> 16  489  149
#> 17  502  199
#> 18  543   83
#> 19  704  282
#> 20  708   53

# enrich with count for p-attribute
b <- enrich(b, p_attribute = "word")

# Indexing and accessing bundle objects
reu <- corpus("REUTERS") %>% split(s_attribute = "id")
#> ℹ s-attribute "id" has values: yes
#> ℹ get regions and get values
#> ✔ get regions and get values [6ms]
#> 
#> ℹ instantiate objects (n = 20)
#> ✔ instantiate objects (n = 20) [10ms]
#> 
#> ℹ assign names
#> ✔ assign names [6ms]
#> 
reu[1:3]
#> <<subcorpus_bundle>>
#> Number of subcorpora:    3
reu[-1]
#> <<subcorpus_bundle>>
#> Number of subcorpora:    19
reu[-(1:10)]
#> <<subcorpus_bundle>>
#> Number of subcorpora:    10
reu["127"]
#> <<subcorpus_bundle>>
#> Number of subcorpora:    1
reu$`127` # alternative access
#> <<subcorpus>>
#> corpus:     REUTERS
#> encoding:   latin1
#> type:       NA
#> template:   yes
#> size:       92
reu[c("127", "273")]
#> <<subcorpus_bundle>>
#> Number of subcorpora:    2
reu[["127"]] <- NULL
pb <- partition_bundle("GERMAPARLMINI", s_attribute = "party")
#> ℹ s-attribute "party" has values: yes
#> ℹ get regions and get values
#> ✔ get regions and get values [7ms]
#> 
#> ℹ instantiate objects (n = 6)
#> ✔ instantiate objects (n = 6) [9ms]
#> 
#> ℹ assign names
#> ✔ assign names [5ms]
#> 
pb$"NA" <- NULL # quotation needed if name is "NA"

# Turn bundle into data.table (not tested to save time)
# \donttest{
dt <- partition_bundle("REUTERS", s_attribute = "id") %>%
  cooccurrences(query = "oil", cqp = FALSE) %>%
  as.data.table(col = "ll")
#> ℹ s-attribute "id" has values: yes
#> ℹ get regions and get values
#> ✔ get regions and get values [6ms]
#> 
#> ℹ instantiate objects (n = 20)
#> ✔ instantiate objects (n = 20) [10ms]
#> 
#> ℹ assign names
#> ✔ assign names [5ms]
#> 
#> Warning: No hits for query oil (returning NULL)
# }