Papers
Topics
Authors
Recent
Assistant
AI Research Assistant
Well-researched responses based on relevant abstracts and paper content.
Custom Instructions Pro
Preferences or requirements that you'd like Emergent Mind to consider when generating responses.
Gemini 2.5 Flash
Gemini 2.5 Flash 62 tok/s
Gemini 2.5 Pro 51 tok/s Pro
GPT-5 Medium 36 tok/s Pro
GPT-5 High 30 tok/s Pro
GPT-4o 67 tok/s Pro
Kimi K2 192 tok/s Pro
GPT OSS 120B 430 tok/s Pro
Claude Sonnet 4.5 34 tok/s Pro
2000 character limit reached

TSED: Tree Similarity via Edit Distance

Updated 29 September 2025
  • Tree Similarity of Edit Distance (TSED) is a method that quantifies the resemblance between trees by computing the minimal cost of edit operations like insertions, deletions, and substitutions.
  • It uses context-sensitive weighting by normalizing match scores with sibling counts, resulting in similarity metrics on a [0,1] scale without additional adjustments.
  • Applied in automatic wrapper adaptation, TSED enables robust web data extraction by identifying structural changes and reducing manual maintenance.

Tree Similarity of Edit Distance (TSED) quantifies the resemblance between tree-structured data by computing the minimal cost of transforming one tree into another via a sequence of edit operations. Initially developed for robustness in web data extraction, TSED has evolved toward highly efficient and expressive algorithms for applications spanning web automation, biological modeling, and hierarchical data comparison.

1. Foundations: Tree Edit Distance and Matching Algorithms

TSED is formally underpinned by tree edit distance, which seeks the minimum-cost sequence of operations—typically insertions, deletions, and substitutions—to morph one rooted, labeled, ordered tree into another. The seminal “simple tree matching” algorithm recursively computes, for each pair of nodes with the same label, a dynamic programming table over their children:

1
2
3
4
5
6
7
8
if T′ and T″ have the same label:
    m = degree(T′), n = degree(T″)
    Initialize M[0][j]=0, M[i][0]=0
    For i=1..m, j=1..n:
        M[i][j]=max{M[i][j–1], M[i–1][j], M[i–1][j–1]+SimpleTreeMatching(T′(i–1), T″(j–1))}
    return M[m][n] + 1
else:
    return 0

Building on this, clustered tree matching introduces context-sensitive weighting. Rather than assigning a fixed score per match, it divides the value by the maximum sibling count at each comparison:

if m>0 and n>0: return M[m][n]×(1max(t(T),t(T))) else: return M[m][n]+(1max(t(T),t(T)))\text{if } m>0 \text{ and } n>0:\ \mathrm{return}\ M[m][n]\times\left(\frac{1}{\max(t(T'), t(T''))}\right) \ \text{else}:\ \mathrm{return}\ M[m][n]+\left(\frac{1}{\max(t(T'), t(T''))}\right)

where t(n)t(n) is the number of siblings, including the node itself. This normalization yields a similarity metric in [0,1][0,1], facilitating direct thresholding for structural resemblance.

2. Methodological Improvements over Prior Approaches

The clustered tree matching approach corrects key deficiencies of earlier tree edit distance methods:

  • Contextual Weighting: By weighting matches by inverse sibling count, spurious or missing nodes in dense subtrees (such as repetitive list elements) have diminished impact on the overall similarity score.
  • Automatic Normalization: Similarity scores lie in [0,1][0,1] without post-hoc normalization, making them intuitively interpretable and usable for robust thresholding in practical systems.
  • Sensitivity to Minor Structural Variants: The algorithm is robust against minor additions, deletions, or format changes, only significantly penalizing semantically meaningful structural deviations.

The method preserves computational tractability for typical web-scale trees while enhancing robustness against small, innocuous HTML changes.

3. Application: Automatic Wrapper Adaptation

TSED, via clustered tree matching, is directly applied to wrapper adaptation in web data extraction:

  • On wrapper creation, the DOM subtree around the target element is stored as a structural signature.
  • If the structure of a target page changes and the wrapper fails, candidate subtrees in the new DOM are compared against the stored signature using clustered tree matching.
  • Subtrees exceeding a configured similarity threshold are deemed valid, allowing extraction logic to be re-induced (e.g., regenerating XPaths).
  • In repeated element contexts (e.g., search result listings), multiple high-similarity candidates can be identified, improving extraction robustness.

This end-to-end pipeline notably reduces manual maintenance, as wrappers adapt automatically to non-catastrophic HTML changes.

4. Experimental Validation and Performance

Experimental evaluation on heterogeneous, real-world sites—including Google News, Google Search, Facebook, Delicious, eBay, Kelkoo, and Techcrunch—demonstrated the efficacy of TSED:

Algorithm Precision (%) Recall (%) F-measure (%)
Simple Tree Matching 98.18 92.13 ~92.13
Clustered Tree Matching 99.18 97.19 98.18

For example, on Google News with a 90% similarity threshold, clustered tree matching yielded only 12 false negatives versus 52 with the simple algorithm. Across 70 test pages, F-measure approached 98%, attesting to the high robustness and low error rate under typical HTML evolution.

5. Limitations and Future Directions

Despite its strengths, TSED as instantiated by clustered tree matching has notable limitations:

  • No Tolerance of Node Permutation: Both the simple and clustered algorithms preserve the order of sibling nodes; permutations are penalized as mismatches. While not always critical for HTML, strongly templated websites employing reordering may defeat the adaptation.
  • Structurally Focused: Only element labels, attributes, and structure are considered; content features (e.g., text length) are ignored despite their potential disambiguating power.
  • Threshold Sensitivity: Proper selection of the similarity threshold is critical—too high, and legitimate matches are missed; too low, and unrelated elements may be chosen. In datasets with extreme structural transformation, manual or adaptive calibration may be necessary.
  • Sparse and Deep Trees: Highly nested or unusually sparse trees may yield unintuitive or unstable similarity values, and further heuristic or calibration steps may be needed.

Prospective enhancements include integrating full attribute or content analysis and designing algorithms robust to node permutation or deeper structural differences.

6. Context within the Literature and Broader Impact

The clustered tree matching TSED approach represents a principled extension to node-weighted, structure-aware tree similarity, specifically tailored for semi-structured data extraction on the web. It finds direct application in the maintenance of information extraction pipelines, reducing manual updates and increasing resilience to the high churn of web content layouts. The general methodology of contextually weighting edit operations has applicability beyond web scraping, potentially informing algorithms in fields such as computational biology (for comparing phylogenies) and software engineering (matching program ASTs).

Crucially, by grounding similarity in efficient, structure-respecting dynamic programming with minimal parameter tuning (apart from threshold selection), TSED facilitates scalable, automated solutions in domains where tree-like data is ubiquitous and subject to frequent, minor alterations.

Forward Email Streamline Icon: https://streamlinehq.com

Follow Topic

Get notified by email when new papers are published related to Tree Similarity of Edit Distance (TSED).