public async Task <IActionResult> Index(string inputText = "") { if (!string.IsNullOrEmpty(inputText)) { var sentimentScore = await TextAnalyticsService.GetSentimentScore(inputText); var keyPhrases = await TextAnalyticsService.GetKeyPhrases(inputText); //Cast sentiment score as a percentage sentimentScore = Math.Round((sentimentScore * 100), 0); var viewModel = new ResultViewModel() { SentimentScore = sentimentScore, KeyPhrases = keyPhrases, OriginalText = inputText, }; return(View(viewModel)); } else { return(View()); } }
public async Task <IActionResult> Index(string inputText = "") { if (!string.IsNullOrEmpty(inputText)) { var sentimentScore = await TextAnalyticsService.GetSentimentScore(inputText); var keyPhrases = await TextAnalyticsService.GetKeyPhrases(inputText); var keyPhrasesAsString = string.Empty; foreach (var keyPhrase in keyPhrases) { keyPhrasesAsString += keyPhrase + " "; } var viewModel = new ResultViewModel() { SentimentScore = sentimentScore, KeyPhrases = keyPhrases, OriginalText = inputText, KeyPhrasesAsString = keyPhrasesAsString }; return(View(viewModel)); } else { return(View()); } }