-
Notifications
You must be signed in to change notification settings - Fork 5
/
check_words.py
48 lines (39 loc) · 1.34 KB
/
check_words.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from uzwords import words
from difflib import get_close_matches
def check_words(word, words=words):
word = word.lower()
matches = set(get_close_matches(word, words))
available = False
if word in matches:
available = True
matches = word
elif 'ҳ' in word:
word = word.replace('ҳ', 'х')
matches.update(set(get_close_matches(word, words)))
elif 'х' in word:
word = word.replace('х', 'ҳ')
matches.update(set(get_close_matches(word, words)))
return {'available': available, "matches": matches}
if __name__ == "__main__":
print(len(words))
print(words[0])
print(words[-1])
print(words[23233])
print('-' * 100)
print(get_close_matches("ҳато", words))
print(get_close_matches("тариҳ", words))
print(get_close_matches("хато", words))
print(get_close_matches("олма", words))
print(get_close_matches("ҳат", words))
print(get_close_matches("ҳайт", words))
print('-' * 100)
print(get_close_matches("ҳато", words, n=5))
print(get_close_matches("ҳато", words))
print('-' * 100)
print(check_words("ҳато"))
print(check_words("тариҳ"))
print(check_words("хато"))
print(check_words("олма"))
print(check_words("ҳат"))
print(check_words("ҳайт"))
print('-' * 100)