def get_value_xpaths(dom_tree,
                     truth_value,
                     overall_xpath_dict,
                     website="",
                     field=""):
    """Gets a list of xpaths that contain a text truth_value in DOMTree objects.

    Args:
      dom_tree: the DOMTree object of a specific HTML page.
      truth_value: a certain groundtruth value.
      overall_xpath_dict: a dict maintaining all xpaths data of a website.
      website: the website name.
      field: the field name.

    Returns:
      xpaths: a list of xpaths containing the truth_value exactly as inner texts.
      current_xpath_data: the xpaths and corresponding values in this DOMTree.
    """
    if not truth_value:
        #  Some values are empty strings, that are not in the DOMTree.
        return []

    xpaths = []  # The resulting list of xpaths to be returned.
    current_xpath_data = dict()  # The resulting dictionary to save all page data.

    current_page_nodes_in_order = []
    is_truth_value_list = []

    # Some values contains HTML tags and special strings like "&nbsp;"
    # So we need to escape the HTML by parsing and then extract the inner text.
    value_dom = lxml.html.fromstring(truth_value)
    value = " ".join(etree.XPath("//text()")(value_dom))
    value = clean_spaces(value)

    # Iterate all the nodes in the given DOMTree.
    for e in dom_tree.iter():
        # The value can only be matched in the text of the node or the tail.
        if e.text:
            match_value_node(
                e,
                e.text,
                current_xpath_data,
                overall_xpath_dict,
                text_part_flag="node_text",
                groundtruth_value=value,
                matched_xpaths=xpaths,
                website=website,
                field=field,
                dom_tree=dom_tree,
                current_page_nodes_in_order=current_page_nodes_in_order,
                is_truth_value_list=is_truth_value_list
            )
        if e.tail:
            match_value_node(
                e,
                e.tail,
                current_xpath_data,
                overall_xpath_dict,
                text_part_flag="node_tail_text",
                groundtruth_value=value,
                matched_xpaths=xpaths,
                website=website,
                field=field,
                dom_tree=dom_tree,
                current_page_nodes_in_order=current_page_nodes_in_order,
                is_truth_value_list=is_truth_value_list
            )

    return xpaths, current_xpath_data, current_page_nodes_in_order, is_truth_value_list
Gets a list of xpaths that contain a text truth_value in DOMTree objects.

    Args:
      dom_tree: the DOMTree object of a specific HTML page.
      truth_value: a certain groundtruth value.
      overall_xpath_dict: a dict maintaining all xpaths data of a website.
      website: the website name.
      field: the field name.

    Returns:
      xpaths: a list of xpaths containing the truth_value exactly as inner texts.
      current_xpath_data: the xpaths and corresponding values in this DOMTree.
    
markuplm/examples/fine_tuning/run_swde/prepare_data.py