本文整理匯總了Python中util.ElementHelper.get_root方法的典型用法代碼示例。如果您正苦於以下問題:Python ElementHelper.get_root方法的具體用法?Python ElementHelper.get_root怎麽用?Python ElementHelper.get_root使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類util.ElementHelper
的用法示例。
在下文中一共展示了ElementHelper.get_root方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_clustered_records
# 需要導入模塊: from util import ElementHelper [as 別名]
# 或者: from util.ElementHelper import get_root [as 別名]
def get_clustered_records(cls, doctree):
#get level_nodes_mapping
all_level_nodes = cls.bfs_tree(doctree)
root = ElementHelper.get_root(doctree)
body = ElementHelper.get_body(doctree)
#get max level and min level
upper_bound = int(ElementHelper.get_element_depth(root))+1
low_bound = int(body.get(px))+1
for level in range(low_bound, upper_bound):
level_nodes = all_level_nodes[level]
#if parent is record node, then do not consider its children
level_nodes = [node for node in level_nodes if not cls.is_node_or_ancestor_record(node)]
for j in range(1,len(level_nodes)-1):
left_node = level_nodes[j-1]
#橫向比較
right_bound = min(len(level_nodes), j+5)
right_nodes = level_nodes[j:right_bound]
#縱向比較
down_nodes = right_nodes[0]
right_nodes.extend(down_nodes)
for right_node in right_nodes:
if cls.similar_check(left_node, right_node):
left_node.set(kg_record_mark,'1')
right_node.set(kg_record_mark, '1')
break
record_groups = cls.merger_sibling_record_node(doctree)
return record_groups
示例2: pre_process_domtree
# 需要導入模塊: from util import ElementHelper [as 別名]
# 或者: from util.ElementHelper import get_root [as 別名]
def pre_process_domtree(doctree):
if doctree is not None:
root = ElementHelper.get_root(doctree)
if is_set_attribute_valid(root):
return doctree
else:
return None
else:
return None