-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexample.py
More file actions
30 lines (24 loc) · 1017 Bytes
/
example.py
File metadata and controls
30 lines (24 loc) · 1017 Bytes
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
import os
from sympound import sympound
import platform
distancefun = None
if platform.system() != "Windows":
from pyxdameraulevenshtein import damerau_levenshtein_distance
distancefun = damerau_levenshtein_distance
else:
from jellyfish import levenshtein_distance
distancefun = levenshtein_distance
ssc = sympound(distancefun=distancefun, maxDictionaryEditDistance=3)
def test():
ssc.create_dictionary_entry("bonjour", 1)
print(ssc.lookup_compound(input_string="bonjur bonjour", edit_distance_max=2))
print()
print(ssc.lookup_compound(input_string="bonjuor", edit_distance_max=2))
print()
print(ssc.load_dictionary("example-dict.txt", term_index=0, count_index=1))
print(ssc.lookup_compound(input_string="bonjur hallo", edit_distance_max=2))
print()
ssc.save_pickle("symspell.pickle")
#ssc.load_pickle("symspell.pickle")
print(ssc.lookup_compound(input_string="བཀྲ་ཤས་བད་ལེགས། ལ་མ་", edit_distance_max=3))
test()