Skip to content

Instantly share code, notes, and snippets.

@AsishP
Created May 30, 2019 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AsishP/61b350b5ade1316dc973a43372eb3ddd to your computer and use it in GitHub Desktop.
Save AsishP/61b350b5ade1316dc973a43372eb3ddd to your computer and use it in GitHub Desktop.
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