1 Star 0 Fork 0

fanyangchu/PythonCode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
personal_translator.py 1.37 KB
一键复制 编辑 原始数据 按行查看 历史
Itz-Antaripa 提交于 2020-10-06 20:30 . Added Personal Translator
# -*- coding: utf-8 -*-
"""Personal_translator.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1lHb0mCvF6Ie3QaTt3VfqlNjNs6vuV5qJ
"""
# uncomment the line to intall googletrans library
# ! pip install googletrans
from googletrans import Translator
# make a simple function that will translate any language to english
def text_translator(Text):
translator = Translator()
translated = translator.translate(Text, dest='en')
return translated.text
text_translator('Cidades brasileiras integram programa de preservação de florestas') # portuguese to english
text_translator('Guten Morgen, wie gehts?') # german to english
text_translator('Ami tumake bhalobashi') # bengali to english
text_translator('ਮੈਨੂੰ ਇੱਕ ਗੱਲ ਦੱਸੋ') # punjabi to english
text_translator('I am fine') # english text remains constant
def eng2punj_translator(Text): # english to punjabi translator
translator = Translator()
translated = translator.translate(Text, dest='pa')
return translated.text
eng2punj_translator('Meet you soon')
def eng2beng_translator(Text): # english to bengali translator
translator = Translator()
translated = translator.translate(Text, dest='bn')
return translated.text
eng2beng_translator('So happy to see you')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fanych/pythoncode.git
git@gitee.com:fanych/pythoncode.git
fanych
pythoncode
PythonCode
master

搜索帮助