public static async Task <SentimentResult> GetTextSentimentAsync(string input, string language = "en") { SentimentResult sentimentResult = new SentimentResult() { Score = 0.5 }; if (!string.IsNullOrEmpty(input)) { SentimentBatchResult result = await AnalyticsClient.SentimentAsync(new MultiLanguageBatchInput( new List <MultiLanguageInput>() { new MultiLanguageInput(language, "0", input) })); if (result.Documents != null) { sentimentResult.Score = (double)result.Documents[0].Score; } if (result.Errors != null) { // Just return the neutral value } } return(sentimentResult); }