Can I use Google Transliteration in Python? [close

2019-06-05 18:04发布

问题:

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.