有没有中文翻译成英文的API服务?
我有一份中文的产品名称列表。我想把这些翻译成英文。我试过使用谷歌的AJAX语言API,但翻译效果似乎不太好。如果有人能给我一些建议或者推荐一个更好的选择,那就太好了。
谢谢。
2 个回答
3
嗯,谷歌确实是个很不错的翻译服务,但如果你想要可靠的翻译,可能还是得找人来翻译——机器翻译有时候不太靠谱。myGengo 提供了一个可以帮助机器翻译的接口;你的问题是关于“python”的,所以我下面给你放了一些示例代码,不过如果你想要更详细的教程,可以去这里看看。
有趣的是,你可以在等待人工翻译的同时,先用机器翻译来应急,这样如果你需要在这段时间内得到某些东西,就不会束手无策了。;)
首先,安装 mygengo 的 Python 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']
2
我觉得谷歌可能是最好的在线自动翻译服务之一。