Package pypln :: Package workers :: Module freqdist
[hide private]

Source Code for Module pypln.workers.freqdist

 1  # coding: utf-8 
 2   
 3  __meta__ = {'from': 'document', 
 4              'requires': ['tokens'], 
 5              'to': 'document', 
 6              'provides': ['freqdist'],} 
 7   
8 -def main(document):
9 tokens = [info[0].lower() for info in document['tokens']] 10 frequency_distribution = {token: tokens.count(token) \ 11 for token in set(tokens)} 12 fd = frequency_distribution.items() 13 fd.sort(lambda x, y: cmp(y[1], x[1])) 14 return {'freqdist': fd}
15