# loadwordcounts -
# loads the corpus wordcounts out of a plain text file with
# fields delimited with a colon into a dictionary
import string
def load_corpus_wordcounts(filename):
infile = open(filename,'r')
wc = {}
for line in infile.readlines():
row = string.split(string.strip(line),':')
if len(row) == 2:
wc[row[0]] = row[1]
infile.close()
return wc
file = "c:\\python20\\balzacwords.txt"
wc = load_corpus_wordcounts(file)
print wc
Text file Source (historic): geocities.com/soho/square/3472
geocities.com/soho/squaregeocities.com/soho
(to report bad content: archivehelp @ gmail)
|
|
|
|
|