Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

♻️ [수정] quotation refactoring / code refactoring #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions process_vecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def blocks(files, size=65536):
yield b

def count_lines(filepath):
with open(filepath, "r", encoding="utf-8", errors='ignore') as f:
with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
return sum(bl.count("\n") for bl in tqdm(blocks(f), desc='Counting lines', mininterval=1))


Expand All @@ -42,7 +42,7 @@ def count_lines(filepath):
normal_words = load_dic('data/ko-aff-dic-0.7.92/ko_filtered.txt')
print("# words in dictionary:", len(normal_words))
valid_nearest = []
valid_nearest_mat = None
valid_nearest_mat = []
eliminated = 0
checked_words = set()
total_lines = count_lines('data/cc.ko.300.vec') - 1
Expand All @@ -61,10 +61,7 @@ def count_lines(filepath):
vec = array([float(w1) for w1 in words[1:]])
if word in normal_words:
valid_nearest.append(word)
if valid_nearest_mat is None:
valid_nearest_mat = [vec]
else:
valid_nearest_mat.append(vec)
valid_nearest_mat.append(vec)
cursor.execute("""INSERT INTO guesses values (?, ?)""", (word, pickle.dumps(vec)))
checked_words.add(word)
if n % 100000 == 0:
Expand Down