Skip to content

Commit

Permalink
adds
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharth17196 committed Apr 9, 2021
1 parent ce049c0 commit 2093e9b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
40 changes: 22 additions & 18 deletions elt/translit.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import http.client


lang_maps={
"hindi": 'hi-t-i0-und',
lang_maps = {
"hindi": "hi-t-i0-und",
"telegu": "te-t-i0-und",
"bengali": "bn-t-i0-und",
"tamil": "ta-t-i0-und",
Expand All @@ -13,45 +13,49 @@
"marathi": "mr-t-i0-und",
"odiya": "or-t-i0-und",
"punjabi": "pu-t-i0-und",
"urdu": "ur-t-i0-und"
"urdu": "ur-t-i0-und",
}

class translit:

def __init__(self, lang='hindi'):
class translit:
def __init__(self, lang="hindi"):
self.lang = lang_maps[lang]

@staticmethod
def request(q, lang):
conn = http.client.HTTPSConnection('inputtools.google.com')
conn.request('GET', '/request?text=' + q + '&itc=' + lang +
'&num=1&cp=0&cs=1&ie=utf-8&oe=utf-8&app=test')
conn = http.client.HTTPSConnection("inputtools.google.com")
conn.request(
"GET",
"/request?text="
+ q
+ "&itc="
+ lang
+ "&num=1&cp=0&cs=1&ie=utf-8&oe=utf-8&app=test",
)
res = conn.getresponse()
return res


def get_lang(self, q):
output = ''
output = ""
res = self.request(q, self.lang)
res = res.read()
output = str(res, encoding='utf=8')[14+4+len(q):-31]
output=output.strip()
output = str(res, encoding="utf=8")[14 + 4 + len(q) : -31]
output = output.strip()
return output


def convert(self, stops):
final_list = []
special_chars ='/.,><?][}{)(|;:-+='
special_chars = "/.,><?][}{)(|;:-+="
for i in range(len(stops)):
t_word = ''
phrase_list = stops[i][:].split(' ')
t_word = ""
phrase_list = stops[i][:].split(" ")
for word in phrase_list:
if type(word)==int:
if type(word) == int:
t_word += word
elif word in special_chars:
t_word += word
else:
t_word += self.get_lang(word)
t_word += ' '
t_word += " "
final_list.append(t_word[:-1])
return final_list
6 changes: 1 addition & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from setuptools import setup, find_packages

setup(
name="elt",
version='0.1.0',
packages=find_packages()
)
setup(name="elt", version="0.1.0", packages=find_packages())

0 comments on commit 2093e9b

Please sign in to comment.