class_docstr: Tree Edit Distance basead Similarity
      
class_docstr_tok: ["Tree","Edit","Distance","basead","Similarity"]
docstr: Computes TEDS score between the prediction and the ground truth of a
  given sample
docstr_tok: ["Computes","TEDS","score","between","the","prediction","and","the","ground","truth","of","a","given","sample"]
code: def evaluate(self, pred, true):
      """Computes TEDS score between the prediction and the ground truth of a
      given sample
      """
      if (not pred) or (not true):
          return 0.0
      parser = html.HTMLParser(remove_comments=True, encoding="utf-8")
      pred = html.fromstring(pred, parser=parser)
      true = html.fromstring(true, parser=parser)
      if pred.xpath("body/table") and true.xpath("body/table"):
          pred = pred.xpath("body/table")[0]
          true = true.xpath("body/table")[0]
          if self.ignore_nodes:
              etree.strip_tags(pred, *self.ignore_nodes)
              etree.strip_tags(true, *self.ignore_nodes)
          n_nodes_pred = len(pred.xpath(".//*"))
          n_nodes_true = len(true.xpath(".//*"))
          n_nodes = max(n_nodes_pred, n_nodes_true)
          tree_pred = self.load_html_tree(pred)
          tree_true = self.load_html_tree(true)
          distance = APTED(
              tree_pred, tree_true, CustomConfig()
          ).compute_edit_distance()
          return 1.0 - (float(distance) / n_nodes)
      else:
          return 0.0
  
imports: from rapidfuzz.distance import Levenshtein
  from apted import APTED, Config
  from apted.helpers import Tree
  from lxml import etree, html
  from collections import deque
  from .parallel import parallel_process
  from tqdm import tqdm
label_desc: Use image node_id 4 for calling the TEDS obj's underlying member method code with example usage: obj.evaluate(pred, true) and returns: int, unknown, int