Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -46,10 +46,11 @@ def translate(text,lang):
|
|
46 |
print(resp)
|
47 |
content = resp.content
|
48 |
html = fromstring(content)
|
49 |
-
rslt = html.xpath('//
|
50 |
-
print(rslt)
|
51 |
translated = rslt[0].text.strip()
|
52 |
-
|
|
|
|
|
53 |
|
54 |
def generate_random_string(length):
|
55 |
characters = string.ascii_letters + string.digits
|
|
|
46 |
print(resp)
|
47 |
content = resp.content
|
48 |
html = fromstring(content)
|
49 |
+
rslt = html.xpath('//pre[@aria-label="Translated text"]/span')
|
|
|
50 |
translated = rslt[0].text.strip()
|
51 |
+
ret = re.sub(f'[{string.punctuation}]', '', re.sub('[\s+]', ' ', translated)).lower().strip()
|
52 |
+
print(ret)
|
53 |
+
return ret
|
54 |
|
55 |
def generate_random_string(length):
|
56 |
characters = string.ascii_letters + string.digits
|