Merge branch 'master' into modernize-python2-code
This commit is contained in:
@@ -47,7 +47,7 @@ data.append(0) # data[7] is frequency
|
|||||||
# Open the secondary memory
|
# Open the secondary memory
|
||||||
word_freqs = touchopen('word_freqs', 'rb+')
|
word_freqs = touchopen('word_freqs', 'rb+')
|
||||||
# Open the input file
|
# Open the input file
|
||||||
f = open(sys.argv[1])
|
f = open(sys.argv[1], 'r')
|
||||||
# Loop over input file's lines
|
# Loop over input file's lines
|
||||||
while True:
|
while True:
|
||||||
data[1] = [f.readline()]
|
data[1] = [f.readline()]
|
||||||
@@ -72,7 +72,7 @@ while True:
|
|||||||
if len(data[5]) >= 2 and data[5] not in data[0]:
|
if len(data[5]) >= 2 and data[5] not in data[0]:
|
||||||
# Let's see if it already exists
|
# Let's see if it already exists
|
||||||
while True:
|
while True:
|
||||||
data[6] = word_freqs.readline().strip()
|
data[6] = str(word_freqs.readline().strip(), 'utf-8')
|
||||||
if data[6] == '':
|
if data[6] == '':
|
||||||
break;
|
break;
|
||||||
data[7] = int(data[6].split(',')[1])
|
data[7] = int(data[6].split(',')[1])
|
||||||
@@ -84,10 +84,10 @@ while True:
|
|||||||
break
|
break
|
||||||
if not data[4]:
|
if not data[4]:
|
||||||
word_freqs.seek(0, 1) # Needed in Windows
|
word_freqs.seek(0, 1) # Needed in Windows
|
||||||
word_freqs.writelines("%20s,%04d\n" % (data[5], 1))
|
word_freqs.write(bytes("%20s,%04d\n" % (data[5], 1), 'utf-8'))
|
||||||
else:
|
else:
|
||||||
word_freqs.seek(-26, 1)
|
word_freqs.seek(-26, 1)
|
||||||
word_freqs.writelines("%20s,%04d\n" % (data[5], data[7]))
|
word_freqs.write(bytes("%20s,%04d\n" % (data[5], data[7]), 'utf-8'))
|
||||||
word_freqs.seek(0,0)
|
word_freqs.seek(0,0)
|
||||||
# Let's reset
|
# Let's reset
|
||||||
data[2] = None
|
data[2] = None
|
||||||
@@ -108,7 +108,7 @@ data.append(0) # data[26] is freq
|
|||||||
|
|
||||||
# Loop over secondary memory file
|
# Loop over secondary memory file
|
||||||
while True:
|
while True:
|
||||||
data[25] = word_freqs.readline().strip()
|
data[25] = str(word_freqs.readline().strip(), 'utf-8')
|
||||||
if data[25] == '': # EOF
|
if data[25] == '': # EOF
|
||||||
break
|
break
|
||||||
data[26] = int(data[25].split(',')[1]) # Read it as integer
|
data[26] = int(data[25].split(',')[1]) # Read it as integer
|
||||||
|
|||||||
Reference in New Issue
Block a user