当前位置: 首页>>代码示例>>Python>>正文


Python Document.clust_sentences[0]方法代码示例

本文整理汇总了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(),". ",
开发者ID:sebastian-thomas,项目名称:tso,代码行数:60,代码来源:main.py

示例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)
开发者ID:sebastian-thomas,项目名称:tso,代码行数:78,代码来源:main.py


注:本文中的document.Document.clust_sentences[0]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。