Can I use Google Transliteration in Python? [closed]

故事扮演 提交于 2019-12-08 10:04:23

问题


I am aware that Google allows transliteration from English to several languages (www.google.com/transliterate).

I have an English word-list. I would like to transliterate (not translate) every word to Bengali (a language Google supports) - to obtain output in the form of a Unicode word-list.

Is there a way to use the transliteration API in Python to do this?


回答1:


This is the getting started documentation: http://code.google.com/apis/language/transliterate/v1/getting_started.html#transliterateLowLevel

If you only need to use it one time, it's probably easiest to use the example code to perform your transliteration in a browser.

If you can figure out the actual requests to make (shouldn't be hard, you can observe them in your browser's developer tools), you can re-implement that using the requests module (just get it with pip).




回答2:


Try the unidecode module




回答3:


The Google Transliteration API is a javascript API meant to be used by web pages. There isn't anything about direct usage from programming languages or RESTful web services interface. This means that in order to use it from python, you would need to reverse engineer the calls made to the server (Not sure this is allowed though).

Another solution would be to use a Selenium web driver. You would need to install a browser and the Selenium web driver. Then, you would be able to control the browser from python (write text fields, read the results).




回答4:


Also, there's https://github.com/davisp/python-spidermonkey found in Best way to integrate Python and JavaScript?. At least a place to start looking.



来源:https://stackoverflow.com/questions/10297454/can-i-use-google-transliteration-in-python

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