public TextAnalyticJsonResultContainer(TextAnalyticsOptions options, TextAnalyticAnalysisResults results) { _options = options; _results = results; SetDataInContainerProperties(); }
private async Task UpdateMailMessage(Jobs.Core.Data.EmailInformation mailMsg, TextAnalyticAnalysisResults result) { if (result.TextAnalyticSentimentAnalysis.AnalysisResult.ActionSubmittedSuccessfully) { _logger.WriteLine("Mail processed ok"); var mailClassification = result.TextAnalyticSentimentAnalysis.AnalysisResult.ResponseData.documents[0].score; if (result.TextAnalyticKeyPhraseAnalysis != null && result.TextAnalyticKeyPhraseAnalysis.AnalysisResult != null) { _logger.WriteLine("Keyphrase: Has some results"); if (result.TextAnalyticKeyPhraseAnalysis.AnalysisResult.ActionSubmittedSuccessfully) { _logger.WriteLine("Action submitted successfully."); var keyResult = result.TextAnalyticKeyPhraseAnalysis.AnalysisResult; if (keyResult.ResponseData != null && keyResult.ResponseData.documents.Length > 0) { var keyPhrases = keyResult.ResponseData.documents[0]?.keyPhrases[0]; mailMsg.KeyPhrases = keyPhrases; } else { _logger.WriteLine("No data in keyphrase analysis"); } } else { _logger.WriteLine("Key{Phrase analysis did not work."); _logger.WriteLine($"Error: {result.TextAnalyticKeyPhraseAnalysis.AnalysisResult.ResponseData.errors.FirstOrDefault().message} "); } } else { _logger.WriteLine("KeyPhrase analysis did not work - no results."); } _logger.WriteLine("Updating mail store"); mailMsg.HasBeenAnalysed = true; mailMsg.partitionKey = "analysedmail"; mailMsg.SentimentScore = mailClassification; await _repository.UpdateMessageAsync(mailMsg); } else { _logger.WriteLine("Mail did not process successfully."); } }
public TextAnalyticErrorProcessor(TextAnalyticsOptions options, TextAnalyticAnalysisResults results) { _options = options; _results = results; }
public OperationStatusQueryEngine(TextAnalyticAnalysisResults analysisResults) { _analysisResults = analysisResults; }
private static void ProcessResults(TextAnalyticAnalysisResults result) { if (result.SentimentAnalysis.AnalysisResult.ActionSubmittedSuccessfully) { var errors = result.SentimentAnalysis.AnalysisResults .Where(r => r.ResponseData.errors != null && r.ResponseData.errors.Length > 0) .SelectMany(s => s.ResponseData.errors) .ToList(); if (errors.Count > 0) { Console.WriteLine("Sentiment Analysis: Action submitted but contained some errors:"); foreach (var err in errors) { Console.WriteLine(" {0}: {1} -> {2}", err.code, err.message, err.InnerError != null ? $"-> {err.InnerError.code}:{err.InnerError.message}" : string.Empty); } } else { Console.WriteLine("Sentiment Analysis: Action submitted successfully:"); var allResultItems = result.SentimentAnalysis.GetResults(); foreach (var resultItem in allResultItems) { Console.WriteLine(" {0}: {1} ({2})", resultItem.id, resultItem.score, result.SentimentAnalysis.ScoringEngine.EvaluateScore(resultItem.score).Name); } } } else { var firstError = result.SentimentAnalysis.AnalysisResult.ResponseData.errors.First(); Console.WriteLine("Sentiment Analysis: Unsuccessful. Reason: {0}:{1}", firstError.code, firstError.message, firstError.InnerError != null ? $" -> {firstError.InnerError.code}:{firstError.InnerError.message}" : string.Empty); } if (result.KeyPhraseAnalysis.AnalysisResult.ActionSubmittedSuccessfully) { var errors = result.KeyPhraseAnalysis.AnalysisResults .Where(r => r.ResponseData.errors != null && r.ResponseData.errors.Length > 0) .SelectMany(s => s.ResponseData.errors) .ToList(); if (errors.Count > 0) { Console.WriteLine("Keyphrase Analysis: Action submitted but contained some errors:"); foreach (var err in errors) { Console.WriteLine(" {0}: {1} -> {2}", err.code, err.message, err.InnerError != null ? $"-> {err.InnerError.code}:{err.InnerError.message}" : string.Empty); } } else { Console.WriteLine("Keyphrase Analysis: Action submitted successfully:"); var allResultItems = result.KeyPhraseAnalysis.AnalysisResults.Select(r => r.ResponseData); foreach (var resultItem in allResultItems) { var keyphraseList = resultItem.documents.SelectMany(k => k.keyPhrases); Console.WriteLine(" {0}: {1}", resultItem.id, string.Join(",", keyphraseList)); } } } else { var firstError = result.SentimentAnalysis.AnalysisResult.ResponseData.errors.First(); Console.WriteLine("Keyphrase Analysis: Unsuccessful. Reason: {0}:{1}", firstError.code, firstError.message, firstError.InnerError != null ? $" -> {firstError.InnerError.code}:{firstError.InnerError.message}" : string.Empty); } }