Last active
December 31, 2015 01:09
-
-
Save NickMirnov/7911910 to your computer and use it in GitHub Desktop.
черновик
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import csv | |
d = {} | |
infil = open('lemma-freq.csv', 'r') | |
i = 0 | |
for rw in csv.reader(infil, delimiter = ';'): | |
key = rw[0] | |
value = rw[1] | |
d[key]= value | |
i = i+1 | |
if i%100000 == 0: | |
print i | |
if i == 1000000: | |
break | |
#print len(d) | |
infil.close() | |
infile = open('mat.csv', 'r') | |
outfile = open('outmat.csv','w') | |
writer = csv.writer(outfile,delimiter = ';') | |
for row in csv.reader(infile,delimiter = ';'): | |
freq = d.get(row[0],"-2") | |
row.append(freq) | |
writer.writerow(row) | |
#print row[0], row[1], row[2],freq | |
infile.close() | |
outfile.close() | |
#print outfile,freq, row[0], row[1],row[2], | |
#здесь в lemm буду искать частоту (в этом цикле) | |
# print row[0], row[1] | |
# #for s in row: | |
# #print s | |
# #table.append(row) | |
# infile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment