Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -29,14 +29,57 @@ symbolsDict = {
|
|
29 |
}
|
30 |
|
31 |
def normalizePreeti(preetitxt):
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
def convert(preeti):
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
def is_english_word(word):
|
42 |
"""Check if a word is English."""
|
|
|
29 |
}
|
30 |
|
31 |
def normalizePreeti(preetitxt):
|
32 |
+
normalized = ''
|
33 |
+
previoussymbol = ''
|
34 |
+
preetitxt = preetitxt.replace('qm', 's|')
|
35 |
+
preetitxt = preetitxt.replace('f]', 'ो')
|
36 |
+
preetitxt = preetitxt.replace('km', 'फ')
|
37 |
+
preetitxt = preetitxt.replace('0f', 'ण')
|
38 |
+
preetitxt = preetitxt.replace('If', 'क्ष')
|
39 |
+
preetitxt = preetitxt.replace('if', 'ष')
|
40 |
+
preetitxt = preetitxt.replace('cf', 'आ')
|
41 |
+
index = -1
|
42 |
+
while index + 1 < len(preetitxt):
|
43 |
+
index += 1
|
44 |
+
character = preetitxt[index]
|
45 |
+
try:
|
46 |
+
if preetitxt[index + 2] == '{':
|
47 |
+
if preetitxt[index + 1] == 'f' or preetitxt[index + 1] == 'ो':
|
48 |
+
normalized += '{' + character + preetitxt[index + 1]
|
49 |
+
index += 2
|
50 |
+
continue
|
51 |
+
if preetitxt[index + 1] == '{':
|
52 |
+
if character != 'f':
|
53 |
+
normalized += '{' + character
|
54 |
+
index += 1
|
55 |
+
continue
|
56 |
+
except IndexError:
|
57 |
+
pass
|
58 |
+
if character == 'l':
|
59 |
+
previoussymbol = 'l'
|
60 |
+
continue
|
61 |
+
else:
|
62 |
+
normalized += character + previoussymbol
|
63 |
+
previoussymbol = ''
|
64 |
+
return normalized
|
65 |
|
66 |
def convert(preeti):
|
67 |
+
converted = ''
|
68 |
+
normalizedpreeti = normalizePreeti(preeti)
|
69 |
+
for index, character in enumerate(normalizedpreeti):
|
70 |
+
try:
|
71 |
+
if ord(character) >= 97 and ord(character) <= 122:
|
72 |
+
converted += unicodeatoz[ord(character) - 97]
|
73 |
+
elif ord(character) >= 65 and ord(character) <= 90:
|
74 |
+
converted += unicodeAtoZ[ord(character) - 65]
|
75 |
+
elif ord(character) >= 48 and ord(character) <= 57:
|
76 |
+
converted += unicode0to9[ord(character) - 48]
|
77 |
+
else:
|
78 |
+
converted += symbolsDict[character]
|
79 |
+
except KeyError:
|
80 |
+
converted += character
|
81 |
+
|
82 |
+
return converted
|
83 |
|
84 |
def is_english_word(word):
|
85 |
"""Check if a word is English."""
|