-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathadd_correction.py
More file actions
22 lines (19 loc) · 807 Bytes
/
add_correction.py
File metadata and controls
22 lines (19 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import pprint
from spelling_correct import spelling_correct
if __name__ == '__main__':
last_correction = ""
while True:
misspelling = input("misspelling: ")
correction = input("correction: ")
if not misspelling and not correction:
exit()
if not correction:
correction = last_correction
corrections = set(spelling_correct.get(correction, set()))
corrections.add(misspelling)
spelling_correct[correction] = set(corrections)
for k, v in spelling_correct.items():
spelling_correct[k] = sorted(list(set(v)))
with open('spelling_correct.py', 'w') as f:
f.write(f'spelling_correct = {pprint.pformat(spelling_correct, compact=True, indent=4)}\n')
last_correction = correction