-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
32 lines (25 loc) · 841 Bytes
/
test.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
import re
from engine.google import GoogleTranslateEngine
from config.config import GetConfig
config = GetConfig()
if config is not None:
engine = GoogleTranslateEngine(config)
text = """
Come on, Phil.
Hurry up.
"""
s = engine.Translate(text)
print(s)
#regex = re.compile(r"([\w|\[, '-]*[?|.|!|\]])|(♪[\w|, ']*♪*)")
#matches = regex.finditer(text.replace("\n", " "))
#s = [match.group(0).strip() for match in matches]
#for match in matches:
# s.append(match.group(0))
#sentences = [s.strip() for s in re.split(r"\.|\?", text.replace("\n", " ")) if len(s.strip()) > 0]
#print(sentences)
#sentences = [s.strip() for s in re.split(r"([.|?])", text) if len(s.strip()) > 0]
#print(sentences)
#translated = [engine.Translate(s) for s in sentences]
#print(translated)
#
#print(engine.Translate(text))