Spaces:
Build error
Build error
File size: 987 Bytes
dab2de2 |
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 |
"""Translate english to chinese via a dict."""
# from typing import List, Union
from typing import Iterable, List, Union
import warnings
import copy
from radiobee.mdx_e2c import mdx_e2c
warnings.simplefilter('ignore', DeprecationWarning)
# fmt: off
def en2zh(
# text: Union[str, List[List[str]]],
# text: Union[str, List[str]],
text: Union[str, Iterable[str]],
) -> List[str]:
# fmt: on
"""Translate english to chinese via a dict.
Args
text: to translate, list of str
Returns
res: list of str
"""
res = copy.deepcopy(text)
if isinstance(text, str):
# res = [text.split()]
res = [text]
# if res and isinstance(res[0], str):
# res = [line.lower().split() for line in res]
# res = ["".join([word_tr(word) for word in line]) for line in res]
_ = []
for line in res:
line_tr = [mdx_e2c(word) for word in line.split()]
_.append("".join(line_tr))
return _
|