* Fix gather_freqs.py

This commit is contained in:
Matthew Honnibal 2016-02-04 20:21:58 +01:00
parent 48ce09687d
commit a66e2f2f53

View File

@ -1,11 +1,13 @@
from __future__ import unicode_literals
import plac
import io
def main(in_loc, out_loc):
out_file = open(out_loc, 'w')
this_key = None
this_freq = 0
df = 0
for line in open(in_loc):
with io.open(out_loc, 'w', encoding='utf8') as out_file:
for line in io.open(in_loc, encoding='utf8'):
line = line.strip()
if not line:
continue
@ -19,8 +21,8 @@ def main(in_loc, out_loc):
else:
this_freq += freq
df += 1
this_key = key
out_file.write('%d\t%d\t%s\n' % (this_freq, df, this_key))
out_file.close()
if __name__ == '__main__':