Split entire corpus or a partition into speeches. The heuristic is to split
the corpus/partition into partitions on day-to-day basis first, using the
s-attribute provided by s_attribute_date. These subcorpora are then
splitted into speeches by speaker name, using s-attribute s_attribute_name.
If there is a gap larger than the number of tokens supplied by argument
gap, contributions of a speaker are assumed to be two seperate speeches.
as.speeches(.Object, ...)
# S4 method for class 'partition'
as.speeches(
.Object,
s_attribute_date = grep("date", s_attributes(.Object), value = TRUE),
s_attribute_name = grep("name", s_attributes(.Object), value = TRUE),
gap = 500,
mc = FALSE,
verbose = TRUE,
progress = TRUE
)
# S4 method for class 'subcorpus'
as.speeches(
.Object,
s_attribute_date = grep("date", s_attributes(.Object), value = TRUE),
s_attribute_name = grep("name", s_attributes(.Object), value = TRUE),
gap = 500,
mc = FALSE,
verbose = TRUE,
progress = TRUE
)
# S4 method for class 'corpus'
as.speeches(
.Object,
s_attribute_date = grep("date", s_attributes(.Object), value = TRUE),
s_attribute_name = grep("name", s_attributes(.Object), value = TRUE),
gap = 500,
subset,
mc = FALSE,
verbose = TRUE,
progress = TRUE
)
# S4 method for class 'character'
as.speeches(
.Object,
s_attribute_date = grep("date", s_attributes(.Object), value = TRUE),
s_attribute_name = grep("name", s_attributes(.Object), value = TRUE),
gap = 500,
mc = FALSE,
verbose = TRUE,
progress = TRUE
)A partition, or length-one character vector indicating a
CWB corpus.
Further arguments.
A length-one character vector, the s-attribute that
provides the dates of sessions.
A length-one character vector, the s-attribute that
provides the names of speakers.
An integer value, the number of tokens between strucs
assumed to make the difference whether a speech has been interrupted (by an
interjection or question), or whether to assume seperate speeches.
Whether to use multicore, defaults to FALSE. If progress is
TRUE, argument mc is passed into pblapply as argument cl. If
progress is FALSE, mc is passed into mclapply() as argument
mc.cores.
A logical value, defaults to TRUE.
A logical value, whether to show progress bar.
A logical expression evaluated in a temporary data.table
with columns 'speaker' and 'date' to define a subset of the entire corpus
to be turned into speeches. Usually faster than applying as.speeches() on
a partition or subcorpus.
A partition_bundle, the names of the objects in the bundle are
the speaker name, the date of the speech and an index for the number of the
speech on a given day, concatenated by underscores.
if (FALSE) { # \dontrun{
use("polmineR")
speeches <- as.speeches(
"GERMAPARLMINI",
s_attribute_date = "date", s_attribute_name = "speaker"
)
speeches_count <- count(speeches, p_attribute = "word")
tdm <- as.TermDocumentMatrix(speeches_count, col = "count")
bt <- partition("GERMAPARLMINI", date = "2009-10-27")
speeches <- as.speeches(
bt,
s_attribute_name = "speaker",
s_attribute_date = "date"
)
summary(speeches)
} # }
if (FALSE) { # \dontrun{
#' sp <- corpus("GERMAPARLMINI") %>%
as.speeches(s_attribute_name = "speaker", s_attribute_date = "date")
sp <- corpus("GERMAPARLMINI") %>%
as.speeches(
s_attribute_name = "speaker",
s_attribute_date = "date",
subset = {date == as.Date("2009-11-11")},
progress = FALSE
)
sp <- corpus("GERMAPARLMINI") %>%
as.speeches(
s_attribute_name = "speaker",
s_attribute_date = "date",
subset = {date == "2009-11-10" & grepl("Merkel", speaker)},
progress = FALSE
)
} # }