本文整理匯總了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