def cal_acc(pred: dict, answer: dict):
    """
    Calculate normalized tree edit distance(nTED) based accuracy.
    1) Construct tree from dict,
    2) Get tree distance with insert/remove/update cost,
    3) Divide distance with GT tree size (i.e., nTED),
    4) Calculate nTED based accuracy. (= max(1 - nTED, 0 ).
    """
    pred = construct_tree_from_dict(normalize_dict(pred))
    answer = construct_tree_from_dict(normalize_dict(answer))
    val1 = zss.distance(
        pred,
        answer,
        get_children=zss.Node.get_children,
        insert_cost=insert_and_remove_cost,
        remove_cost=insert_and_remove_cost,
        update_cost=update_cost,
        return_operations=False,
    )
    val2 = zss.distance(
        construct_tree_from_dict(normalize_dict({})),
        answer,
        get_children=zss.Node.get_children,
        insert_cost=insert_and_remove_cost,
        remove_cost=insert_and_remove_cost,
        update_cost=update_cost,
        return_operations=False,
    )
    return max(0, 1 - val1 / val2)

    Calculate normalized tree edit distance(nTED) based accuracy.
    1) Construct tree from dict,
    2) Get tree distance with insert/remove/update cost,
    3) Divide distance with GT tree size (i.e., nTED),
    4) Calculate nTED based accuracy. (= max(1 - nTED, 0 ).
    
vlmeval/dataset/utils/ccocr_evaluator/kie_evaluator.py