本文整理汇总了Python中post.Post.cluster方法的典型用法代码示例。如果您正苦于以下问题:Python Post.cluster方法的具体用法?Python Post.cluster怎么用?Python Post.cluster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post.Post
的用法示例。
在下文中一共展示了Post.cluster方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import cluster [as 别名]
#saving TOP terms per cluster:
order_centroids = km.cluster_centers_.argsort()[:, ::-1]
terms = feature_names
for i in range(numK):
for ind in order_centroids[i, :15]:
clusterList[i].topTerms.append(terms[ind])
#saving post per cluster
counter = 0
for post in postCollection.list:
postCluster = km.labels_[counter]
clusterList[postCluster].posts.append(post)
post.cluster = postCluster
counter += 1
# for post in postCollection.list:
# print(post.cluster)
#
# for i in range(numK):
# print("\n\n\nCluster Num:%d." % i)
# for post in postCollection.getClusterElements(i):
# print(post.text)
if opts.showCluster:
for cluster in clusterList:
print("%s\n\n\nCluster Num:%s%d.%s" % (RED,BOLD,cluster.id,ENDC))
topTermString = ""
for topTerm in cluster.topTerms:
topTermString += topTerm + " "