freqn - for token in line.split(): types[token] =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#!/usr/bin/env python import sys,re def cmpItems(x,y): return -cmp(x[1],y[1]) types = {} for line in sys.stdin.readlines(): line = re.sub(r'[^a-z]',' ',line.lower())
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for token in line.split(): types[token] = types.get(token,0) + 1 words = types.items() words.sort(cmpItems) for type,value in words: print value,type...
View Full Document

This note was uploaded on 09/06/2009 for the course LING 571 taught by Professor Staff during the Fall '08 term at San Diego State.

Ask a homework question - tutors are online