From d988b1b42e38d88731b3b0236dce3ebf33d6da57 Mon Sep 17 00:00:00 2001 From: Joshua Chin Date: Fri, 17 Jul 2015 15:13:25 -0400 Subject: [PATCH] generated freq dict in place --- wordfreq_builder/wordfreq_builder/word_counts.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wordfreq_builder/wordfreq_builder/word_counts.py b/wordfreq_builder/wordfreq_builder/word_counts.py index 1eceb0f..6e3fec2 100644 --- a/wordfreq_builder/wordfreq_builder/word_counts.py +++ b/wordfreq_builder/wordfreq_builder/word_counts.py @@ -47,9 +47,10 @@ def read_freqs(filename, cutoff=0): # duplicates, it does the right thing raw_counts[token] += val - freqs = {key: raw_count / total - for (key, raw_count) in raw_counts.items()} - return freqs + for word in raw_counts: + raw_counts[word] /= total + + return raw_counts def freqs_to_cBpack(in_filename, out_filename, cutoff=-600):