Description Usage Arguments Value Note Examples
View source: R/enhance_manifesto_df.R
Functon takes a manifesto data frame
(see as_tibble.ManifestoCorpus
and as_tibble.ManifestoDocument
)
and enhances it with quasi-sentence, sentence, and bloc counters as well as a
role indicator distinguishing quasi-sentence text (value 'qs'), from title, header and meta text.
This text-level information is infered from columns 'text' and 'cmp_code'.
1 |
x |
A manifesto data frame with the two required columns: 'text' and 'cmp_code' |
The input x
as manifesto.df
object (inherits from tibble
),
enhanced by column
'qs_nr' (running quasi-sentence counter),
'sent_nr' (running sentence counter),
'role' (indicator, here 'qs' for all rows), and
'bloc_nr' (enumerates consecutive rows by 'role')
In addition, the returned manifesto.df
obejct has two attributes:
'annotated': indicates wehtehr or not the input manifesto has been annotated/coded by CMP experts.
'extra_cols': names of columns added by enhancing the input data frame.
As one natrual sentence may contain multiple quasi-sentences, the latter map m:1 to the former.
For each row, the indicator variable 'role' may assume either of four values:
'qs': quasi-sentence
'title': the first row(s) with CMP code 'H' or NA
(only in annotated manifestos)
'header': subsequent rows with CMP code 'H' or NA
(only in annotated manifestos)
'meta': in annotated manifestos containing 'H' codes, the row(s) between 'title' and the first 'header' rows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## Not run:
library(tibble)
library(manifestoEnhanceR)
man <- tribble(
~manifesto_id, ~text, ~cmp_code,
"123", "main title", "H",
"123", "sub title", "H",
"123", "Publisher etc", NA_character,
"123", "first section", "H",
"123", "This is the first full sentence.", "000",
"123", "This is the second,", "000",
"123", "but splitted sentence.", "000",
"123", "second section", "H",
"123", "This is the third sentence.", "000"
)
enhanced <- enhance_manifesto_df(man)
class(enhanced)
nrow(man) == nrow(enhanced)
ncol(man) < ncol(enhanced)
attr(enhanced, "annotated")
attr(enhanced, "extra_cols")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.