
Expand parent element nodes with sub-point and example child nodes
Source:R/jsonld-helpers.R
expand_with_subpoints.RdWalks a list of parent element nodes, parses each one's
cybed:elementText for enumerated child fragments, and returns a list
with the parents plus newly-minted child nodes. Each child is routed
per its parsed node_type:
node_type == "Subpoint"(framework-as-specified enumeration from "such as", "including", semicolon-list patterns) becomes a cybed:Subpoint node, carries its parent's framework subtype, and appears in defaultcybed:hasElementtraversals.node_type == "Example"(pedagogical scaffolding from "Clarification statement:" sources) becomes a cybed:Example node, carries no framework-native subtype, and is reachable only via the parent'scybed:hasExamplepredicate (Examples are excluded from defaultcybed:hasElementcollections).
Parents that emit any Example children are mutated in place to add
cybed:hasExample triples linking to those Examples. Parents whose
text yields no fragments pass through unchanged. The returned list
preserves parent order and appends children after their parents.
Child IRIs are deterministic: <parent_iri>.sub.<ordinal> for
Subpoints and <parent_iri>.example.<ordinal> for Examples.
Usage
expand_with_subpoints(
element_nodes,
framework_prefix,
framework_id,
framework_slug = NULL,
parent_subtype = NULL
)Arguments
- element_nodes
List of named lists produced by
build_role_element_node().- framework_prefix
Character, Tier 2 prefix.
- framework_id
Character, framework identifier.
- framework_slug
Character, framework slug for per-framework opt-out via
CYBED_DISABLE_SUBPOINT_PARSERenv var. Optional.- parent_subtype
Character, the framework's element subtype name (e.g.,
"Standard","SkillLevel"). Defaults to"RoleElement"if unknown.
Value
List with two named entries: nodes (the expanded list of
parent + child nodes) and subnode_index (a tibble with one row
per child: parent_id, subnode_id, ordinal, node_type). The
index drives extend_role_element_ids(), which back-fills the parent
role's cybed:hasElement list with Subpoint IDs (Examples excluded).
See also
Other Sub-point parsing:
build_example_node(),
build_subpoint_node(),
extend_role_element_ids(),
parse_subpoints()