Created
January 1, 2015 20:34
-
-
Save gazs/6e64a5aeaeec668da202 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
import csv | |
from itertools import permutations, izip | |
filename = 'u2head.csv' | |
minimal_pairs = 0 | |
wordlist = ['x'] | |
letter1 = '1' | |
letter2 = '2' | |
count1 = 0 | |
count2 = 0 | |
with open('u2.csv', 'r') as csvfile: | |
csv = csv.reader(csvfile, delimiter=';') | |
wordlist = [(row[0], int(row[1])) for row in csv] | |
print "---" | |
for n1, word1 in enumerate(wordlist): | |
w1 = word1[0] | |
for word2 in wordlist[n1+1:]: | |
w2 = word2[0] | |
if len(w1) == len(w2): | |
difference = 0 | |
for a, b in izip(w1, w2): | |
if a == b: | |
difference += 0 | |
elif (a == letter1 and b == letter2) or (a == letter2 and b == letter1): | |
difference += 1 | |
else: | |
difference += 2 | |
if difference == 1: | |
#minimal_pairs += 1 | |
if letter1 in w1 and letter2 in w2: | |
count1 += word1[1] | |
count2 += word2[1] | |
if letter1 in w2 and letter2 in w1: | |
count1 += word2[1] | |
count2 += word1[1] | |
print word1, word2 | |
print 'count1', count1 | |
print 'count2', count2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment