Templates are used to format the markdown/html of fulltext. get_template()
loads and parses the content of the JSON template file, if it is found in the
slot "template" of .Object.
get_template(.Object, ...)
# S4 method for class 'character'
get_template(.Object, warn = FALSE)
# S4 method for class 'corpus'
get_template(.Object, warn = FALSE)
# S4 method for class 'subcorpus'
get_template(.Object, warn = FALSE)If a template is available, a list with the parsed content of the
template file, otherwise NULL.
To learn how to write templates, consult the sample files in the folder "templates" of the installed package - see examples.
use("polmineR")
#> ✔ corpus loaded: GERMAPARLMINI (version: 0.1.0 | build date: 2023-04-16)
corpus("GERMAPARLMINI") %>%
get_template()
#> $metadata
#> name date party
#> "speaker" "date" "party"
#>
#> $document
#> $document$sAttribute
#> [1] "text"
#>
#> $document$format
#> [1] "\n### " "\n"
#>
#>
#> $speech
#> $speech$sAttribute
#> [1] "interjection"
#>
#> $speech$format
#> $speech$format$speech
#> [1] "" ""
#>
#> $speech$format$interjection
#> [1] "\n> " "\n"
#>
#>
#>
# template files included in the package
template_dir <- system.file(package = "polmineR", "templates")
list.files(template_dir)
#> [1] "article.template.json" "plain.template.json" "plpr.template.json"