### Reorganizes copy and pasted list input and divides between what was found in dict and not found
import csv
raw_list = []
path = r'D:\Monolingual Frequency List.csv'
#open file, append each line to raw_list
with open(path, 'r',encoding='utf-8') as csv_file:
csv_reader = csv.reader(csv_file)
for line in csv_reader:
raw_list.append(line)
csv_file.close()
#create new list with padded values so as to properly sort
padded_list = []
for word, value in raw_list:
#len of the most common = amount of padding required
padded_list.append((word,value.zfill((len(raw_list[0][1])))))
def thinner_sorter(list):
#takes out reoccurrences of words, sorts the words
jl = [] #will be list of inputted words with their values
jl_only_word =[] #gets only the words
not_in =[] #words / phrases not recognized by dictionary
unique_j = [] #used to get rid of reoccurrences of words
for word in list:
if word not in unique_j:
unique_j.append(word)
for list_word in unique_j:
for word_file, num_file in padded_list:
if list_word == word_file:
jl.append((list_word,num_file))
print('\n')
jl.sort(key = lambda x:x[1], reverse = True) # takes in x, returns x[1]
for x, y in jl:
print(x)
for word, value in jl:
jl_only_word.append(word)
for line in unique_j:
if line not in jl_only_word:
not_in.append(line)
if len(not_in) > 0:
print('*****NOT FOUND*****')
for word in not_in:
print(word)
else:
print('All words found.')
print('Paste your list of words: ')
j_list_lines = []
list_input = True
while list_input:
line = input()
if line:
j_list_lines.append(line)
else:
break
thinner_sorter(j_list_lines)
Here is the code if that matters. When I make a py.exe file from this, it does not seem to recognize the Japanese characters, giving this image screenshot
Not sure how to fix this. Like I said it runs fine in Pycharm. -- Also I am sure the code sucks but it that is not my issue right now