本文整理汇总了Python中util.ElementHelper.element_text_content_list方法的典型用法代码示例。如果您正苦于以下问题:Python ElementHelper.element_text_content_list方法的具体用法?Python ElementHelper.element_text_content_list怎么用?Python ElementHelper.element_text_content_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.ElementHelper
的用法示例。
在下文中一共展示了ElementHelper.element_text_content_list方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_article_wish
# 需要导入模块: from util import ElementHelper [as 别名]
# 或者: from util.ElementHelper import element_text_content_list [as 别名]
def get_article_wish(clusters, doctree, title_node=None, debug = False):
#filter
clusters = filter_cluster(clusters)
if len(clusters) == 0:
return ElementHelper.element_text_content(title_node)
maxCluster = get_biggest_cluster(clusters)
nodes = clusters[maxCluster]
m = {}
m[maxCluster] = nodes
filter_cluster(m)
#============================================
if debug:
# for test
print 'maxCluster: %s' %maxCluster
for n in nodes:
print ElementHelper.get_xpath_by_element(n, doctree)
allnodes = []
for node in nodes:
children = ElementHelper.get_children(node)
allnodes.extend(children)
allnodes.sort(lambda p,q:ElementHelper.get_element_preorder_num(p)-ElementHelper.get_element_preorder_num(q))
s = ElementHelper.get_element_preorder_num(allnodes[0])
t = ElementHelper.get_element_preorder_num(allnodes[-1])
title_text = ''
if title_node is not None:
index = ElementHelper.get_element_preorder_num(title_node)
if index < s:
s = index
title_text = ElementHelper.element_text_content(title_node)
body = ElementHelper.get_body(doctree)
set_text_mark(body, s, t)
remove_nontext_element(body)
# ElementHelper.print_element(body)
return ElementHelper.element_text_content_list(body), title_text
示例2: get_article_wish
# 需要导入模块: from util import ElementHelper [as 别名]
# 或者: from util.ElementHelper import element_text_content_list [as 别名]
def get_article_wish(clusters, doctree, title_node=None, debug = False):
body, title_text = clean_body(clusters, doctree, title_node, debug)
return ElementHelper.element_text_content_list(body), title_text