Skip to contents

Compile a tidy semantic refinement rulebook into grouped refinement specifications suitable for refine_by_rulebook() workflows.

Usage

compile_rulebook(rulebook)

Arguments

rulebook

A data frame or tibble containing semantic refinement rules.

The input must contain:

  • "refine_id": refinement stage identifier;

  • "variable": matching variable;

  • "match": matching semantics;

  • "pattern": matching pattern;

  • "refined_assertion": refined semantic assertion.

Value

A list of compiled semantic refinement specifications suitable for refine_by_rulebook().

Each list element contains:

  • "refine_id": refinement stage identifier;

  • "rules": wide matching rule table;

  • "by": matching variables;

  • "match": matching semantics;

  • "assertion": refined semantic assertion.

Details

compile_rulebook() transforms a long-form rule table into a lightweight operational structure for iterative semantic stabilization.

Each compiled refinement stage contains:

  • matching variables;

  • matching semantics;

  • observational matching patterns;

  • refined semantic assertions.

Rulebooks support workflows where semantic interpretations are progressively stabilized through deterministic contextual matching rather than fully predefined ontology structures.

The function intentionally preserves tidy relational semantics in the rulebook representation while creating a lightweight operational structure for iterative semantic refinement.

Rulebooks are designed to support workflows where semantic stabilization emerges gradually through deterministic matching operations rather than through fully predefined ontological structures.

Examples


rulebook <- data.frame(
  refine_id = c(
    "refine_1",
    "refine_1",
    "refine_2"
  ),
  variable = c(
    "extension",
    "filename",
    "extension"
  ),
  match = c(
    "exact",
    "starts_with",
    "exact"
  ),
  pattern = c(
    "png",
    "film",
    "csv"
  ),
  refined_assertion = c(
    "visualisation",
    "visualisation",
    "tabular_data"
  ),
  stringsAsFactors = FALSE
)

compile_rulebook(rulebook)
#> [[1]]
#> [[1]]$refine_id
#> [1] "refine_1"
#> 
#> [[1]]$rules
#> # A tibble: 1 × 2
#>   extension filename
#>   <chr>     <chr>   
#> 1 png       film    
#> 
#> [[1]]$by
#> [1] "extension" "filename" 
#> 
#> [[1]]$match
#> [1] "exact"       "starts_with"
#> 
#> [[1]]$assertion
#> [1] "visualisation"
#> 
#> 
#> [[2]]
#> [[2]]$refine_id
#> [1] "refine_2"
#> 
#> [[2]]$rules
#> # A tibble: 1 × 1
#>   extension
#>   <chr>    
#> 1 csv      
#> 
#> [[2]]$by
#> [1] "extension"
#> 
#> [[2]]$match
#> [1] "exact"
#> 
#> [[2]]$assertion
#> [1] "tabular_data"
#> 
#>