sfa_build_regions: Build Many Construct Regions in One Corpus Pass

View source: R/regions_multi.R

sfa_build_regionsR Documentation

Build Many Construct Regions in One Corpus Pass

Description

The campaign-scale companion to sfa_build_region(): streams the corpus once and extracts sentences for every construct simultaneously, then builds one "sfa_region" per construct. Variants are matched on word boundaries (a component like "care" must not match "career"), which also makes compositional names safe: a construct like Honesty-Humility is gathered through variants = c("honesty", "humility").

Usage

sfa_build_regions(
  constructs,
  corpus = "fineweb-10bt",
  target = 1500,
  max_docs = 2e+07,
  sentences_per_doc = 3,
  min_chars = 30,
  max_chars = 500,
  embeddings = TRUE,
  embed = "sbert",
  model = NULL,
  cache = TRUE,
  instruction = TRUE,
  dir = NULL,
  progress = TRUE
)

Arguments

constructs

Named list: construct name -> list(definition = , variants = NULL) (a bare definition string also works). Default variants are simple inflections of the name.

corpus

"fineweb-10bt" (streamed once for all constructs), or a local corpus as in sfa_build_region().

target, max_docs, sentences_per_doc, min_chars, max_chars

As in sfa_build_region(), applied per construct.

embeddings

Embed each region now? FALSE builds sentence-only regions (no encoder needed; sfa_coverage() refuses them until sfa_reembed_region() fills the embeddings in).

embed, model, cache, instruction

As in sfa_build_region().

dir

Optional directory: each region is saved as ⁠{dir}/{slug}.rds⁠.

progress

Print streaming progress? Default TRUE.

Details

For encoder-ladder studies, build once with embeddings = FALSE (a pure extraction; no encoder touched) and embed the same sentence sets under each encoder with sfa_reembed_region() - the regions differ only in the embedding space, never in their text.

Value

A named list of "sfa_region" objects.


semanticfa documentation built on Sept. 2, 2026, 1:07 a.m.