-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCHECK_SPELLINGS.py
49 lines (34 loc) · 1.26 KB
/
CHECK_SPELLINGS.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
49
from itertools import permutations
import time
import sqlite3
database = sqlite3.connect('clang.db')
user = database.cursor()
error = 0
def finder(toReplace):
user.execute("SELECT keyword from keys")
data = user.fetchall()
flag = 0
q = 0
for row in data:
print("ANALYSING REQUESTS NO : -> "+str(q))
q+=1
fromReplace= row[0]
fromReplaceData = [''.join(p) for p in permutations(fromReplace) ]
for string in range(0,len(fromReplaceData)):
x = toReplace.find(fromReplaceData[string])
global error
if x !=-1 :
#print(fromReplaceData[string])
corrected_value = toReplace.replace(fromReplaceData[string], fromReplace)
error +=1
flag = 1
break
if flag ==1 :
break
if flag == 1:
#print(corrected_value)
return(corrected_value)
elif flag ==0 :
return(toReplace)
def error_count() :
return error