Can I use Google Transliteration in Python? [close

2019-06-05 18:20发布

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?

4条回答
看我几分像从前
2楼-- · 2019-06-05 18:44

Try the unidecode module

查看更多
Viruses.
3楼-- · 2019-06-05 18:55

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).

查看更多
对你真心纯属浪费
4楼-- · 2019-06-05 19:01
女痞
5楼-- · 2019-06-05 19:05

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).

查看更多
登录 后发表回答