cod - kv2001= sorted([(v, k) for k, v in d1.items()],...

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

View Full Document Right Arrow Icon
#!/usr/bin/env python ##cod.py Calculates the coefficent of difference between two specified corpuses. ##Written by Sara Kazemi for Ling 571 Midterm project. d1 = {} for line in open('2001.txt','r'): line = [c for c in line.lower() if c.isalpha()] for token in line.split(): d1[token] = d1.get(token,0) + 1
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: kv2001= sorted([(v, k) for k, v in d1.items()], reverse=True) for kv in kv2001: if kv[1] not in ' \n': print "%2s %3d" % (kv[1], kv[0]) d5 = {} for line in open('2005.txt','r'): line = [c for c in line.lower() if c.isalpha()] for token in line.split(): d5[token] = d5.get(token,0) + 1...
View Full Document

Ask a homework question - tutors are online