java.lang.Object
com.northconcepts.datapipeline.foundations.pipeline.tree.detect.StructureSiblingSetRule
All Implemented Interfaces:
SiblingSetRule

public class StructureSiblingSetRule extends Object implements SiblingSetRule
Derives a SiblingSetPattern from siblings whose child structures overlap, instead of their names: each candidate's structural signature is the set of its child element and attribute names (looking through JSON object/array container nodes), and siblings whose signatures agree above minimumSimilarity (Jaccard overlap) form the collapse group.

This collapses siblings that are instances of the same entity even when their names share no derivable affix (for example alpha, beta, gamma elements with identical children), and refuses siblings that merely share a naming convention while holding different content (for example Form ADV's Item3A/Item5B sections, whose attribute sets do not overlap). Siblings without children are never clustered — value-only leaf fields such as first_name/last_name are fields, not repeating records.

The derived pattern is a closed set: it matches exactly the sibling names that formed the cluster (with any shared affix contributing a field-name hint), unlike AffixSiblingSetRule whose patterns also match future names with the same shape.

  • Field Details

    • DEFAULT_MINIMUM_SIBLINGS

      public static final int DEFAULT_MINIMUM_SIBLINGS
      See Also:
    • DEFAULT_MINIMUM_SIMILARITY

      public static final double DEFAULT_MINIMUM_SIMILARITY
      See Also:
  • Constructor Details

    • StructureSiblingSetRule

      public StructureSiblingSetRule()
  • Method Details

    • getMinimumSiblings

      public int getMinimumSiblings()
      Returns the minimum number of structurally similar siblings required to derive a pattern (default 3).
    • setMinimumSiblings

      public StructureSiblingSetRule setMinimumSiblings(int minimumSiblings)
      Sets the minimum number of structurally similar siblings required to derive a pattern (default 3, at least 2).
    • getMinimumSimilarity

      public double getMinimumSimilarity()
      Returns the minimum Jaccard overlap between sibling structural signatures (default 0.75).
    • setMinimumSimilarity

      public StructureSiblingSetRule setMinimumSimilarity(double minimumSimilarity)
      Sets the minimum Jaccard overlap between sibling structural signatures (default 0.75; greater than 0, at most 1).
    • derivePattern

      public SiblingSetPattern derivePattern(TreeNode parent, List<TreeNode> candidateSiblings)
      Description copied from interface: SiblingSetRule
      Returns the pattern shared by the candidate children of parent, or null; CollapseSiblingPatterns passes its named children, excluding attributes, wildcards and JSON containers.
      Specified by:
      derivePattern in interface SiblingSetRule
    • getStructuralSignature

      protected Set<String> getStructuralSignature(TreeNode node)
      Returns the node's structural signature: the names of its element and attribute children, looking through JSON object/array container nodes to the entries inside them. Empty for value-only leaves.