Translate¶
Implementation of different translators.
In general you should not need to use these directly.
googleTranslate
¶
Translate using Google Translate.
To use this, environmental variable GOOGLE_APPLICATION_CREDENTIALS
needs
to be set with file continaining your key for Google Cloud account.
See https://cloud.google.com/translate/docs/reference/libraries
-
clstk.translate.googleTranslate.
translate
(text, sourceLang, targetLang)¶ Translate text
Parameters: - text – Text, each line contains one sentence
- sourceLang – Two-letter code for source language
- targetLang – Two-letter code for target language
Returns: translated text and list of translated sentences
Return type: (translation, sentences)
googleTranslateWeb
¶
DO NOT use this for commercial purpuses
-
clstk.translate.googleTranslateWeb.
translate
(text, sourceLang, targetLang, sentencePerLine=True)¶ Translate text
Parameters: - text – Text, each line contains one sentence
- sourceLang – Two-letter code for source language
- targetLang – Two-letter code for target language
Returns: translated text and list of translated sentences
Return type: (translation, sentences)