You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If it is feasible to add preprocesser i will make PR, otherwise i will add this to chatterbot-tricks
deftranslate_text(chatbot, statement, target):
"""Translates text into the target language. Target must be an ISO 639-1 language code. See https://g.co/cloud/translate/v2/translate-reference#supported_languages """fromgoogle.cloudimporttranslatetranslate_client=translate.Client()
# Text can also be a sequence of strings, in which case this method# will return a sequence of results for each text.result=translate_client.translate(
statement.text,
target_language=target)
# Input language: result['input']# Translated language: result['translatedText']# Detected source language: result['detectedSourceLanguage']statement.text=str(result['translatedText'])
returnstatement
gunthercox
changed the title
Translate Text adapters
Translation preprocessors
Jan 31, 2017
@gunthercox how about adding this feature to Chatterbot?
More information https://cloud.google.com/translate/docs/translating-text#translate-translate-text-python
Any comments?
The text was updated successfully, but these errors were encountered: