How to translate French to English Text in C# .Net Framework using Deep Learning AI
Deep Learning is something of a double edged sword. On the one hand, it provides the most accurate non-human translations currently available. But on the other side, it is difficult to get set up and time consuming to “train” the AI needed for the task, taking a week or more even with the latest hardware. Today, I will be showing you how to solve this problem by employing a pre-trained AI contained within an API.
To begin, we need our package to be installed, accomplished with this command for the NuGet console.
Install-Package Cloudmersive.APIClient.NET.NLP -Version 4.0.9
Next we make our function call and input our French string as part of our request object.
using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.NLP.Api;using Cloudmersive.APIClient.NET.NLP.Client;using Cloudmersive.APIClient.NET.NLP.Model;namespace Example{public class LanguageTranslationTranslateFraToEngExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new LanguageTranslationApi();var input = new LanguageTranslationRequest(); // LanguageTranslationRequest | Input translation requesttry{// Translate French to English text with Deep Learning AILanguageTranslationResponse result = apiInstance.LanguageTranslationTranslateFraToEng(input);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling LanguageTranslationApi.LanguageTranslationTranslateFraToEng: " + e.Message );}}}}
And that’s it!