Dict = {
'i':u'我','my':u'我的','is':u'是', 'name':u'名字','that':u'这','hello':u'大家好', 'guys':u'伙伴们',
'like':u'喜欢', 'computer':u'计算机', 'graphic':u'图形图像','especially':u'尤其是',
'vfx':u'视觉特效','loli':u'萝莉', 'life':u'生活','lambert':u'兰伯特'}
Text = '''Hello guys
My name is Lambert
I like computer graphic especially VFX
I like LOLI
That is my life'''
def translateMachine(word):
convert = word.lower()
if convert not in Dict:
return word
return Dict[convert]
def translateSentence(sentence):
wordsInSentence = sentence.split(' ')
chineseSentence = ''
for i in wordsInSentence:
chineseSentence +=translateMachine(i)
return chineseSentence
def translateText(text):
sentencesInText =text.split('\n')
chineseText = ''
for j in sentencesInText:
chineseText += translateSentence(j)
chineseText += '\n'
return chineseText
print(translateText(Text))
翻译机
最新推荐文章于 2023-12-30 00:33:17 发布