/// <summary> Get the next batch status of an analysis job. </summary> /// <param name="nextLink"> Next link for list operation. </param> /// <param name="cancellationToken"> The cancellation token to use. </param> /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception> public async Task <Response <AnalyzeTextJobState> > AnalyzeBatchNextPageAsync(string nextLink, CancellationToken cancellationToken = default) { if (nextLink == null) { throw new ArgumentNullException(nameof(nextLink)); } using var message = CreateAnalyzeBatchNextPageRequest(nextLink); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { AnalyzeTextJobState value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = AnalyzeTextJobState.DeserializeAnalyzeTextJobState(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal static HealthcareJobStatusResult ConvertToHealthcareJobStatusResult(AnalyzeTextJobState jobState, IDictionary <string, int> map) { var result = new HealthcareJobStatusResult { NextLink = jobState.NextLink, CreatedOn = jobState.CreatedDateTime, LastModifiedOn = jobState.LastUpdateDateTime, ExpiresOn = jobState.ExpirationDateTime, Status = jobState.Status }; if (result.Status == TextAnalyticsOperationStatus.Succeeded) { result.Result = ExtractHealthcareActionResult(jobState, map); } foreach (var error in jobState.Errors) { result.Errors.Add(error); } return(result); }
internal static AnalyzeActionsResult ConvertToAnalyzeActionsResult(AnalyzeTextJobState jobState, IDictionary <string, int> map) { List <ExtractKeyPhrasesActionResult> keyPhrases = new(); List <RecognizeEntitiesActionResult> entitiesRecognition = new(); List <RecognizePiiEntitiesActionResult> entitiesPiiRecognition = new(); List <RecognizeLinkedEntitiesActionResult> entitiesLinkingRecognition = new(); List <AnalyzeSentimentActionResult> analyzeSentiment = new(); List <ExtractSummaryActionResult> extractSummary = new(); List <RecognizeCustomEntitiesActionResult> customEntitiesRecognition = new(); List <SingleCategoryClassifyActionResult> singleCategoryClassify = new(); List <MultiCategoryClassifyActionResult> multiCategoryClassify = new(); foreach (AnalyzeTextLROResult task in jobState.Tasks.Items) { if (task.Kind == AnalyzeTextLROResultsKind.KeyPhraseExtractionLROResults) { keyPhrases.Add(new ExtractKeyPhrasesActionResult(ConvertToExtractKeyPhrasesResultCollection((task as KeyPhraseExtractionLROResult).Results, map), task.TaskName, task.LastUpdateDateTime)); } else if (task.Kind == AnalyzeTextLROResultsKind.EntityRecognitionLROResults) { entitiesRecognition.Add(new RecognizeEntitiesActionResult(ConvertToRecognizeEntitiesResultCollection((task as EntityRecognitionLROResult).Results, map), task.TaskName, task.LastUpdateDateTime)); } else if (task.Kind == AnalyzeTextLROResultsKind.PiiEntityRecognitionLROResults) { entitiesPiiRecognition.Add(new RecognizePiiEntitiesActionResult(ConvertToRecognizePiiEntitiesResultCollection((task as PiiEntityRecognitionLROResult).Results, map), task.TaskName, task.LastUpdateDateTime)); } else if (task.Kind == AnalyzeTextLROResultsKind.EntityLinkingLROResults) { entitiesLinkingRecognition.Add(new RecognizeLinkedEntitiesActionResult(ConvertToLinkedEntitiesResultCollection((task as EntityLinkingLROResult).Results, map), task.TaskName, task.LastUpdateDateTime)); } else if (task.Kind == AnalyzeTextLROResultsKind.SentimentAnalysisLROResults) { analyzeSentiment.Add(new AnalyzeSentimentActionResult(ConvertToAnalyzeSentimentResultCollection((task as SentimentLROResult).Results, map), task.TaskName, task.LastUpdateDateTime)); } else if (task.Kind == AnalyzeTextLROResultsKind.ExtractiveSummarizationLROResults) { extractSummary.Add(new ExtractSummaryActionResult(ConvertToExtractSummaryResultCollection((task as ExtractiveSummarizationLROResult).Results, map), task.TaskName, task.LastUpdateDateTime)); } else if (task.Kind == AnalyzeTextLROResultsKind.CustomEntityRecognitionLROResults) { customEntitiesRecognition.Add(new RecognizeCustomEntitiesActionResult(ConvertToRecognizeCustomEntitiesResultCollection((task as CustomEntityRecognitionLROResult).Results, map), task.TaskName, task.LastUpdateDateTime)); } else if (task.Kind == AnalyzeTextLROResultsKind.CustomSingleLabelClassificationLROResults) { singleCategoryClassify.Add(new SingleCategoryClassifyActionResult(ConvertToSingleCategoryClassifyResultCollection((task as CustomSingleLabelClassificationLROResult).Results, map), task.TaskName, task.LastUpdateDateTime)); } else if (task.Kind == AnalyzeTextLROResultsKind.CustomMultiLabelClassificationLROResults) { multiCategoryClassify.Add(new MultiCategoryClassifyActionResult(ConvertToMultiCategoryClassifyResultCollection((task as CustomMultiLabelClassificationLROResult).Results, map), task.TaskName, task.LastUpdateDateTime)); } } return(new AnalyzeActionsResult( keyPhrases, entitiesRecognition, entitiesPiiRecognition, entitiesLinkingRecognition, analyzeSentiment, extractSummary, customEntitiesRecognition, singleCategoryClassify, multiCategoryClassify)); }
internal static AnalyzeTextJobStatusResult ConvertToAnalyzeTextJobStatusResult(AnalyzeTextJobState jobState, IDictionary <string, int> map) { var result = new AnalyzeTextJobStatusResult { DisplayName = jobState.DisplayName, NextLink = jobState.NextLink, CreatedOn = jobState.CreatedDateTime, LastModifiedOn = jobState.LastUpdateDateTime, ExpiresOn = jobState.ExpirationDateTime, AcionsSucceeded = jobState.Tasks.Completed, AcionsInProgress = jobState.Tasks.InProgress, ActionsFailed = jobState.Tasks.Failed, ActionsTotal = jobState.Tasks.Total, Status = jobState.Status }; if (result.Status == TextAnalyticsOperationStatus.Succeeded) { result.Result = ConvertToAnalyzeActionsResult(jobState, map); } foreach (var error in jobState.Errors) { result.Errors.Add(error); } return(result); }
private static AnalyzeHealthcareEntitiesResultCollection ExtractHealthcareActionResult(AnalyzeTextJobState jobState, IDictionary <string, int> map) { var healthcareTask = jobState.Tasks.Items[0]; if (healthcareTask.Kind == AnalyzeTextLROResultsKind.HealthcareLROResults) { return(Transforms.ConvertToAnalyzeHealthcareEntitiesResultCollection((healthcareTask as HealthcareLROResult).Results, map)); } throw new InvalidOperationException($"Invalid task executed. Expected a HealthcareLROResults but instead got {healthcareTask.Kind}."); }