本文整理汇总了Python中document.Document.print_sent_ordered方法的典型用法代码示例。如果您正苦于以下问题:Python Document.print_sent_ordered方法的具体用法?Python Document.print_sent_ordered怎么用?Python Document.print_sent_ordered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类document.Document
的用法示例。
在下文中一共展示了Document.print_sent_ordered方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from document import Document [as 别名]
# 或者: from document.Document import print_sent_ordered [as 别名]
def main():
#inputs = ['ip1.txt','ip2.txt']
#inputs = ['ip3.txt','ip4.txt']
#inputs = ['sachin1.txt']
#inputs = ['mal1.txt']
inputs = ['ip5.txt','ip6.txt','ip7.txt']
no_of_clusters = int(sys.argv[1])
doc = Document(inputs,no_of_clusters)
count = 0
print "Number of Sentences :"
print len(doc.sentences)
#print doc.sent_no_swords
#print len(doc.sent_no_swords)
'''
print "Initial cluster sentences:"
for i in range(len(doc.clusters)):
print doc.clusters[i][0],
'''
print "Selecting sentence from each cluster..."
doc.cluster_vector()
doc.find_clust_similar_sent()
#print ""
#print "Cluster sentences:\n"
#print doc.clust_sentences
#print "Assigning weights to cluster sentences:"
#doc.select_cluster_sentences()
#doc.printclust_sentences()
#doc.print_rogue_clust_sentences()
print "Ordering...."
for input_file in inputs:
count = count +1
if count == 1:
doc.print_sent_ordered()
#ordering
first = ordering.precedence_ordering(doc,doc.clust_sentences)
tempv = doc.clust_sentences[0]
doc.clust_sentences[0] = doc.clust_sentences[first]
doc.clust_sentences[first] = tempv
ordered_sentences=ordering.similarity_ordering(doc,doc.clust_sentences)
#print doc.clust_sentences,ordered_sentences
#****exchange 1st sentence in the cluster with first
for i in ordered_sentences:
print doc.sentences[i].lstrip().capitalize(),". ",