These functions load one or more source(s) from a file or a string and store it in memory for further processing. Note that you'll probably want to clean the sources first, using one of the clean_sources() functions, and you'll probably want to add utterance identifiers to each utterance using one of the prepending_uids() functions.

load_source(
  input,
  encoding = rock::opts$get("encoding"),
  silent = rock::opts$get("silent"),
  rlWarn = rock::opts$get(rlWarn),
  diligentWarnings = rock::opts$get("diligentWarnings")
)

load_sources(
  input,
  filenameRegex = ".*",
  ignoreRegex = NULL,
  recursive = TRUE,
  full.names = FALSE,
  encoding = rock::opts$get("encoding"),
  silent = rock::opts$get("silent")
)

Arguments

input

The filename or contents of the source for load_source and the directory containing the sources for load_sources.

encoding

The encoding of the file(s).

silent

Whether to be chatty or quiet.

rlWarn

Whether to let readLines() warn, e.g. if files do not end with a newline character.

diligentWarnings

Whether to display very diligent warnings.

filenameRegex

A regular expression to match against located files; only files matching this regular expression are processed.

ignoreRegex

Regular expression indicating which files to ignore. This is a perl-style regular expression (see base::regex).

recursive

Whether to search all subdirectories (TRUE) as well or not.

full.names

Whether to store source names as filenames only or whether to include paths.

Value

Invisibly, an R character vector of classes rock_source and character.

Examples

### Get path to example source
examplePath <-
  system.file("extdata", package="rock");

### Get a path to one example file
exampleFile <-
  file.path(examplePath, "example-1.rock");

### Parse single example source
loadedSource <- rock::load_source(exampleFile);