How to Translate English to German; German to English with Deep Learning AI using Java

When you have simple, day-to-day words you want to translate to/from German, you can (and should) enter your queries into google. When you want to build translation services into your applications, however, you’ll probably want a more efficient solution. With our German to English & English to German translation APIs, you can build a Deep Learning AI-powered translation service into your application — and the best part is you can do it for free (you just need to register a free account on our website to get a free-tier API key, which will yield a limit of 800 API calls per month).

Below, I’ve provided instructions to install the Cloudmersive NLP API client and structure your API calls with ready-to-run Java code snippets.

The first step is to include a reference in the repository in pom.xml:

After that, you can include a reference in the dependency:

Now you can use either (or both) of the below functions to translate to and/or from German. Both code snippets begin with the same imports, which you can add to the top of your file before structuring your API call.

Below, you may begin with the German to English API iteration:

ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Apikey.setApiKeyPrefix("Token");
LanguageTranslationApi apiInstance = new LanguageTranslationApi();
LanguageTranslationRequest input = new LanguageTranslationRequest(); // LanguageTranslationRequest | Input translation request
try {
LanguageTranslationResponse result = apiInstance.languageTranslationTranslateDeuToEng(input);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling LanguageTranslationApi#languageTranslationTranslateDeuToEng");
e.printStackTrace();
}

And with the following code, you can call the English to German iteration:

ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Apikey.setApiKeyPrefix("Token");
LanguageTranslationApi apiInstance = new LanguageTranslationApi();
LanguageTranslationRequest input = new LanguageTranslationRequest(); // LanguageTranslationRequest | Input translation request
try {
LanguageTranslationResponse result = apiInstance.languageTranslationTranslateEngToDeu(input);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling LanguageTranslationApi#languageTranslationTranslateEngToDeu");
e.printStackTrace();
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

Cloudmersive

436 Followers

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.