Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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