Skip to contents

One-call corpus preparation: reads the database, applies the configured column mapping, standardizes column names, runs preprocessing, and (optionally) applies test_mode sampling. Returns a tibble with the canonical std_id, std_text, std_author, std_timestamp, original_text columns (plus any configured metric columns and source_table).

Usage

load_corpus_from_config(config, apply_test_mode = TRUE)

Arguments

config

Either a ThematicConfig object (e.g., from load_config) or a length-1 character path to a YAML config file. If a path, load_config() is called with no overrides.

apply_test_mode

Logical; if TRUE (the default) and the config's analysis$test_mode$enabled is set, sample the corpus down to analysis$test_mode$sample_size rows using analysis$test_mode$seed. Pass FALSE to skip sampling and return the full preprocessed corpus regardless of the test_mode config – useful when the same config drives both a test_mode dry-run and a full Mode 1 ingestion.

Value

A tibble of standardized + preprocessed entries with std_id, std_text, std_author, std_timestamp, original_text, plus any metric columns identified by the column mapping, plus source_table.

Details

This is the canonical public entry point for users who need the standardized + preprocessed corpus as a stand-alone object, particularly for Mode 1 (run_mode1), which requires the researcher to attach theme_membership_* columns from their external coding workflow (NVivo, ATLAS.ti, MAXQDA, etc.) before invoking the provocateur loop. run_analysis (Modes 2/3) calls this same function internally during its Step 2, so the loading code path is canonically identical whether the corpus is consumed by run_analysis or by run_mode1.

Previously users had to call the internal trio (pakhom:::load_and_combine_tables + pakhom:::detect_columns + pakhom:::preprocess_text) to construct a Mode 1 data argument from a YAML config, which broke the package's no-::: contract for replicable workflows. This helper closes that gap.

See also

load_config (parse a YAML config to ThematicConfig); run_mode1 (Mode 1 entry point that consumes the returned tibble after the researcher attaches theme_membership_* columns); run_analysis (Modes 2/3 entry point that loads the corpus internally via this function); vignette("methodology-modes") for a Mode 1 worked example.

Examples

if (FALSE) { # \dontrun{
  # Mode 1 (Reflexive Scaffold) workflow: load the standardized
  # corpus from config, attach researcher-authored theme
  # memberships, then run the provocateur loop.
  cfg    <- load_config("config.yaml")   # methodology = reflexive_scaffold
  corpus <- load_corpus_from_config(cfg)

  # Attach theme_membership_* columns from your external coding
  # tool (NVivo / ATLAS.ti / MAXQDA export). In Mode 1 pakhom
  # never authors themes -- you do, in your own workflow.
  corpus$theme_membership_Adoption  <- as.integer(corpus$std_id %in% ids_adopt)
  corpus$theme_membership_Resistance <- as.integer(corpus$std_id %in% ids_r)

  themes <- create_theme_set(list(
    list(id = 1, name = "Adoption",
         description = "Researcher-authored: remote-work flexibility",
         codes_included = c("async_routine", "daily_batching"))
  ))

  result <- run_mode1(data = corpus, theme_set = themes, config = cfg)
} # }