Created
May 30, 2019 03:38
-
-
Save AsishP/61b350b5ade1316dc973a43372eb3ddd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string DetectLanguageFromText(string text) | |
{ | |
log.Info($"Got Text {text}"); | |
string detectedLanguage = ""; | |
var result = client.DetectLanguageAsync(new BatchInput( | |
new List<Input>() | |
{ | |
new Input("1", text) | |
})).Result; | |
// Printing language results. | |
foreach (var document in result.Documents) | |
{ | |
detectedLanguage = document.DetectedLanguages[0].Iso6391Name; | |
log.Info($"Document ID: {document.Id} , Language: {document.DetectedLanguages[0].Name}"); | |
} | |
return detectedLanguage; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment