Python 有中文到英文的翻译API服务吗?
我有一份中文产品名称清单。我想把这些翻译成英语,我试过谷歌AJAX语言API,但翻译似乎不太好,如果有人能给我一些建议或者给我一个更好的选择,那就太好了。Python 有中文到英文的翻译API服务吗?,python,translate,Python,Translate,我有一份中文产品名称清单。我想把这些翻译成英语,我试过谷歌AJAX语言API,但翻译似乎不太好,如果有人能给我一些建议或者给我一个更好的选择,那就太好了。 谢谢。我认为谷歌可能是最好的基于网络的自动翻译服务之一。呃,谷歌当然是一个很好的翻译服务,但是如果你在寻找可靠的翻译,你可能需要使用人工-机器翻译最多只能是粗略的。具有便于机器翻译的API;您的问题被标记为“python”,因此我在下面抛出了一些示例代码,但如果您愿意,您可以这样做 最酷的是,你可以在等待人工翻译完成的同时获得机器翻译,因此,
谢谢。我认为谷歌可能是最好的基于网络的自动翻译服务之一。呃,谷歌当然是一个很好的翻译服务,但是如果你在寻找可靠的翻译,你可能需要使用人工-机器翻译最多只能是粗略的。具有便于机器翻译的API;您的问题被标记为“python”,因此我在下面抛出了一些示例代码,但如果您愿意,您可以这样做 最酷的是,你可以在等待人工翻译完成的同时获得机器翻译,因此,如果你在这段时间内需要一些东西,你就不会感到兴奋和枯燥 首先,安装Python的mygengo API库:
pip install mygengo
然后,请求如下所示的翻译:
# -*- coding: utf-8 -*-
from mygengo import MyGengo
gengo = MyGengo(
public_key = 'your_mygengo_api_key',
private_key = 'your_mygengo_private_key',
sandbox = False, # possibly False, depending on your dev needs
)
translation = gengo.postTranslationJob(job = {
'type': 'text', # REQUIRED. Type to translate, you'll probably always put 'text' here (for now ;)
'slug': 'Translating Chinese to English with the myGengo API', # REQUIRED. For storing on the myGengo side
'body_src': '我們今天要去那裏嗎', # REQUIRED. The text you're translating. ;P
'lc_src': 'zh', # REQUIRED. source_language_code (see getServiceLanguages() for a list of codes)
'lc_tgt': 'en', # REQUIRED. target_language_code (see getServiceLanguages() for a list of codes)
'tier': 'standard', # REQUIRED. tier type ("machine", "standard", "pro", or "ultra")
})
# This will print out a machine translation; for your human translation, you can
# poll and check often, or set up a URL for it to post the results to.
print translation['response']['job']['body_tgt']