Difference between the google translate API

拈花ヽ惹草 提交于 2019-12-11 18:07:23

问题


I am building an Open Source Chrome extension based on Google translate (here).

I have read the other questions about Google translate API (like this one and this one) but I still don't have my answer. I found several URLs for Google translate like these:

  • https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=fr&dt=t&q=father&ie=UTF-8&oe=UTF-8

  • https://clients5.google.com/translate_a/t?client=dict-chrome-ex&sl=en&tl=fr&dt=t&q=father

It seems all the URL are a different combination of 3 parts:

  • a base URL :

    • translate.googleapis.com/translate_a/
    • https://translate.google.com/translate_a/
    • https://clients5.google.com/translate_a/
  • the first argument after the translate_a/: either single or t

  • the clients which can be gtx, t or dict-chrome-ex [or apparently any ID]

So far I have seen differences in the JSON returned. This https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=fr&dt=t&q=father&ie=UTF-8&oe=UTF-8 returns this json:

[[["père","father",null,null,1]
]
,null,"en"]

While this https://clients5.google.com/translate_a/t?client=dict-chrome-ex&sl=en&tl=fr&dt=t&q=father returns this json:

{"sentences":[{"trans":"père","orig":"father","backend":1},{"src_translit":"ˈfäT͟Hər"}],"dict":[{"pos":"noun","terms":["père"],"entry":[{"word":"père","reverse_translation":["father","dad","parent","papa"],"score":0.70910621,"previous_word":"le","gender":1}],"base_form":"father","pos_enum":1},{"pos":"verb","terms":["engendrer","concevoir"],"entry":[{"word":"engendrer","reverse_translation":["generate","engender","give rise to","beget","breed","father"],"synset_id":[52561],"score":0.00017133754},{"word":"concevoir","reverse_translation":["design","conceive","devise","plan","form","father"],"synset_id":[52561],"score":4.8327973e-05}],"base_form":"father","pos_enum":2}],"src":"en","alternative_translations":[{"src_phrase":"father","alternative":[{"word_postproc":"père","score":1000,"has_preceding_space":true,"attach_to_next_token":false}],"srcunicodeoffsets":[{"begin":0,"end":6}],"raw_src_segment":"father","start_pos":0,"end_pos":0}],"confidence":1,"ld_result":{"srclangs":["en"],"srclangs_confidences":[1],"extended_srclangs":["en"]},"query_inflections":[{"written_form":"father","features":{"number":2}},{"written_form":"fathers","features":{"number":1}}],"target_inflections":[{"written_form":"père","features":{"gender":1,"number":2}},{"written_form":"pères","features":{"gender":1,"number":1}},{"written_form":"père","features":{"number":2}},{"written_form":"pères","features":{"number":1}}]}

So my question is what are the (other than this one) differences between the different combinations given above. In which case should I use one rather than the other (except for the returned JSON). Is there one that is depreciated or that supports more request?

For the meaning of the queries: https://stackoverflow.com/a/29537590/3154274


回答1:


In regards to your actual question, I'm not sure there are any meaningful differences other than what you have stated and it would be difficult to determine if and when any of them are deprecated.

Given the API's are undocumented and don't appear to be intended for usage in this manor, I don't think any of them should be considered for use in the development of a real application.


However, for solving your problem of finding a free human language translation API, I would recommend the Azure Translator Text API which provides translation of 2 million characters per month as part of their free tier.

https://azure.microsoft.com/en-us/pricing/details/cognitive-services/translator-text-api/

For your specific use case, where I assume there may be a high amount of duplicate translations, I feel that caching the results would provide a significant benefit in reducing your usage amount.



来源:https://stackoverflow.com/questions/57397073/difference-between-the-google-translate-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!