I have a list of product names in Chinese. I want to translate these into English, I have tried Google AJAX language API, but it seems that translation is not good, it wou开发者_运维技巧ld be great if someone could give me some advice about or point me towards a better choice.
Thank you.Eh, Google is certainly a great translation service, but if you're looking for reliable translations you probably need to go human - machine translation can be sketchy at best. myGengo has an API to facilitate machine translation; your question is tagged with "python", so I've thrown some sample code below, but you can get a more extensive walkthrough if you so desire.
The cool thing is that you can get a machine translation while you wait for your human translation to be done, so if you need something in the time between you're not high and dry. ;)
First, install the mygengo API library for Python:
pip install mygengo
Then, request translations like below:
# -*- 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']
I think Google are probably one of the best web based automatic translation services.
精彩评论