本文整理汇总了Python中document.Document.clust_sentences[0]方法的典型用法代码示例。如果您正苦于以下问题:Python Document.clust_sentences[0]方法的具体用法?Python Document.clust_sentences[0]怎么用?Python Document.clust_sentences[0]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类document.Document
的用法示例。
在下文中一共展示了Document.clust_sentences[0]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from document import Document [as 别名]
# 或者: from document.Document import clust_sentences[0] [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(),". ",
示例2: summarize
# 需要导入模块: from document import Document [as 别名]
# 或者: from document.Document import clust_sentences[0] [as 别名]
def summarize(inpdir,no_of_clusters,task):
doc = Document(ques_root_directory+inpdir,no_of_clusters)
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],
#doc.printinit_clust()
doc.cluster_vector()
doc.find_clust_similar_sent()
print ""
print "Simi based cluster sentences:"
print doc.clust_sentences
doc.printclust_sentences()
print "###"
'''
print "weight cluster sentences:"
doc.select_cluster_sentences()
print doc.clust_sentences
doc.printclust_sentences()
'''
'''
print "document cluster sentences:"
doc.clust_doc_sent()
print doc.clust_sentences
doc.printclust_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
print ""
print "SUMMARY of",no_of_clusters," :"
for i in ordered_sentences:
print doc.sentences[i],". "
#doc.print_rogue_clust_sentences()
print("writing op of task "+str(task))
doc.write_rogue_clust_sentences(sys_dir,task)