Applies I-ADOPT compositional deduplication to a proposed-terms dataframe. This prevents term proliferation by:
Removing duplicates across tables (same term_label)
Collapsing age-stratified variants (X Age 1..7) into one base term
Collapsing phase-stratified variants (Ocean/Terminal/Mainstem X) into one base term
Identifying terms that should use constraint_iri instead of new term_iri
Value
A tibble with deduplicated terms and additional columns:
is_base_term: TRUE if this is the canonical base term for a patternneeds_age_facet: TRUE if age variants should use constraint_irineeds_phase_facet: TRUE if phase variants should use constraint_iricollapsed_from: Count of how many variants were collapsed into this termdedup_notes: Explanation of deduplication applied
Details
The function returns a deduplicated dataframe with added columns for facet handling.
Target ratio: For a dictionary with N measurement columns, expect ~N/10 to N/5 distinct base terms, NOT N terms. If the output still has >30 rows, consider further manual review.
Anti-patterns detected:
"Spawners Age 1", "Spawners Age 2", ... patterns -> collapsed to "SpawnerCount"
Duplicate term_labels across different tables -> deduplicated
Phase-stratified variants (Ocean X, Terminal X) -> collapsed to base term
Examples
proposed <- tibble::tibble(
term_label = c("Spawner Age 1", "Spawner Age 2", "Spawner Age 3"),
term_definition = rep("Spawner count by age", 3),
term_type = rep("owl_class", 3),
suggested_parent_iri = rep("", 3)
)
deduped <- deduplicate_proposed_terms(proposed)
#> ✔ Deduplicated 3 -> 1 terms (2 collapsed/removed).
#> ℹ Review 'dedup_notes' column for facet handling guidance.
deduped |> dplyr::filter(collapsed_from > 1)
#> # A tibble: 1 × 10
#> term_label term_definition term_type suggested_parent_iri is_base_term
#> <chr> <chr> <chr> <chr> <lgl>
#> 1 Spawner Age 1 Spawner count by age owl_class "" TRUE
#> # ℹ 5 more variables: needs_age_facet <lgl>, needs_phase_facet <lgl>,
#> # collapsed_from <int>, dedup_notes <chr>, label_pattern <chr>
