本文整理汇总了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