-
Notifications
You must be signed in to change notification settings - Fork 1
/
training.py
34 lines (32 loc) · 965 Bytes
/
training.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Generates training.txt for the user to practice abbrs
import csv
expand_trigger = ",;"
alt_suffix_1 = "q"
alt_suffix_2 = "j"
seen = {}
output = "matches:\n"
line_no = 0
print("Processing abbr.tsv")
with open("abbr.tsv") as abbr_file:
abbr_file = csv.reader(abbr_file, delimiter="\t")
index = 0
words = ""
abbrs = ""
print("Writing training.txt")
with open("training.txt", "w") as training_file:
for line in abbr_file:
word = line[0]
abbr = line[1]
if not abbr:
continue
words += f"{word} "
abbrs += abbr + (" " * (len(word) + 1 - len(abbr)))
index += 1
if index % 10 == 0:
training_file.write(words.rstrip())
training_file.write("\n")
training_file.write(abbrs.rstrip())
training_file.write("\n")
words = ""
abbrs = ""
print("Done")