BlogJamun – Thinks Aloud

thinking feverishly for a tagline..

Quality Check on literature – A Software based approach

A quick python hack on to prove a point. To ‘just’ show how low people can stoop in the name of literature. Copy paste any boring text onto a file. Now run the following python script on the file.

import sys
import pprint

if len(sys.argv) < 2:
exit(1)

fd = file(sys.argv[1], ‘r’)

pp = pprint.PrettyPrinter()
lines = fd.readlines()
count = {}
for line in lines:
words = line.split(” “)
for word in words:
if not count.has_key(word):
count[word] = 1
else:
count[word] = count[word] + 1
pp.pprint(count)

The script returns a dictionary of words and word count. This python script is limited in its prowess, It can’t catch ‘em all. But don’t lose heart. Open source saves the day, and i give it with CYL (choose your license) license.

December 8, 2009 Posted by | Uncategorized | , , | 1 Comment

   

Follow

Get every new post delivered to your Inbox.