本文整理汇总了Python中block.Block.stats方法的典型用法代码示例。如果您正苦于以下问题:Python Block.stats方法的具体用法?Python Block.stats怎么用?Python Block.stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类block.Block
的用法示例。
在下文中一共展示了Block.stats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from block import Block [as 别名]
# 或者: from block.Block import stats [as 别名]
def __init__(self, adjStats = string.ascii_letters + ' ', noisy = False):
# Load it...
if noisy: print 'Reading in ply2 corpus file...'
data = read(os.path.join(os.path.dirname(__file__),'corpus.ply2'))
# Convert contents into a list of blocks...
self.blocks = []
t_arr = data['element']['document']['text']
a_arr = data['element']['document']['attribution']
if noisy:
print 'Creating blocks...'
for i in xrange(t_arr.shape[0]):
b = Block(t_arr[i], a_arr[i])
self.blocks.append(b)
# Construct all statistics - this gets complicated for reasons of efficiency...
if noisy:
print 'Collecting statistics...'
self.counts = numpy.zeros(256, dtype=numpy.int32)
self.adj = numpy.zeros((len(adjStats),len(adjStats)), dtype=numpy.int32)
self.adj_index = adjStats
for b in self.blocks:
b.stats(self.counts, self.adj, self.adj_index)