Translate Russian to English text with Deep Learning AI in Python
Language translation is a great feature of Cloudmersive’s NLP API v2 — it can provide your application with the capacity to translate a few commonly spoken languages into English & back. In this article, we’ll quickly run through how you can implement Russian-to-English translation capabilities in Python via the /nlp-v2/translate/language/rus/to/eng iteration of the Cloudmersive NLP API v2.
To get started here, you’ll first need to copy & paste the below code to install the Python SDK:
pip install cloudmersive-nlp-api-clientfrom __future__ import print_function
import time
import cloudmersive_nlp_api_client
from cloudmersive_nlp_api_client.rest import ApiException
from pprint import pprint
After that, you’ll need to authorize your API key (acquired by making a free account on the Cloudmersive website) using the following code:
# Configure API key authorization: Apikey
configuration = cloudmersive_nlp_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
Once the first two steps are done, all that’s left is copying in the callback function:
# create an instance of the API class
api_instance = cloudmersive_nlp_api_client.LanguageTranslationApi(cloudmersive_nlp_api_client.ApiClient(configuration))
input = cloudmersive_nlp_api_client.LanguageTranslationRequest() # LanguageTranslationRequest | Input translation requesttry:
# Translate Russian to English text with Deep Learning AI
api_response = api_instance.language_translation_translate_rus_to_eng(input)
pprint(api_response)
except ApiException as e:
print("Exception when calling LanguageTranslationApi->language_translation_translate_rus_to_eng: %s\n" % e)