diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs index e5fa125f90af..7755f851fa2c 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs @@ -228,14 +228,14 @@ public partial class RecognizePiiEntitiesOptions : Azure.AI.TextAnalytics.TextAn public RecognizePiiEntitiesOptions() { } public Azure.AI.TextAnalytics.PiiEntityDomainType DomainFilter { get { throw null; } set { } } } - public partial class RecognizePiiEntitiesResult : Azure.AI.TextAnalytics.TextAnalyticsResult + public partial class RecognizePiiResult : Azure.AI.TextAnalytics.TextAnalyticsResult { - internal RecognizePiiEntitiesResult() { } + internal RecognizePiiResult() { } public Azure.AI.TextAnalytics.PiiEntityCollection Entities { get { throw null; } } } - public partial class RecognizePiiEntitiesResultCollection : System.Collections.ObjectModel.ReadOnlyCollection + public partial class RecognizePiiResultCollection : System.Collections.ObjectModel.ReadOnlyCollection { - internal RecognizePiiEntitiesResultCollection() : base (default(System.Collections.Generic.IList)) { } + internal RecognizePiiResultCollection() : base (default(System.Collections.Generic.IList)) { } public string ModelVersion { get { throw null; } } public Azure.AI.TextAnalytics.TextDocumentBatchStatistics Statistics { get { throw null; } } } @@ -313,10 +313,10 @@ public TextAnalyticsClient(System.Uri endpoint, Azure.Core.TokenCredential crede public virtual System.Threading.Tasks.Task> RecognizeLinkedEntitiesBatchAsync(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response RecognizePiiEntities(string document, string language = null, Azure.AI.TextAnalytics.RecognizePiiEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> RecognizePiiEntitiesAsync(string document, string language = null, Azure.AI.TextAnalytics.RecognizePiiEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response RecognizePiiEntitiesBatch(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.RecognizePiiEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response RecognizePiiEntitiesBatch(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.RecognizePiiEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> RecognizePiiEntitiesBatchAsync(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.RecognizePiiEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> RecognizePiiEntitiesBatchAsync(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.RecognizePiiEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response RecognizePiiEntitiesBatch(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.RecognizePiiEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response RecognizePiiEntitiesBatch(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.RecognizePiiEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RecognizePiiEntitiesBatchAsync(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.RecognizePiiEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RecognizePiiEntitiesBatchAsync(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.RecognizePiiEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override string ToString() { throw null; } } @@ -411,9 +411,9 @@ public static partial class TextAnalyticsModelFactory public static Azure.AI.TextAnalytics.RecognizeLinkedEntitiesResult RecognizeLinkedEntitiesResult(string id, Azure.AI.TextAnalytics.TextAnalyticsError error) { throw null; } public static Azure.AI.TextAnalytics.RecognizeLinkedEntitiesResult RecognizeLinkedEntitiesResult(string id, Azure.AI.TextAnalytics.TextDocumentStatistics statistics, Azure.AI.TextAnalytics.LinkedEntityCollection linkedEntities) { throw null; } public static Azure.AI.TextAnalytics.RecognizeLinkedEntitiesResultCollection RecognizeLinkedEntitiesResultCollection(System.Collections.Generic.IEnumerable list, Azure.AI.TextAnalytics.TextDocumentBatchStatistics statistics, string modelVersion) { throw null; } - public static Azure.AI.TextAnalytics.RecognizePiiEntitiesResult RecognizePiiEntitiesResult(string id, Azure.AI.TextAnalytics.TextAnalyticsError error) { throw null; } - public static Azure.AI.TextAnalytics.RecognizePiiEntitiesResult RecognizePiiEntitiesResult(string id, Azure.AI.TextAnalytics.TextDocumentStatistics statistics, Azure.AI.TextAnalytics.PiiEntityCollection entities) { throw null; } - public static Azure.AI.TextAnalytics.RecognizePiiEntitiesResultCollection RecognizePiiEntitiesResultCollection(System.Collections.Generic.IEnumerable list, Azure.AI.TextAnalytics.TextDocumentBatchStatistics statistics, string modelVersion) { throw null; } + public static Azure.AI.TextAnalytics.RecognizePiiResult RecognizePiiResult(string id, Azure.AI.TextAnalytics.TextAnalyticsError error) { throw null; } + public static Azure.AI.TextAnalytics.RecognizePiiResult RecognizePiiResult(string id, Azure.AI.TextAnalytics.TextDocumentStatistics statistics, Azure.AI.TextAnalytics.PiiEntityCollection entities) { throw null; } + public static Azure.AI.TextAnalytics.RecognizePiiResultCollection RecognizePiiResultCollection(System.Collections.Generic.IEnumerable list, Azure.AI.TextAnalytics.TextDocumentBatchStatistics statistics, string modelVersion) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.AI.TextAnalytics.SentenceSentiment SentenceSentiment(Azure.AI.TextAnalytics.TextSentiment sentiment, string text, double positiveScore, double neutralScore, double negativeScore) { throw null; } public static Azure.AI.TextAnalytics.SentenceSentiment SentenceSentiment(Azure.AI.TextAnalytics.TextSentiment sentiment, string text, double positiveScore, double neutralScore, double negativeScore, int offset, int length, System.Collections.Generic.IReadOnlyList minedOpinions) { throw null; } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthOperation.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthOperation.cs new file mode 100644 index 000000000000..9618c737287a --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthOperation.cs @@ -0,0 +1,213 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Azure.AI.TextAnalytics.Models; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.TextAnalytics +{ + /// The AnalyzeOperation class for LRO. + public class AnalyzeHealthOperation : Operation + { + /// Provides communication with the Form Recognizer Azure Cognitive Service through its REST API. + private readonly ServiceRestClient _serviceClient; + + /// Provides tools for exception creation in case of failure. + private readonly ClientDiagnostics _diagnostics; + + /// + /// Gets an ID representing the operation that can be used to poll for the status + /// of the long-running operation. + /// + public override string Id { get; } + + /// + /// Final result of the long-running operation. + /// + /// + /// This property can be accessed only after the operation completes successfully (HasValue is true). + /// + public override AnalyzeHealthResultCollection Value + { + get + { + if (HasCompleted && !HasValue) +#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations + throw _requestFailedException; +#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations + else + { + return OperationHelpers.GetValue(ref _value); + } + } + } + + /// true if the long-running operation has completed. Otherwise, false. + private bool _hasCompleted; + + /// + /// Returns true if the long-running operation completed. + /// + public override bool HasCompleted => _hasCompleted; + + private RequestFailedException _requestFailedException; + + /// The last HTTP response received from the server. null until the first response is received. + private Response _response; + + /// The result of the long-running operation. null until result is received on status update. + private AnalyzeHealthResultCollection _value; + + /// + /// Returns true if the long-running operation completed successfully and has produced final result (accessible by Value property). + /// + public override bool HasValue => _value != null; + + /// + /// Initializes a new instance of the class. + /// + /// The ID of this operation. + /// The client used to check for completion. + public AnalyzeHealthOperation(string operationId, TextAnalyticsClient client) + { + // TODO: Add argument validation here. + + Id = operationId; + _serviceClient = client._serviceRestClient; + _diagnostics = client._clientDiagnostics; + } + + /// + /// Initializes a new instance of the class. + /// + /// The client for communicating with the Form Recognizer Azure Cognitive Service through its REST API. + /// The client diagnostics for exception creation in case of failure. + /// The address of the long-running operation. It can be obtained from the response headers upon starting the operation. + internal AnalyzeHealthOperation(ServiceRestClient serviceClient, ClientDiagnostics diagnostics, string operationLocation) + { + _serviceClient = serviceClient; + _diagnostics = diagnostics; + + // TODO: Add validation here + // https://github.com/Azure/azure-sdk-for-net/issues/11505 + Id = operationLocation.Split('/').Last(); + } + + + /// + /// The last HTTP response received from the server. + /// + /// + /// The last response returned from the server during the lifecycle of this instance. + /// An instance of sends requests to a server in UpdateStatusAsync, UpdateStatus, and other methods. + /// Responses from these requests can be accessed using GetRawResponse. + /// + public override Response GetRawResponse() => _response; + + /// + /// Calls the server to get updated status of the long-running operation. + /// + /// A used for the service call. + /// The HTTP response received from the server. + /// + /// This operation will update the value returned from GetRawResponse and might update HasCompleted, HasValue, and Value. + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => + UpdateStatusAsync(false, cancellationToken).EnsureCompleted(); + + /// + /// Calls the server to get updated status of the long-running operation. + /// + /// A used for the service call. + /// The HTTP response received from the server. + /// + /// This operation will update the value returned from GetRawResponse and might update HasCompleted, HasValue, and Value. + /// + public override async ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => + await UpdateStatusAsync(true, cancellationToken).ConfigureAwait(false); + + /// + /// Periodically calls the server till the long-running operation completes. + /// + /// A used for the periodical service calls. + /// The last HTTP response received from the server. + /// + /// This method will periodically call UpdateStatusAsync till HasCompleted is true, then return the final result of the operation. + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => + this.DefaultWaitForCompletionAsync(cancellationToken); + + /// + /// Periodically calls the server till the long-running operation completes. + /// + /// + /// The interval between status requests to the server. + /// The interval can change based on information returned from the server. + /// For example, the server might communicate to the client that there is not reason to poll for status change sooner than some time. + /// + /// A used for the periodical service calls. + /// The last HTTP response received from the server. + /// + /// This method will periodically call UpdateStatusAsync till HasCompleted is true, then return the final result of the operation. + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => + this.DefaultWaitForCompletionAsync(pollingInterval, cancellationToken); + + /// + /// Calls the server to get updated status of the long-running operation. + /// + /// When true, the method will be executed asynchronously; otherwise, it will execute synchronously. + /// A used for the service call. + /// The HTTP response received from the server. + private async ValueTask UpdateStatusAsync(bool async, CancellationToken cancellationToken) + { + if (!_hasCompleted) + { + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(AnalyzeHealthOperation)}.{nameof(UpdateStatus)}"); + scope.Start(); + + try + { + bool? _showStats = null; + int? _top = null; + int? _skip = null; + Response update = async + ? await _serviceClient.HealthStatusAsync(new Guid(Id), _top, _skip, _showStats, cancellationToken).ConfigureAwait(false) + : _serviceClient.HealthStatus(new Guid(Id), _top, _skip, _showStats, cancellationToken); + + _response = update.GetRawResponse(); + + if (update.Value.Status == State.Succeeded) + { + // we need to first assign a vaue and then mark the operation as completed to avoid race conditions + _value = new AnalyzeHealthResultCollection(new List() { update.Value.Results }, + update.Value.Results.Statistics, + update.Value.Results.ModelVersion); + _hasCompleted = true; + } + else if (update.Value.Status == State.Failed) + { + _requestFailedException = await ClientCommon.CreateExceptionForFailedOperationAsync(async, _diagnostics, _response, update.Value.Results.Errors) + .ConfigureAwait(false); + _hasCompleted = true; + throw _requestFailedException; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + return GetRawResponse(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthResultCollection.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthResultCollection.cs new file mode 100644 index 000000000000..a036c29c325d --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthResultCollection.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Azure.AI.TextAnalytics.Models; + +namespace Azure.AI.TextAnalytics +{ + /// + /// Collection of objects corresponding + /// to a batch of documents, and information about the batch operation. + /// + public class AnalyzeHealthResultCollection : ReadOnlyCollection + { + /// + /// + /// + /// + /// + internal AnalyzeHealthResultCollection(IList list, TextDocumentBatchStatistics statistics, string modelVersion) : base(list) + { + Documents = list; + Statistics = statistics; + ModelVersion = modelVersion; + } + + /// + /// Gets statistics about the documents batch and how it was processed + /// by the service. This property will have a value when IncludeStatistics + /// is set to true in the client call. + /// + public IList Documents { get; } + + /// + /// Gets statistics about the documents batch and how it was processed + /// by the service. This property will have a value when IncludeStatistics + /// is set to true in the client call. + /// + public TextDocumentBatchStatistics Statistics { get; } + + /// + /// Gets the version of the Text Analytics model used by this operation + /// on this batch of documents. + /// + public string ModelVersion { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeOperation.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeOperation.cs new file mode 100644 index 000000000000..17673d94f494 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeOperation.cs @@ -0,0 +1,211 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure.AI.TextAnalytics.Models; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.TextAnalytics +{ + /// The AnalyzeOperation class for LRO. + public class AnalyzeOperation : Operation + { + /// Provides communication with the Form Recognizer Azure Cognitive Service through its REST API. + private readonly ServiceRestClient _serviceClient; + + /// Provides tools for exception creation in case of failure. + private readonly ClientDiagnostics _diagnostics; + + /// + /// Gets an ID representing the operation that can be used to poll for the status + /// of the long-running operation. + /// + public override string Id { get; } + + /// + /// Final result of the long-running operation. + /// + /// + /// This property can be accessed only after the operation completes successfully (HasValue is true). + /// + public override AnalyzeResultCollection Value + { + get + { + if (HasCompleted && !HasValue) +#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations + throw _requestFailedException; +#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations + else + { + return OperationHelpers.GetValue(ref _value); + } + } + } + + /// true if the long-running operation has completed. Otherwise, false. + private bool _hasCompleted; + + /// + /// Returns true if the long-running operation completed. + /// + public override bool HasCompleted => _hasCompleted; + + private RequestFailedException _requestFailedException; + + /// The last HTTP response received from the server. null until the first response is received. + private Response _response; + + /// The result of the long-running operation. null until result is received on status update. + private AnalyzeResultCollection _value; + + /// + /// Returns true if the long-running operation completed successfully and has produced final result (accessible by Value property). + /// + public override bool HasValue => _value != null; + + /// + /// Initializes a new instance of the class. + /// + /// The ID of this operation. + /// The client used to check for completion. + public AnalyzeOperation(string operationId, TextAnalyticsClient client) + { + // TODO: Add argument validation here. + + Id = operationId; + _serviceClient = client._serviceRestClient; + _diagnostics = client._clientDiagnostics; + } + + /// + /// Initializes a new instance of the class. + /// + /// The client for communicating with the Form Recognizer Azure Cognitive Service through its REST API. + /// The client diagnostics for exception creation in case of failure. + /// The address of the long-running operation. It can be obtained from the response headers upon starting the operation. + internal AnalyzeOperation(ServiceRestClient serviceClient, ClientDiagnostics diagnostics, string operationLocation) + { + _serviceClient = serviceClient; + _diagnostics = diagnostics; + + // TODO: Add validation here + // https://github.com/Azure/azure-sdk-for-net/issues/11505 + Id = operationLocation.Split('/').Last(); + } + + + /// + /// The last HTTP response received from the server. + /// + /// + /// The last response returned from the server during the lifecycle of this instance. + /// An instance of sends requests to a server in UpdateStatusAsync, UpdateStatus, and other methods. + /// Responses from these requests can be accessed using GetRawResponse. + /// + public override Response GetRawResponse() => _response; + + /// + /// Calls the server to get updated status of the long-running operation. + /// + /// A used for the service call. + /// The HTTP response received from the server. + /// + /// This operation will update the value returned from GetRawResponse and might update HasCompleted, HasValue, and Value. + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => + UpdateStatusAsync(false, cancellationToken).EnsureCompleted(); + + /// + /// Calls the server to get updated status of the long-running operation. + /// + /// A used for the service call. + /// The HTTP response received from the server. + /// + /// This operation will update the value returned from GetRawResponse and might update HasCompleted, HasValue, and Value. + /// + public override async ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => + await UpdateStatusAsync(true, cancellationToken).ConfigureAwait(false); + + /// + /// Periodically calls the server till the long-running operation completes. + /// + /// A used for the periodical service calls. + /// The last HTTP response received from the server. + /// + /// This method will periodically call UpdateStatusAsync till HasCompleted is true, then return the final result of the operation. + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => + this.DefaultWaitForCompletionAsync(cancellationToken); + + /// + /// Periodically calls the server till the long-running operation completes. + /// + /// + /// The interval between status requests to the server. + /// The interval can change based on information returned from the server. + /// For example, the server might communicate to the client that there is not reason to poll for status change sooner than some time. + /// + /// A used for the periodical service calls. + /// The last HTTP response received from the server. + /// + /// This method will periodically call UpdateStatusAsync till HasCompleted is true, then return the final result of the operation. + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => + this.DefaultWaitForCompletionAsync(pollingInterval, cancellationToken); + + /// + /// Calls the server to get updated status of the long-running operation. + /// + /// When true, the method will be executed asynchronously; otherwise, it will execute synchronously. + /// A used for the service call. + /// The HTTP response received from the server. + private async ValueTask UpdateStatusAsync(bool async, CancellationToken cancellationToken) + { + if (!_hasCompleted) + { + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(AnalyzeOperation)}.{nameof(UpdateStatus)}"); + scope.Start(); + + try + { + bool? _showStats = null; + int? _top = null; + int? _skip = null; + Response update = async + ? await _serviceClient.AnalyzeStatusAsync(new Guid(Id), _showStats, _top, _skip, cancellationToken).ConfigureAwait(false) + : _serviceClient.AnalyzeStatus(new Guid(Id), _showStats, _top, _skip, cancellationToken); + + _response = update.GetRawResponse(); + + if (update.Value.Status == State.Succeeded) + { + // we need to first assign a vaue and then mark the operation as completed to avoid race conditions + _value = new AnalyzeResultCollection(new List() { update.Value }, + update.Value.Statistics); + _hasCompleted = true; + } + else if (update.Value.Status == State.Failed) + { + _requestFailedException = await ClientCommon.CreateExceptionForFailedOperationAsync(async, _diagnostics, _response, update.Value.Errors) + .ConfigureAwait(false); + _hasCompleted = true; + throw _requestFailedException; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + return GetRawResponse(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeResultCollection.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeResultCollection.cs new file mode 100644 index 000000000000..8570eec5343a --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeResultCollection.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Azure.AI.TextAnalytics.Models; + +namespace Azure.AI.TextAnalytics +{ + /// + /// Collection of objects corresponding + /// to a batch of documents, and information about the batch operation. + /// + public class AnalyzeResultCollection : ReadOnlyCollection + { + /// + /// + /// + /// + internal AnalyzeResultCollection(IList list, TextDocumentBatchStatistics statistics) : base(list) + { + Documents = list; + Statistics = statistics; + } + + /// + /// Documents. + /// + public IList Documents { get; } + + /// + /// Gets statistics about the documents batch and how it was processed + /// by the service. This property will have a value when IncludeStatistics + /// is set to true in the client call. + /// + public TextDocumentBatchStatistics Statistics { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/ClientCommon.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/ClientCommon.cs new file mode 100644 index 000000000000..a4d340de31c7 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/ClientCommon.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.AI.TextAnalytics.Models; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.TextAnalytics +{ + internal static class ClientCommon + { + /// + /// Used as part of argument validation. Attempts to create a from a string and + /// throws an in case of failure. + /// + /// The model identifier to be parsed into a . + /// The original parameter name of the . Used to create exceptions in case of failure. + /// The instance created from the . + /// Thrown when parsing fails. + public static Guid ValidateModelId(string modelId, string paramName) + { + Guid guid; + + try + { + guid = new Guid(modelId); + } + catch (Exception ex) when (ex is FormatException || ex is OverflowException) + { + throw new ArgumentException($"The {paramName} must be a valid GUID.", paramName, ex); + } + + return guid; + } + + public static string GetResponseHeader(ResponseHeaders responseHeaders, string headerName) + { + if (responseHeaders.TryGetValue(headerName, out var headerValue)) + { + return headerValue; + } + else + { + throw new KeyNotFoundException($"Header '{headerName}' was not present in the response sent by the server."); + } + } + + public static async ValueTask CreateExceptionForFailedOperationAsync(bool async, ClientDiagnostics diagnostics, Response response, IReadOnlyList errors, string errorMessage = default) + { + string errorCode = default; + + if (errors.Count > 0) + { + errorCode = errors[0].Error.Code; + errorMessage ??= errors[0].Error.Message; + } + + var errorInfo = new Dictionary(); + int index = 0; + foreach (var error in errors) + { + errorInfo.Add($"error-{index}", $"{error.Error.Code}: {error.Error.Message}"); + index++; + } + + return async + ? await diagnostics.CreateRequestFailedExceptionAsync(response, errorMessage, errorCode, errorInfo).ConfigureAwait(false) + : diagnostics.CreateRequestFailedException(response, errorMessage, errorCode, errorInfo); + } + + public static async ValueTask CreateExceptionForFailedOperationAsync(bool async, ClientDiagnostics diagnostics, Response response, IReadOnlyList errors, string errorMessage = default) + { + string errorCode = default; + + if (errors.Count > 0) + { + errorCode = errors[0].Code; + errorMessage ??= errors[0].Message; + } + + var errorInfo = new Dictionary(); + int index = 0; + foreach (var error in errors) + { + errorInfo.Add($"error-{index}", $"{error.Code}: {error.Message}"); + index++; + } + + return async + ? await diagnostics.CreateRequestFailedExceptionAsync(response, errorMessage, errorCode, errorInfo).ConfigureAwait(false) + : diagnostics.CreateRequestFailedException(response, errorMessage, errorCode, errorInfo); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomClassificationTaskParameters.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomClassificationTaskParameters.cs new file mode 100644 index 000000000000..148bc49cffa6 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomClassificationTaskParameters.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("CustomClassificationTaskParameters")] + internal partial class CustomClassificationTaskParameters + { + /// AppId. + internal string AppId { get; } + + /// SlotName. + internal string SlotName { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomClassificationTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomClassificationTasksItem.cs new file mode 100644 index 000000000000..962f8c866a31 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomClassificationTasksItem.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("TasksStateTasksCustomClassificationTasksItem")] + internal partial class CustomClassificationTasksItem + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomClassificationTasksItemProperties.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomClassificationTasksItemProperties.cs new file mode 100644 index 000000000000..f12ecc77c94e --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomClassificationTasksItemProperties.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("Components4X9ZamSchemasTasksstatePropertiesTasksPropertiesCustomclassificationtasksItemsAllof1")] + internal partial class CustomClassificationTasksItemProperties + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomEntitiesTaskParameters.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomEntitiesTaskParameters.cs new file mode 100644 index 000000000000..244a37620481 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomEntitiesTaskParameters.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("CustomEntitiesTaskParameters")] + internal partial class CustomEntitiesTaskParameters + { + /// AppId. + internal string AppId { get; } + + /// SlotName. + internal string SlotName { get; } + + /// StringIndexType. + internal StringIndexType? StringIndexType { get; set; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomEntityRecognitionTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomEntityRecognitionTasksItem.cs new file mode 100644 index 000000000000..00030aeb1330 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomEntityRecognitionTasksItem.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("TasksStateTasksCustomEntityRecognitionTasksItem")] + internal partial class CustomEntityRecognitionTasksItem + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomEntityRecognitionTasksItemProperties.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomEntityRecognitionTasksItemProperties.cs new file mode 100644 index 000000000000..15a040ad5867 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/CustomEntityRecognitionTasksItemProperties.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("Components1Yw06Y0SchemasTasksstatePropertiesTasksPropertiesCustomentityrecognitiontasksItemsAllof1")] + internal partial class CustomEntityRecognitionTasksItemProperties + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/DocumentHealthcareEntities.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/DocumentHealthcareEntities.cs new file mode 100644 index 000000000000..3cae49d4fd04 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/DocumentHealthcareEntities.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text.RegularExpressions; +using Azure.Core; +using Microsoft.Extensions.Azure; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("DocumentHealthcareEntities")] + internal partial class DocumentHealthcareEntities + { + /// Initializes a new instance of DocumentHealthcareEntities. + /// Unique, non-empty document identifier. + /// Healthcare entities. + /// Healthcare entity relations. + /// Warnings encountered while processing document. + /// , , , or is null. + internal DocumentHealthcareEntities(string id, IEnumerable entities, IEnumerable relations, IEnumerable warnings) + { + if (id == null) + { + throw new ArgumentNullException(nameof(id)); + } + if (entities == null) + { + throw new ArgumentNullException(nameof(entities)); + } + if (relations == null) + { + throw new ArgumentNullException(nameof(relations)); + } + if (warnings == null) + { + throw new ArgumentNullException(nameof(warnings)); + } + + Id = id; + Entities = entities.ToList(); + Relations = ResolveHealthcareRelations(entities, relations); + Warnings = warnings.ToList(); + } + + /// Initializes a new instance of DocumentHealthcareEntities. + /// Unique, non-empty document identifier. + /// Healthcare entities. + /// Healthcare entity relations. + /// Warnings encountered while processing document. + /// if showStats=true was specified in the request this field will contain information about the document payload. + internal DocumentHealthcareEntities(string id, IReadOnlyList entities, IReadOnlyList relations, IReadOnlyList warnings, TextDocumentStatistics? statistics) + { + Id = id; + Entities = entities; + Relations = ResolveHealthcareRelations(entities, relations); + Warnings = warnings; + Statistics = statistics; + } + + internal static IReadOnlyList ResolveHealthcareRelations(IEnumerable entities, IEnumerable relations) + { + List list = new List(); + foreach (HealthcareRelation relation in relations) + { + list.Add(new HealthcareRelation(entities, relation.RelationType, + relation.Bidirectional, + relation.Source, + relation.Target)); + } + + return list; + } + + /// Unique, non-empty document identifier. + public string Id { get; } + /// Healthcare entities. + public IReadOnlyList Entities { get; } + /// Healthcare entity relations. + public IReadOnlyList Relations { get; } + /// Warnings encountered while processing document. + public IReadOnlyList Warnings { get; } + /// if showStats=true was specified in the request this field will contain information about the document payload. + public TextDocumentStatistics? Statistics { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntitiesTaskParameters.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntitiesTaskParameters.cs new file mode 100644 index 000000000000..29206b5e2aa8 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntitiesTaskParameters.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("EntitiesTaskParameters")] + internal partial class EntitiesTaskParameters + { + internal string ModelVersion { get; set; } + internal StringIndexType? StringIndexType { get; set; } + + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityLinkingTaskParameters.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityLinkingTaskParameters.cs new file mode 100644 index 000000000000..97172502ee96 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityLinkingTaskParameters.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("EntityLinkingTaskParameters")] + internal partial class EntityLinkingTaskParameters + { + internal string ModelVersion { get; set; } + internal StringIndexType? StringIndexType { get; set; } + + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityLinkingTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityLinkingTasksItem.cs new file mode 100644 index 000000000000..31f37490333a --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityLinkingTasksItem.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("TasksStateTasksEntityLinkingTasksItem")] + internal partial class EntityLinkingTasksItem + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityLinkingTasksItemProperties.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityLinkingTasksItemProperties.cs new file mode 100644 index 000000000000..dd5cc54a6c01 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityLinkingTasksItemProperties.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("ComponentsIfu7BjSchemasTasksstatePropertiesTasksPropertiesEntitylinkingtasksItemsAllof1")] + internal partial class EntityLinkingTasksItemProperties + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityRecognitionPiiTasksItemsProperties.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityRecognitionPiiTasksItemsProperties.cs new file mode 100644 index 000000000000..4118c22133a2 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityRecognitionPiiTasksItemsProperties.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("Components15X8E9LSchemasTasksstatePropertiesTasksPropertiesEntityrecognitionpiitasksItemsAllof1")] + internal partial class EntityRecognitionPiiTasksItemProperties + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityRecognitionTasksItemProperties.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityRecognitionTasksItemProperties.cs new file mode 100644 index 000000000000..f34fac6ea2c1 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityRecognitionTasksItemProperties.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("Components15Gvwi3SchemasTasksstatePropertiesTasksPropertiesEntityrecognitiontasksItemsAllof1")] + internal partial class EntityRecognitionTasksItemProperties + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/ErrorCodeValue.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/ErrorCodeValue.cs index 727754f084a3..7cdab74711d2 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/ErrorCodeValue.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/ErrorCodeValue.cs @@ -15,6 +15,8 @@ internal enum ErrorCodeValue /// internalServerError. InternalServerError, /// serviceUnavailable. - ServiceUnavailable + ServiceUnavailable, + /// NotFound. + NotFound } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeBatchInput.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeBatchInput.Serialization.cs new file mode 100644 index 000000000000..d2e689818569 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeBatchInput.Serialization.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class AnalyzeBatchInput : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("analysisInput"); + writer.WriteObjectValue(AnalysisInput); + writer.WritePropertyName("tasks"); + writer.WriteObjectValue(Tasks); + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"); + writer.WriteStringValue(DisplayName); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeBatchInput.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeBatchInput.cs new file mode 100644 index 000000000000..1c77a16429d2 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeBatchInput.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The AnalyzeBatchInput. + internal partial class AnalyzeBatchInput : JobDescriptor + { + /// Initializes a new instance of AnalyzeBatchInput. + /// Contains a set of input documents to be analyzed by the service. + /// The set of tasks to execute on the input documents. Cannot specify the same task more than once. + /// or is null. + public AnalyzeBatchInput(MultiLanguageBatchInput analysisInput, JobManifestTasks tasks) + { + if (analysisInput == null) + { + throw new ArgumentNullException(nameof(analysisInput)); + } + if (tasks == null) + { + throw new ArgumentNullException(nameof(tasks)); + } + + AnalysisInput = analysisInput; + Tasks = tasks; + } + + /// Contains a set of input documents to be analyzed by the service. + public MultiLanguageBatchInput AnalysisInput { get; } + /// The set of tasks to execute on the input documents. Cannot specify the same task more than once. + public JobManifestTasks Tasks { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeJobState.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeJobState.Serialization.cs new file mode 100644 index 000000000000..35442959f54c --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeJobState.Serialization.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.TextAnalytics; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class AnalyzeJobState + { + internal static AnalyzeJobState DeserializeAnalyzeJobState(JsonElement element) + { + Optional> errors = default; + Optional statistics = default; + TasksStateTasks tasks = default; + Optional nextLink = default; + DateTimeOffset createdDateTime = default; + Optional displayName = default; + Optional expirationDateTime = default; + Guid jobId = default; + DateTimeOffset lastUpdateDateTime = default; + State status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("errors")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TextAnalyticsErrorInternal.DeserializeTextAnalyticsErrorInternal(item)); + } + errors = array; + continue; + } + if (property.NameEquals("statistics")) + { + statistics = TextDocumentBatchStatistics.DeserializeTextDocumentBatchStatistics(property.Value); + continue; + } + if (property.NameEquals("tasks")) + { + tasks = TasksStateTasks.DeserializeTasksStateTasks(property.Value); + continue; + } + if (property.NameEquals("@nextLink")) + { + nextLink = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdDateTime")) + { + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("displayName")) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("expirationDateTime")) + { + expirationDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("jobId")) + { + jobId = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("lastUpdateDateTime")) + { + lastUpdateDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("status")) + { + status = new State(property.Value.GetString()); + continue; + } + } + return new AnalyzeJobState(createdDateTime, displayName.Value, Optional.ToNullable(expirationDateTime), jobId, lastUpdateDateTime, status, Optional.ToList(errors), statistics.Value, tasks, nextLink.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeJobState.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeJobState.cs new file mode 100644 index 000000000000..b09f806fd181 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeJobState.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.TextAnalytics; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The AnalyzeJobState. + internal partial class AnalyzeJobState : JobMetadata + { + /// Initializes a new instance of AnalyzeJobState. + /// . + /// . + /// . + /// . + /// . + /// is null. + internal AnalyzeJobState(DateTimeOffset createdDateTime, Guid jobId, DateTimeOffset lastUpdateDateTime, State status, TasksStateTasks tasks) : base(createdDateTime, jobId, lastUpdateDateTime, status) + { + if (tasks == null) + { + throw new ArgumentNullException(nameof(tasks)); + } + + Errors = new ChangeTrackingList(); + Tasks = tasks; + } + + /// Initializes a new instance of AnalyzeJobState. + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// if showStats=true was specified in the request this field will contain information about the request payload. + /// . + /// . + internal AnalyzeJobState(DateTimeOffset createdDateTime, string displayName, DateTimeOffset? expirationDateTime, Guid jobId, DateTimeOffset lastUpdateDateTime, State status, IReadOnlyList errors, TextDocumentBatchStatistics statistics, TasksStateTasks tasks, string nextLink) : base(createdDateTime, displayName, expirationDateTime, jobId, lastUpdateDateTime, status) + { + Errors = errors; + Statistics = statistics; + Tasks = tasks; + NextLink = nextLink; + } + + public IReadOnlyList Errors { get; } + /// if showStats=true was specified in the request this field will contain information about the request payload. + public TextDocumentBatchStatistics Statistics { get; } + public TasksStateTasks Tasks { get; } + public string NextLink { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassification.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassification.Serialization.cs new file mode 100644 index 000000000000..aefddfdbe0a7 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassification.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class CustomClassification + { + internal static CustomClassification DeserializeCustomClassification(JsonElement element) + { + double confidenceScore = default; + string name = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("confidenceScore")) + { + confidenceScore = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + } + return new CustomClassification(confidenceScore, name); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassification.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassification.cs new file mode 100644 index 000000000000..53b2b46a3b35 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassification.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The CustomClassification. + internal partial class CustomClassification + { + /// Initializes a new instance of CustomClassification. + /// . + /// . + /// is null. + internal CustomClassification(double confidenceScore, string name) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + ConfidenceScore = confidenceScore; + Name = name; + } + + public double ConfidenceScore { get; } + public string Name { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationDocument.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationDocument.Serialization.cs new file mode 100644 index 000000000000..9742528914d6 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationDocument.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class CustomClassificationDocument + { + internal static CustomClassificationDocument DeserializeCustomClassificationDocument(JsonElement element) + { + string id = default; + IReadOnlyList classifications = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("classifications")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CustomClassification.DeserializeCustomClassification(item)); + } + classifications = array; + continue; + } + } + return new CustomClassificationDocument(id, classifications); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationDocument.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationDocument.cs new file mode 100644 index 000000000000..c16bdabae7a7 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationDocument.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The CustomClassificationDocument. + internal partial class CustomClassificationDocument + { + /// Initializes a new instance of CustomClassificationDocument. + /// . + /// . + /// or is null. + internal CustomClassificationDocument(string id, IEnumerable classifications) + { + if (id == null) + { + throw new ArgumentNullException(nameof(id)); + } + if (classifications == null) + { + throw new ArgumentNullException(nameof(classifications)); + } + + Id = id; + Classifications = classifications.ToList(); + } + + /// Initializes a new instance of CustomClassificationDocument. + /// . + /// . + internal CustomClassificationDocument(string id, IReadOnlyList classifications) + { + Id = id; + Classifications = classifications; + } + + public string Id { get; } + public IReadOnlyList Classifications { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationResult.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationResult.Serialization.cs new file mode 100644 index 000000000000..1ef33783383c --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationResult.Serialization.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.TextAnalytics; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class CustomClassificationResult + { + internal static CustomClassificationResult DeserializeCustomClassificationResult(JsonElement element) + { + IReadOnlyList documents = default; + IReadOnlyList errors = default; + Optional statistics = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("documents")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CustomClassificationDocument.DeserializeCustomClassificationDocument(item)); + } + documents = array; + continue; + } + if (property.NameEquals("errors")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DocumentError.DeserializeDocumentError(item)); + } + errors = array; + continue; + } + if (property.NameEquals("statistics")) + { + statistics = TextDocumentBatchStatistics.DeserializeTextDocumentBatchStatistics(property.Value); + continue; + } + } + return new CustomClassificationResult(documents, errors, statistics.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationResult.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationResult.cs new file mode 100644 index 000000000000..5d132959d892 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationResult.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.TextAnalytics; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The CustomClassificationResult. + internal partial class CustomClassificationResult + { + /// Initializes a new instance of CustomClassificationResult. + /// Response by document. + /// Errors by document id. + /// or is null. + internal CustomClassificationResult(IEnumerable documents, IEnumerable errors) + { + if (documents == null) + { + throw new ArgumentNullException(nameof(documents)); + } + if (errors == null) + { + throw new ArgumentNullException(nameof(errors)); + } + + Documents = documents.ToList(); + Errors = errors.ToList(); + } + + /// Initializes a new instance of CustomClassificationResult. + /// Response by document. + /// Errors by document id. + /// if showStats=true was specified in the request this field will contain information about the request payload. + internal CustomClassificationResult(IReadOnlyList documents, IReadOnlyList errors, TextDocumentBatchStatistics statistics) + { + Documents = documents; + Errors = errors; + Statistics = statistics; + } + + /// Response by document. + public IReadOnlyList Documents { get; } + /// Errors by document id. + public IReadOnlyList Errors { get; } + /// if showStats=true was specified in the request this field will contain information about the request payload. + public TextDocumentBatchStatistics Statistics { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTask.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTask.Serialization.cs new file mode 100644 index 000000000000..343a0cbfcb67 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTask.Serialization.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class CustomClassificationTask : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("parameters"); + writer.WriteObjectValue(Parameters); + writer.WritePropertyName("enable"); + writer.WriteBooleanValue(Enable); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTask.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTask.cs new file mode 100644 index 000000000000..2bcd574f0370 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTask.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The CustomClassificationTask. + internal partial class CustomClassificationTask : TextAnalyticsTask + { + /// Initializes a new instance of CustomClassificationTask. + /// . + /// . + /// is null. + public CustomClassificationTask(bool enable, CustomClassificationTaskParameters parameters) : base(enable) + { + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + Parameters = parameters; + } + + public CustomClassificationTaskParameters Parameters { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTaskParameters.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTaskParameters.Serialization.cs new file mode 100644 index 000000000000..aa00f665388d --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTaskParameters.Serialization.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class CustomClassificationTaskParameters : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("appId"); + writer.WriteStringValue(AppId); + writer.WritePropertyName("slotName"); + writer.WriteStringValue(SlotName); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTaskParameters.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTaskParameters.cs new file mode 100644 index 000000000000..ac5d300bf0a2 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTaskParameters.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The CustomClassificationTaskParameters. + internal partial class CustomClassificationTaskParameters + { + /// Initializes a new instance of CustomClassificationTaskParameters. + /// . + /// . + /// or is null. + public CustomClassificationTaskParameters(string appId, string slotName) + { + if (appId == null) + { + throw new ArgumentNullException(nameof(appId)); + } + if (slotName == null) + { + throw new ArgumentNullException(nameof(slotName)); + } + + AppId = appId; + SlotName = slotName; + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTasksItem.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTasksItem.Serialization.cs new file mode 100644 index 000000000000..963181aa8828 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTasksItem.Serialization.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class CustomClassificationTasksItem + { + internal static CustomClassificationTasksItem DeserializeCustomClassificationTasksItem(JsonElement element) + { + Optional results = default; + DateTimeOffset lastUpdateDateTime = default; + string name = default; + State status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results")) + { + results = CustomClassificationResult.DeserializeCustomClassificationResult(property.Value); + continue; + } + if (property.NameEquals("lastUpdateDateTime")) + { + lastUpdateDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("status")) + { + status = new State(property.Value.GetString()); + continue; + } + } + return new CustomClassificationTasksItem(lastUpdateDateTime, name, status, results.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTasksItem.cs new file mode 100644 index 000000000000..f11c10019c90 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTasksItem.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The TasksStateTasksCustomClassificationTasksItem. + internal partial class CustomClassificationTasksItem : TaskState + { + /// Initializes a new instance of CustomClassificationTasksItem. + /// . + /// . + /// . + /// is null. + internal CustomClassificationTasksItem(DateTimeOffset lastUpdateDateTime, string name, State status) : base(lastUpdateDateTime, name, status) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + } + + /// Initializes a new instance of CustomClassificationTasksItem. + /// . + /// . + /// . + /// . + /// is null. + internal CustomClassificationTasksItem(DateTimeOffset lastUpdateDateTime, string name, State status, CustomClassificationResult results) : base(lastUpdateDateTime, name, status) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + Results = results; + } + + public CustomClassificationResult Results { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTasksItemProperties.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTasksItemProperties.Serialization.cs new file mode 100644 index 000000000000..cff7f7350a65 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTasksItemProperties.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class CustomClassificationTasksItemProperties + { + internal static CustomClassificationTasksItemProperties DeserializeCustomClassificationTasksItemProperties(JsonElement element) + { + Optional results = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results")) + { + results = CustomClassificationResult.DeserializeCustomClassificationResult(property.Value); + continue; + } + } + return new CustomClassificationTasksItemProperties(results.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTasksItemProperties.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTasksItemProperties.cs new file mode 100644 index 000000000000..d9f40b5d39b8 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomClassificationTasksItemProperties.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The Components4X9ZamSchemasTasksstatePropertiesTasksPropertiesCustomclassificationtasksItemsAllof1. + internal partial class CustomClassificationTasksItemProperties + { + /// Initializes a new instance of CustomClassificationTasksItemProperties. + internal CustomClassificationTasksItemProperties() + { + } + + /// Initializes a new instance of CustomClassificationTasksItemProperties. + /// . + internal CustomClassificationTasksItemProperties(CustomClassificationResult results) + { + Results = results; + } + + public CustomClassificationResult Results { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesDocument.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesDocument.Serialization.cs new file mode 100644 index 000000000000..dec2667ce3bd --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesDocument.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class CustomEntitiesDocument + { + internal static CustomEntitiesDocument DeserializeCustomEntitiesDocument(JsonElement element) + { + string id = default; + IReadOnlyList entities = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("entities")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CustomEntity.DeserializeCustomEntity(item)); + } + entities = array; + continue; + } + } + return new CustomEntitiesDocument(id, entities); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesDocument.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesDocument.cs new file mode 100644 index 000000000000..7b6b40768b00 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesDocument.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The CustomEntitiesDocument. + internal partial class CustomEntitiesDocument + { + /// Initializes a new instance of CustomEntitiesDocument. + /// . + /// . + /// or is null. + internal CustomEntitiesDocument(string id, IEnumerable entities) + { + if (id == null) + { + throw new ArgumentNullException(nameof(id)); + } + if (entities == null) + { + throw new ArgumentNullException(nameof(entities)); + } + + Id = id; + Entities = entities.ToList(); + } + + /// Initializes a new instance of CustomEntitiesDocument. + /// . + /// . + internal CustomEntitiesDocument(string id, IReadOnlyList entities) + { + Id = id; + Entities = entities; + } + + public string Id { get; } + public IReadOnlyList Entities { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesResult.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesResult.Serialization.cs new file mode 100644 index 000000000000..1099f3b6486a --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesResult.Serialization.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.TextAnalytics; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class CustomEntitiesResult + { + internal static CustomEntitiesResult DeserializeCustomEntitiesResult(JsonElement element) + { + IReadOnlyList documents = default; + IReadOnlyList errors = default; + Optional statistics = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("documents")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CustomEntitiesDocument.DeserializeCustomEntitiesDocument(item)); + } + documents = array; + continue; + } + if (property.NameEquals("errors")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DocumentError.DeserializeDocumentError(item)); + } + errors = array; + continue; + } + if (property.NameEquals("statistics")) + { + statistics = TextDocumentBatchStatistics.DeserializeTextDocumentBatchStatistics(property.Value); + continue; + } + } + return new CustomEntitiesResult(documents, errors, statistics.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesResult.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesResult.cs new file mode 100644 index 000000000000..9a0af1d3cdd9 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesResult.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.TextAnalytics; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The CustomEntitiesResult. + internal partial class CustomEntitiesResult + { + /// Initializes a new instance of CustomEntitiesResult. + /// Response by document. + /// Errors by document id. + /// or is null. + internal CustomEntitiesResult(IEnumerable documents, IEnumerable errors) + { + if (documents == null) + { + throw new ArgumentNullException(nameof(documents)); + } + if (errors == null) + { + throw new ArgumentNullException(nameof(errors)); + } + + Documents = documents.ToList(); + Errors = errors.ToList(); + } + + /// Initializes a new instance of CustomEntitiesResult. + /// Response by document. + /// Errors by document id. + /// if showStats=true was specified in the request this field will contain information about the request payload. + internal CustomEntitiesResult(IReadOnlyList documents, IReadOnlyList errors, TextDocumentBatchStatistics statistics) + { + Documents = documents; + Errors = errors; + Statistics = statistics; + } + + /// Response by document. + public IReadOnlyList Documents { get; } + /// Errors by document id. + public IReadOnlyList Errors { get; } + /// if showStats=true was specified in the request this field will contain information about the request payload. + public TextDocumentBatchStatistics Statistics { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesTask.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesTask.Serialization.cs new file mode 100644 index 000000000000..6736fb4c09e8 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesTask.Serialization.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class CustomEntitiesTask : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("parameters"); + writer.WriteObjectValue(Parameters); + writer.WritePropertyName("enable"); + writer.WriteBooleanValue(Enable); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesTask.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesTask.cs new file mode 100644 index 000000000000..441a8f2ac326 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesTask.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The CustomEntitiesTask. + internal partial class CustomEntitiesTask : TextAnalyticsTask + { + /// Initializes a new instance of CustomEntitiesTask. + /// . + /// . + /// is null. + public CustomEntitiesTask(bool enable, CustomEntitiesTaskParameters parameters) : base(enable) + { + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + Parameters = parameters; + } + + public CustomEntitiesTaskParameters Parameters { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesTaskParameters.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesTaskParameters.Serialization.cs new file mode 100644 index 000000000000..5267a6ff9ed8 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesTaskParameters.Serialization.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class CustomEntitiesTaskParameters : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("appId"); + writer.WriteStringValue(AppId); + writer.WritePropertyName("slotName"); + writer.WriteStringValue(SlotName); + if (Optional.IsDefined(StringIndexType)) + { + writer.WritePropertyName("stringIndexType"); + writer.WriteStringValue(StringIndexType.Value.ToString()); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesTaskParameters.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesTaskParameters.cs new file mode 100644 index 000000000000..92f0cdc331c0 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntitiesTaskParameters.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The CustomEntitiesTaskParameters. + internal partial class CustomEntitiesTaskParameters + { + /// Initializes a new instance of CustomEntitiesTaskParameters. + /// . + /// . + /// or is null. + public CustomEntitiesTaskParameters(string appId, string slotName) + { + if (appId == null) + { + throw new ArgumentNullException(nameof(appId)); + } + if (slotName == null) + { + throw new ArgumentNullException(nameof(slotName)); + } + + AppId = appId; + SlotName = slotName; + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntity.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntity.Serialization.cs new file mode 100644 index 000000000000..f53cfef2675e --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntity.Serialization.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class CustomEntity + { + internal static CustomEntity DeserializeCustomEntity(JsonElement element) + { + Optional> children = default; + string text = default; + string category = default; + Optional subcategory = default; + int offset = default; + int length = default; + double confidenceScore = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("children")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DeserializeCustomEntity(item)); + } + children = array; + continue; + } + if (property.NameEquals("text")) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("category")) + { + category = property.Value.GetString(); + continue; + } + if (property.NameEquals("subcategory")) + { + subcategory = property.Value.GetString(); + continue; + } + if (property.NameEquals("offset")) + { + offset = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("length")) + { + length = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("confidenceScore")) + { + confidenceScore = property.Value.GetDouble(); + continue; + } + } + return new CustomEntity(text, category, subcategory.Value, offset, length, confidenceScore, Optional.ToList(children)); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntity.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntity.cs new file mode 100644 index 000000000000..b473c6390429 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntity.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The CustomEntity. + internal partial class CustomEntity : Entity + { + /// Initializes a new instance of CustomEntity. + /// Entity text as appears in the request. + /// Entity type. + /// Start position for the entity text. Use of different 'stringIndexType' values can affect the offset returned. + /// Length for the entity text. Use of different 'stringIndexType' values can affect the length returned. + /// Confidence score between 0 and 1 of the extracted entity. + /// or is null. + internal CustomEntity(string text, string category, int offset, int length, double confidenceScore) : base(text, category, offset, length, confidenceScore) + { + if (text == null) + { + throw new ArgumentNullException(nameof(text)); + } + if (category == null) + { + throw new ArgumentNullException(nameof(category)); + } + + Children = new ChangeTrackingList(); + } + + /// Initializes a new instance of CustomEntity. + /// Entity text as appears in the request. + /// Entity type. + /// (Optional) Entity sub type. + /// Start position for the entity text. Use of different 'stringIndexType' values can affect the offset returned. + /// Length for the entity text. Use of different 'stringIndexType' values can affect the length returned. + /// Confidence score between 0 and 1 of the extracted entity. + /// . + internal CustomEntity(string text, string category, string subcategory, int offset, int length, double confidenceScore, IReadOnlyList children) : base(text, category, subcategory, offset, length, confidenceScore) + { + Children = children; + } + + public IReadOnlyList Children { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntityRecognitionTasksItem.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntityRecognitionTasksItem.Serialization.cs new file mode 100644 index 000000000000..08bded93d377 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntityRecognitionTasksItem.Serialization.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class CustomEntityRecognitionTasksItem + { + internal static CustomEntityRecognitionTasksItem DeserializeCustomEntityRecognitionTasksItem(JsonElement element) + { + Optional results = default; + DateTimeOffset lastUpdateDateTime = default; + string name = default; + State status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results")) + { + results = CustomEntitiesResult.DeserializeCustomEntitiesResult(property.Value); + continue; + } + if (property.NameEquals("lastUpdateDateTime")) + { + lastUpdateDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("status")) + { + status = new State(property.Value.GetString()); + continue; + } + } + return new CustomEntityRecognitionTasksItem(lastUpdateDateTime, name, status, results.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntityRecognitionTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntityRecognitionTasksItem.cs new file mode 100644 index 000000000000..3ed7c0169baa --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntityRecognitionTasksItem.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The TasksStateTasksCustomEntityRecognitionTasksItem. + internal partial class CustomEntityRecognitionTasksItem : TaskState + { + /// Initializes a new instance of CustomEntityRecognitionTasksItem. + /// . + /// . + /// . + /// is null. + internal CustomEntityRecognitionTasksItem(DateTimeOffset lastUpdateDateTime, string name, State status) : base(lastUpdateDateTime, name, status) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + } + + /// Initializes a new instance of CustomEntityRecognitionTasksItem. + /// . + /// . + /// . + /// . + /// is null. + internal CustomEntityRecognitionTasksItem(DateTimeOffset lastUpdateDateTime, string name, State status, CustomEntitiesResult results) : base(lastUpdateDateTime, name, status) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + Results = results; + } + + public CustomEntitiesResult Results { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntityRecognitionTasksItemProperties.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntityRecognitionTasksItemProperties.Serialization.cs new file mode 100644 index 000000000000..99ef8e2a0ac5 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntityRecognitionTasksItemProperties.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class CustomEntityRecognitionTasksItemProperties + { + internal static CustomEntityRecognitionTasksItemProperties DeserializeCustomEntityRecognitionTasksItemProperties(JsonElement element) + { + Optional results = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results")) + { + results = CustomEntitiesResult.DeserializeCustomEntitiesResult(property.Value); + continue; + } + } + return new CustomEntityRecognitionTasksItemProperties(results.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntityRecognitionTasksItemProperties.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntityRecognitionTasksItemProperties.cs new file mode 100644 index 000000000000..81fe4fef6639 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomEntityRecognitionTasksItemProperties.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The Components1Yw06Y0SchemasTasksstatePropertiesTasksPropertiesCustomentityrecognitiontasksItemsAllof1. + internal partial class CustomEntityRecognitionTasksItemProperties + { + /// Initializes a new instance of CustomEntityRecognitionTasksItemProperties. + internal CustomEntityRecognitionTasksItemProperties() + { + } + + /// Initializes a new instance of CustomEntityRecognitionTasksItemProperties. + /// . + internal CustomEntityRecognitionTasksItemProperties(CustomEntitiesResult results) + { + Results = results; + } + + public CustomEntitiesResult Results { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/DocumentHealthcareEntities.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/DocumentHealthcareEntities.Serialization.cs new file mode 100644 index 000000000000..dcfbd9454da8 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/DocumentHealthcareEntities.Serialization.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.TextAnalytics; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class DocumentHealthcareEntities + { + internal static DocumentHealthcareEntities DeserializeDocumentHealthcareEntities(JsonElement element) + { + string id = default; + IReadOnlyList entities = default; + IReadOnlyList relations = default; + IReadOnlyList warnings = default; + Optional statistics = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("entities")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(HealthcareEntity.DeserializeHealthcareEntity(item)); + } + entities = array; + continue; + } + if (property.NameEquals("relations")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(HealthcareRelation.DeserializeHealthcareRelation(item)); + } + relations = array; + continue; + } + if (property.NameEquals("warnings")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TextAnalyticsWarningInternal.DeserializeTextAnalyticsWarningInternal(item)); + } + warnings = array; + continue; + } + if (property.NameEquals("statistics")) + { + statistics = TextDocumentStatistics.DeserializeTextDocumentStatistics(property.Value); + continue; + } + } + return new DocumentHealthcareEntities(id, entities, relations, warnings, Optional.ToNullable(statistics)); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/DocumentHealthcareEntities.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/DocumentHealthcareEntities.cs new file mode 100644 index 000000000000..f3196f8c2855 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/DocumentHealthcareEntities.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.TextAnalytics; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The DocumentHealthcareEntities. + internal partial class DocumentHealthcareEntities + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntitiesTask.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntitiesTask.Serialization.cs new file mode 100644 index 000000000000..ea9d819b0a24 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntitiesTask.Serialization.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class EntitiesTask : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Parameters)) + { + writer.WritePropertyName("parameters"); + writer.WriteObjectValue(Parameters); + } + writer.WritePropertyName("enable"); + writer.WriteBooleanValue(Enable); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntitiesTask.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntitiesTask.cs new file mode 100644 index 000000000000..ae379b09fdcc --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntitiesTask.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The EntitiesTask. + internal partial class EntitiesTask : TextAnalyticsTask + { + /// Initializes a new instance of EntitiesTask. + /// . + public EntitiesTask(bool enable) : base(enable) + { + } + + public EntitiesTaskParameters Parameters { get; set; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntitiesTaskParameters.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntitiesTaskParameters.Serialization.cs new file mode 100644 index 000000000000..4dd7ede4d0a9 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntitiesTaskParameters.Serialization.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class EntitiesTaskParameters : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(ModelVersion)) + { + writer.WritePropertyName("model-version"); + writer.WriteStringValue(ModelVersion); + } + if (Optional.IsDefined(StringIndexType)) + { + writer.WritePropertyName("stringIndexType"); + writer.WriteStringValue(StringIndexType.Value.ToString()); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntitiesTaskParameters.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntitiesTaskParameters.cs new file mode 100644 index 000000000000..7d3d86963a44 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntitiesTaskParameters.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The EntitiesTaskParameters. + internal partial class EntitiesTaskParameters + { + /// Initializes a new instance of EntitiesTaskParameters. + public EntitiesTaskParameters() + { + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/Entity.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/Entity.cs index ff41fcafc698..56a5002e7305 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/Entity.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/Entity.cs @@ -14,9 +14,9 @@ internal partial class Entity { /// Initializes a new instance of Entity. /// Entity text as appears in the request. - /// Entity type, such as Person/Location/Org/SSN etc. - /// Start position for the entity text. - /// Length for the entity text. + /// Entity type. + /// Start position for the entity text. Use of different 'stringIndexType' values can affect the offset returned. + /// Length for the entity text. Use of different 'stringIndexType' values can affect the length returned. /// Confidence score between 0 and 1 of the extracted entity. /// or is null. internal Entity(string text, string category, int offset, int length, double confidenceScore) @@ -39,10 +39,10 @@ internal Entity(string text, string category, int offset, int length, double con /// Initializes a new instance of Entity. /// Entity text as appears in the request. - /// Entity type, such as Person/Location/Org/SSN etc. - /// Entity sub type, such as Age/Year/TimeRange etc. - /// Start position for the entity text. - /// Length for the entity text. + /// Entity type. + /// (Optional) Entity sub type. + /// Start position for the entity text. Use of different 'stringIndexType' values can affect the offset returned. + /// Length for the entity text. Use of different 'stringIndexType' values can affect the length returned. /// Confidence score between 0 and 1 of the extracted entity. internal Entity(string text, string category, string subcategory, int offset, int length, double confidenceScore) { @@ -56,13 +56,13 @@ internal Entity(string text, string category, string subcategory, int offset, in /// Entity text as appears in the request. public string Text { get; } - /// Entity type, such as Person/Location/Org/SSN etc. + /// Entity type. public string Category { get; } - /// Entity sub type, such as Age/Year/TimeRange etc. + /// (Optional) Entity sub type. public string Subcategory { get; } - /// Start position for the entity text. + /// Start position for the entity text. Use of different 'stringIndexType' values can affect the offset returned. public int Offset { get; } - /// Length for the entity text. + /// Length for the entity text. Use of different 'stringIndexType' values can affect the length returned. public int Length { get; } /// Confidence score between 0 and 1 of the extracted entity. public double ConfidenceScore { get; } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTask.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTask.Serialization.cs new file mode 100644 index 000000000000..42a26a38b000 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTask.Serialization.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class EntityLinkingTask : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Parameters)) + { + writer.WritePropertyName("parameters"); + writer.WriteObjectValue(Parameters); + } + writer.WritePropertyName("enable"); + writer.WriteBooleanValue(Enable); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTask.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTask.cs new file mode 100644 index 000000000000..bdf884df59f3 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTask.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The EntityLinkingTask. + internal partial class EntityLinkingTask : TextAnalyticsTask + { + /// Initializes a new instance of EntityLinkingTask. + /// . + public EntityLinkingTask(bool enable) : base(enable) + { + } + + public EntityLinkingTaskParameters Parameters { get; set; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTaskParameters.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTaskParameters.Serialization.cs new file mode 100644 index 000000000000..264189a79de0 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTaskParameters.Serialization.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class EntityLinkingTaskParameters : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(ModelVersion)) + { + writer.WritePropertyName("model-version"); + writer.WriteStringValue(ModelVersion); + } + if (Optional.IsDefined(StringIndexType)) + { + writer.WritePropertyName("stringIndexType"); + writer.WriteStringValue(StringIndexType.Value.ToString()); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTaskParameters.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTaskParameters.cs new file mode 100644 index 000000000000..770d3de26bdf --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTaskParameters.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The EntityLinkingTaskParameters. + internal partial class EntityLinkingTaskParameters + { + /// Initializes a new instance of EntityLinkingTaskParameters. + public EntityLinkingTaskParameters() + { + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTasksItem.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTasksItem.Serialization.cs new file mode 100644 index 000000000000..dde1ae88fe93 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTasksItem.Serialization.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class EntityLinkingTasksItem + { + internal static EntityLinkingTasksItem DeserializeEntityLinkingTasksItem(JsonElement element) + { + Optional results = default; + DateTimeOffset lastUpdateDateTime = default; + string name = default; + State status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results")) + { + results = EntityLinkingResult.DeserializeEntityLinkingResult(property.Value); + continue; + } + if (property.NameEquals("lastUpdateDateTime")) + { + lastUpdateDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("status")) + { + status = new State(property.Value.GetString()); + continue; + } + } + return new EntityLinkingTasksItem(lastUpdateDateTime, name, status, results.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTasksItem.cs new file mode 100644 index 000000000000..bf08098a7097 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTasksItem.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The TasksStateTasksEntityLinkingTasksItem. + internal partial class EntityLinkingTasksItem : TaskState + { + /// Initializes a new instance of EntityLinkingTasksItem. + /// . + /// . + /// . + /// is null. + internal EntityLinkingTasksItem(DateTimeOffset lastUpdateDateTime, string name, State status) : base(lastUpdateDateTime, name, status) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + } + + /// Initializes a new instance of EntityLinkingTasksItem. + /// . + /// . + /// . + /// . + /// is null. + internal EntityLinkingTasksItem(DateTimeOffset lastUpdateDateTime, string name, State status, EntityLinkingResult results) : base(lastUpdateDateTime, name, status) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + Results = results; + } + + public EntityLinkingResult Results { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTasksItemProperties.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTasksItemProperties.Serialization.cs new file mode 100644 index 000000000000..c42691af7063 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTasksItemProperties.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class EntityLinkingTasksItemProperties + { + internal static EntityLinkingTasksItemProperties DeserializeEntityLinkingTasksItemProperties(JsonElement element) + { + Optional results = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results")) + { + results = EntityLinkingResult.DeserializeEntityLinkingResult(property.Value); + continue; + } + } + return new EntityLinkingTasksItemProperties(results.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTasksItemProperties.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTasksItemProperties.cs new file mode 100644 index 000000000000..f0f88d84eada --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTasksItemProperties.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The ComponentsIfu7BjSchemasTasksstatePropertiesTasksPropertiesEntitylinkingtasksItemsAllof1. + internal partial class EntityLinkingTasksItemProperties + { + /// Initializes a new instance of EntityLinkingTasksItemProperties. + internal EntityLinkingTasksItemProperties() + { + } + + /// Initializes a new instance of EntityLinkingTasksItemProperties. + /// . + internal EntityLinkingTasksItemProperties(EntityLinkingResult results) + { + Results = results; + } + + public EntityLinkingResult Results { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityRecognitionPiiTasksItemProperties.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityRecognitionPiiTasksItemProperties.Serialization.cs new file mode 100644 index 000000000000..8fd1f1a124e4 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityRecognitionPiiTasksItemProperties.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class EntityRecognitionPiiTasksItemProperties + { + internal static EntityRecognitionPiiTasksItemProperties DeserializeEntityRecognitionPiiTasksItemProperties(JsonElement element) + { + Optional results = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results")) + { + results = PiiResult.DeserializePiiResult(property.Value); + continue; + } + } + return new EntityRecognitionPiiTasksItemProperties(results.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityRecognitionPiiTasksItemProperties.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityRecognitionPiiTasksItemProperties.cs new file mode 100644 index 000000000000..16b585c94faf --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityRecognitionPiiTasksItemProperties.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The Components15X8E9LSchemasTasksstatePropertiesTasksPropertiesEntityrecognitionpiitasksItemsAllof1. + internal partial class EntityRecognitionPiiTasksItemProperties + { + /// Initializes a new instance of EntityRecognitionPiiTasksItemProperties. + internal EntityRecognitionPiiTasksItemProperties() + { + } + + /// Initializes a new instance of EntityRecognitionPiiTasksItemProperties. + /// . + internal EntityRecognitionPiiTasksItemProperties(PiiResult results) + { + Results = results; + } + + public PiiResult Results { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityRecognitionTasksItemProperties.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityRecognitionTasksItemProperties.Serialization.cs new file mode 100644 index 000000000000..8ebb0b5d7677 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityRecognitionTasksItemProperties.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class EntityRecognitionTasksItemProperties + { + internal static EntityRecognitionTasksItemProperties DeserializeEntityRecognitionTasksItemProperties(JsonElement element) + { + Optional results = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results")) + { + results = EntitiesResult.DeserializeEntitiesResult(property.Value); + continue; + } + } + return new EntityRecognitionTasksItemProperties(results.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityRecognitionTasksItemProperties.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityRecognitionTasksItemProperties.cs new file mode 100644 index 000000000000..f91af84f43c1 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityRecognitionTasksItemProperties.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The Components15Gvwi3SchemasTasksstatePropertiesTasksPropertiesEntityrecognitiontasksItemsAllof1. + internal partial class EntityRecognitionTasksItemProperties + { + /// Initializes a new instance of EntityRecognitionTasksItemProperties. + internal EntityRecognitionTasksItemProperties() + { + } + + /// Initializes a new instance of EntityRecognitionTasksItemProperties. + /// . + internal EntityRecognitionTasksItemProperties(EntitiesResult results) + { + Results = results; + } + + public EntitiesResult Results { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/ErrorCodeValue.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/ErrorCodeValue.Serialization.cs index 0bb72c72e237..39ffc3a10335 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/ErrorCodeValue.Serialization.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/ErrorCodeValue.Serialization.cs @@ -17,6 +17,7 @@ internal static class ErrorCodeValueExtensions ErrorCodeValue.InvalidArgument => "InvalidArgument", ErrorCodeValue.InternalServerError => "InternalServerError", ErrorCodeValue.ServiceUnavailable => "ServiceUnavailable", + ErrorCodeValue.NotFound => "NotFound", _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ErrorCodeValue value.") }; @@ -26,6 +27,7 @@ public static ErrorCodeValue ToErrorCodeValue(this string value) if (string.Equals(value, "InvalidArgument", StringComparison.InvariantCultureIgnoreCase)) return ErrorCodeValue.InvalidArgument; if (string.Equals(value, "InternalServerError", StringComparison.InvariantCultureIgnoreCase)) return ErrorCodeValue.InternalServerError; if (string.Equals(value, "ServiceUnavailable", StringComparison.InvariantCultureIgnoreCase)) return ErrorCodeValue.ServiceUnavailable; + if (string.Equals(value, "NotFound", StringComparison.InvariantCultureIgnoreCase)) return ErrorCodeValue.NotFound; throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ErrorCodeValue value."); } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntity.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntity.Serialization.cs new file mode 100644 index 000000000000..cd015b5706a4 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntity.Serialization.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class HealthcareEntity + { + internal static HealthcareEntity DeserializeHealthcareEntity(JsonElement element) + { + bool isNegated = default; + Optional> links = default; + string text = default; + string category = default; + Optional subcategory = default; + int offset = default; + int length = default; + double confidenceScore = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("isNegated")) + { + isNegated = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("links")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(HealthcareEntityLink.DeserializeHealthcareEntityLink(item)); + } + links = array; + continue; + } + if (property.NameEquals("text")) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("category")) + { + category = property.Value.GetString(); + continue; + } + if (property.NameEquals("subcategory")) + { + subcategory = property.Value.GetString(); + continue; + } + if (property.NameEquals("offset")) + { + offset = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("length")) + { + length = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("confidenceScore")) + { + confidenceScore = property.Value.GetDouble(); + continue; + } + } + return new HealthcareEntity(text, category, subcategory.Value, offset, length, confidenceScore, isNegated, Optional.ToList(links)); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntity.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntity.cs new file mode 100644 index 000000000000..5147b9dbcd6f --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntity.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The HealthcareEntity. + internal partial class HealthcareEntity : Entity + { + /// Initializes a new instance of HealthcareEntity. + /// Entity text as appears in the request. + /// Entity type. + /// Start position for the entity text. Use of different 'stringIndexType' values can affect the offset returned. + /// Length for the entity text. Use of different 'stringIndexType' values can affect the length returned. + /// Confidence score between 0 and 1 of the extracted entity. + /// . + /// or is null. + internal HealthcareEntity(string text, string category, int offset, int length, double confidenceScore, bool isNegated) : base(text, category, offset, length, confidenceScore) + { + if (text == null) + { + throw new ArgumentNullException(nameof(text)); + } + if (category == null) + { + throw new ArgumentNullException(nameof(category)); + } + + IsNegated = isNegated; + Links = new ChangeTrackingList(); + } + + /// Initializes a new instance of HealthcareEntity. + /// Entity text as appears in the request. + /// Entity type. + /// (Optional) Entity sub type. + /// Start position for the entity text. Use of different 'stringIndexType' values can affect the offset returned. + /// Length for the entity text. Use of different 'stringIndexType' values can affect the length returned. + /// Confidence score between 0 and 1 of the extracted entity. + /// . + /// Entity references in known data sources. + internal HealthcareEntity(string text, string category, string subcategory, int offset, int length, double confidenceScore, bool isNegated, IReadOnlyList links) : base(text, category, subcategory, offset, length, confidenceScore) + { + IsNegated = isNegated; + Links = links; + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityLink.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityLink.Serialization.cs new file mode 100644 index 000000000000..3d6f4c40a79a --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityLink.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class HealthcareEntityLink + { + internal static HealthcareEntityLink DeserializeHealthcareEntityLink(JsonElement element) + { + string dataSource = default; + string id = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("dataSource")) + { + dataSource = property.Value.GetString(); + continue; + } + if (property.NameEquals("id")) + { + id = property.Value.GetString(); + continue; + } + } + return new HealthcareEntityLink(dataSource, id); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityLink.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityLink.cs new file mode 100644 index 000000000000..6954ae8ce5df --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityLink.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The HealthcareEntityLink. + internal partial class HealthcareEntityLink + { + /// Initializes a new instance of HealthcareEntityLink. + /// Entity Catalog. Examples include: UMLS, CHV, MSH, etc. + /// Entity id in the given source catalog. + /// or is null. + internal HealthcareEntityLink(string dataSource, string id) + { + if (dataSource == null) + { + throw new ArgumentNullException(nameof(dataSource)); + } + if (id == null) + { + throw new ArgumentNullException(nameof(id)); + } + + DataSource = dataSource; + Id = id; + } + + /// Entity Catalog. Examples include: UMLS, CHV, MSH, etc. + public string DataSource { get; } + /// Entity id in the given source catalog. + public string Id { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareJobState.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareJobState.Serialization.cs new file mode 100644 index 000000000000..a76f8569c2c0 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareJobState.Serialization.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class HealthcareJobState + { + internal static HealthcareJobState DeserializeHealthcareJobState(JsonElement element) + { + Optional results = default; + Optional nextLink = default; + DateTimeOffset createdDateTime = default; + Optional displayName = default; + Optional expirationDateTime = default; + Guid jobId = default; + DateTimeOffset lastUpdateDateTime = default; + State status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results")) + { + results = HealthcareResult.DeserializeHealthcareResult(property.Value); + continue; + } + if (property.NameEquals("@nextLink")) + { + nextLink = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdDateTime")) + { + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("displayName")) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("expirationDateTime")) + { + expirationDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("jobId")) + { + jobId = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("lastUpdateDateTime")) + { + lastUpdateDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("status")) + { + status = new State(property.Value.GetString()); + continue; + } + } + return new HealthcareJobState(createdDateTime, displayName.Value, Optional.ToNullable(expirationDateTime), jobId, lastUpdateDateTime, status, results.Value, nextLink.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareJobState.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareJobState.cs new file mode 100644 index 000000000000..cf96fdae0896 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareJobState.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The HealthcareJobState. + internal partial class HealthcareJobState : JobMetadata + { + /// Initializes a new instance of HealthcareJobState. + /// . + /// . + /// . + /// . + internal HealthcareJobState(DateTimeOffset createdDateTime, Guid jobId, DateTimeOffset lastUpdateDateTime, State status) : base(createdDateTime, jobId, lastUpdateDateTime, status) + { + } + + /// Initializes a new instance of HealthcareJobState. + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + internal HealthcareJobState(DateTimeOffset createdDateTime, string displayName, DateTimeOffset? expirationDateTime, Guid jobId, DateTimeOffset lastUpdateDateTime, State status, HealthcareResult results, string nextLink) : base(createdDateTime, displayName, expirationDateTime, jobId, lastUpdateDateTime, status) + { + Results = results; + NextLink = nextLink; + } + + public HealthcareResult Results { get; } + public string NextLink { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareRelation.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareRelation.Serialization.cs new file mode 100644 index 000000000000..a9c20522977f --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareRelation.Serialization.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class HealthcareRelation + { + internal static HealthcareRelation DeserializeHealthcareRelation(JsonElement element) + { + string relationType = default; + bool bidirectional = default; + string source = default; + string target = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("relationType")) + { + relationType = property.Value.GetString(); + continue; + } + if (property.NameEquals("bidirectional")) + { + bidirectional = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("source")) + { + source = property.Value.GetString(); + continue; + } + if (property.NameEquals("target")) + { + target = property.Value.GetString(); + continue; + } + } + return new HealthcareRelation(relationType, bidirectional, source, target); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareRelation.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareRelation.cs new file mode 100644 index 000000000000..42e163ae0deb --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareRelation.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The HealthcareRelation. + internal partial class HealthcareRelation + { + /// Initializes a new instance of HealthcareRelation. + /// Type of relation. Examples include: `DosageOfMedication` or 'FrequencyOfMedication', etc. + /// If true the relation between the entities is bidirectional, otherwise directionality is source to target. + /// Reference link to the source entity. + /// Reference link to the target entity. + /// , , or is null. + internal HealthcareRelation(string relationType, bool bidirectional, string source, string target) + { + if (relationType == null) + { + throw new ArgumentNullException(nameof(relationType)); + } + if (source == null) + { + throw new ArgumentNullException(nameof(source)); + } + if (target == null) + { + throw new ArgumentNullException(nameof(target)); + } + + RelationType = relationType; + Bidirectional = bidirectional; + Source = source; + Target = target; + } + + /// Type of relation. Examples include: `DosageOfMedication` or 'FrequencyOfMedication', etc. + public string RelationType { get; } + /// If true the relation between the entities is bidirectional, otherwise directionality is source to target. + public bool Bidirectional { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareResult.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareResult.Serialization.cs new file mode 100644 index 000000000000..8e27bcaacf07 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareResult.Serialization.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.TextAnalytics; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + public partial class HealthcareResult + { + internal static HealthcareResult DeserializeHealthcareResult(JsonElement element) + { + IReadOnlyList documents = default; + IReadOnlyList errors = default; + Optional statistics = default; + string modelVersion = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("documents")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DocumentHealthcareEntities.DeserializeDocumentHealthcareEntities(item)); + } + documents = array; + continue; + } + if (property.NameEquals("errors")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DocumentError.DeserializeDocumentError(item)); + } + errors = array; + continue; + } + if (property.NameEquals("statistics")) + { + statistics = TextDocumentBatchStatistics.DeserializeTextDocumentBatchStatistics(property.Value); + continue; + } + if (property.NameEquals("modelVersion")) + { + modelVersion = property.Value.GetString(); + continue; + } + } + return new HealthcareResult(documents, errors, statistics.Value, modelVersion); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareResult.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareResult.cs new file mode 100644 index 000000000000..46cac298d88b --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareResult.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.TextAnalytics; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The HealthcareResult. + public partial class HealthcareResult + { + /// Initializes a new instance of HealthcareResult. + /// Response by document. + /// Errors by document id. + /// This field indicates which model is used for scoring. + /// , , or is null. + internal HealthcareResult(IEnumerable documents, IEnumerable errors, string modelVersion) + { + if (documents == null) + { + throw new ArgumentNullException(nameof(documents)); + } + if (errors == null) + { + throw new ArgumentNullException(nameof(errors)); + } + if (modelVersion == null) + { + throw new ArgumentNullException(nameof(modelVersion)); + } + + Documents = documents.ToList(); + Errors = errors.ToList(); + ModelVersion = modelVersion; + } + + /// Initializes a new instance of HealthcareResult. + /// Response by document. + /// Errors by document id. + /// if showStats=true was specified in the request this field will contain information about the request payload. + /// This field indicates which model is used for scoring. + internal HealthcareResult(IReadOnlyList documents, IReadOnlyList errors, TextDocumentBatchStatistics statistics, string modelVersion) + { + Documents = documents; + Errors = errors; + Statistics = statistics; + ModelVersion = modelVersion; + } + /// if showStats=true was specified in the request this field will contain information about the request payload. + public TextDocumentBatchStatistics Statistics { get; } + /// This field indicates which model is used for scoring. + public string ModelVersion { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobDescriptor.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobDescriptor.Serialization.cs new file mode 100644 index 000000000000..2f17bcbdcd03 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobDescriptor.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class JobDescriptor : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"); + writer.WriteStringValue(DisplayName); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobDescriptor.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobDescriptor.cs new file mode 100644 index 000000000000..1c8f028ed44e --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobDescriptor.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The JobDescriptor. + internal partial class JobDescriptor + { + /// Initializes a new instance of JobDescriptor. + public JobDescriptor() + { + } + + /// Optional display name for the analysis job. + public string DisplayName { get; set; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifest.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifest.Serialization.cs new file mode 100644 index 000000000000..82749d35315f --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifest.Serialization.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class JobManifest : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("tasks"); + writer.WriteObjectValue(Tasks); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifest.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifest.cs new file mode 100644 index 000000000000..6dd62f2a4fea --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifest.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The JobManifest. + internal partial class JobManifest + { + /// Initializes a new instance of JobManifest. + /// The set of tasks to execute on the input documents. Cannot specify the same task more than once. + /// is null. + public JobManifest(JobManifestTasks tasks) + { + if (tasks == null) + { + throw new ArgumentNullException(nameof(tasks)); + } + + Tasks = tasks; + } + + /// The set of tasks to execute on the input documents. Cannot specify the same task more than once. + public JobManifestTasks Tasks { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifestTasks.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifestTasks.Serialization.cs new file mode 100644 index 000000000000..d5153fcd2ad5 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifestTasks.Serialization.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class JobManifestTasks : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(EntityRecognitionTasks)) + { + writer.WritePropertyName("entityRecognitionTasks"); + writer.WriteStartArray(); + foreach (var item in EntityRecognitionTasks) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(EntityRecognitionPiiTasks)) + { + writer.WritePropertyName("entityRecognitionPiiTasks"); + writer.WriteStartArray(); + foreach (var item in EntityRecognitionPiiTasks) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(EntityLinkingTasks)) + { + writer.WritePropertyName("entityLinkingTasks"); + writer.WriteStartArray(); + foreach (var item in EntityLinkingTasks) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(KeyPhraseExtractionTasks)) + { + writer.WritePropertyName("keyPhraseExtractionTasks"); + writer.WriteStartArray(); + foreach (var item in KeyPhraseExtractionTasks) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(SentimentAnalysisTasks)) + { + writer.WritePropertyName("sentimentAnalysisTasks"); + writer.WriteStartArray(); + foreach (var item in SentimentAnalysisTasks) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(CustomClassificationTasks)) + { + writer.WritePropertyName("customClassificationTasks"); + writer.WriteStartArray(); + foreach (var item in CustomClassificationTasks) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(CustomEntityRecognitionTasks)) + { + writer.WritePropertyName("customEntityRecognitionTasks"); + writer.WriteStartArray(); + foreach (var item in CustomEntityRecognitionTasks) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifestTasks.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifestTasks.cs new file mode 100644 index 000000000000..9882519bbb6f --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifestTasks.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The set of tasks to execute on the input documents. Cannot specify the same task more than once. + internal partial class JobManifestTasks + { + /// Initializes a new instance of JobManifestTasks. + public JobManifestTasks() + { + EntityRecognitionTasks = new ChangeTrackingList(); + EntityRecognitionPiiTasks = new ChangeTrackingList(); + EntityLinkingTasks = new ChangeTrackingList(); + KeyPhraseExtractionTasks = new ChangeTrackingList(); + SentimentAnalysisTasks = new ChangeTrackingList(); + CustomClassificationTasks = new ChangeTrackingList(); + CustomEntityRecognitionTasks = new ChangeTrackingList(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobMetadata.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobMetadata.Serialization.cs new file mode 100644 index 000000000000..7f9e33dc7ce7 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobMetadata.Serialization.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + public partial class JobMetadata + { + internal static JobMetadata DeserializeJobMetadata(JsonElement element) + { + DateTimeOffset createdDateTime = default; + Optional displayName = default; + Optional expirationDateTime = default; + Guid jobId = default; + DateTimeOffset lastUpdateDateTime = default; + State status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("createdDateTime")) + { + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("displayName")) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("expirationDateTime")) + { + expirationDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("jobId")) + { + jobId = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("lastUpdateDateTime")) + { + lastUpdateDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("status")) + { + status = new State(property.Value.GetString()); + continue; + } + } + return new JobMetadata(createdDateTime, displayName.Value, Optional.ToNullable(expirationDateTime), jobId, lastUpdateDateTime, status); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobMetadata.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobMetadata.cs new file mode 100644 index 000000000000..967b58dc5d9f --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobMetadata.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The JobMetadata. + public partial class JobMetadata + { + /// Initializes a new instance of JobMetadata. + /// . + /// . + /// . + /// . + internal JobMetadata(DateTimeOffset createdDateTime, Guid jobId, DateTimeOffset lastUpdateDateTime, State status) + { + CreatedDateTime = createdDateTime; + JobId = jobId; + LastUpdateDateTime = lastUpdateDateTime; + Status = status; + } + + /// Initializes a new instance of JobMetadata. + /// . + /// . + /// . + /// . + /// . + /// . + internal JobMetadata(DateTimeOffset createdDateTime, string displayName, DateTimeOffset? expirationDateTime, Guid jobId, DateTimeOffset lastUpdateDateTime, State status) + { + CreatedDateTime = createdDateTime; + DisplayName = displayName; + ExpirationDateTime = expirationDateTime; + JobId = jobId; + LastUpdateDateTime = lastUpdateDateTime; + Status = status; + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhraseExtractionTasksItemProperties.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhraseExtractionTasksItemProperties.Serialization.cs new file mode 100644 index 000000000000..40b165dc311d --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhraseExtractionTasksItemProperties.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class KeyPhraseExtractionTasksItemProperties + { + internal static KeyPhraseExtractionTasksItemProperties DeserializeKeyPhraseExtractionTasksItemProperties(JsonElement element) + { + Optional results = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results")) + { + results = KeyPhraseResult.DeserializeKeyPhraseResult(property.Value); + continue; + } + } + return new KeyPhraseExtractionTasksItemProperties(results.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhraseExtractionTasksItemProperties.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhraseExtractionTasksItemProperties.cs new file mode 100644 index 000000000000..5d50ea24378f --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhraseExtractionTasksItemProperties.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The Components1D9IzucSchemasTasksstatePropertiesTasksPropertiesKeyphraseextractiontasksItemsAllof1. + internal partial class KeyPhraseExtractionTasksItemProperties + { + /// Initializes a new instance of KeyPhraseExtractionTasksItemProperties. + internal KeyPhraseExtractionTasksItemProperties() + { + } + + /// Initializes a new instance of KeyPhraseExtractionTasksItemProperties. + /// . + internal KeyPhraseExtractionTasksItemProperties(KeyPhraseResult results) + { + Results = results; + } + + public KeyPhraseResult Results { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhrasesTask.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhrasesTask.Serialization.cs new file mode 100644 index 000000000000..e41375501d5a --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhrasesTask.Serialization.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class KeyPhrasesTask : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Parameters)) + { + writer.WritePropertyName("parameters"); + writer.WriteObjectValue(Parameters); + } + writer.WritePropertyName("enable"); + writer.WriteBooleanValue(Enable); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhrasesTask.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhrasesTask.cs new file mode 100644 index 000000000000..653079f2bfb8 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhrasesTask.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The KeyPhrasesTask. + internal partial class KeyPhrasesTask : TextAnalyticsTask + { + /// Initializes a new instance of KeyPhrasesTask. + /// . + public KeyPhrasesTask(bool enable) : base(enable) + { + } + + public KeyPhrasesTaskParameters Parameters { get; set; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhrasesTaskParameters.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhrasesTaskParameters.Serialization.cs new file mode 100644 index 000000000000..f3db68ef4e28 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhrasesTaskParameters.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class KeyPhrasesTaskParameters : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(ModelVersion)) + { + writer.WritePropertyName("model-version"); + writer.WriteStringValue(ModelVersion); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhrasesTaskParameters.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhrasesTaskParameters.cs new file mode 100644 index 000000000000..50893a1d5db1 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/KeyPhrasesTaskParameters.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The KeyPhrasesTaskParameters. + internal partial class KeyPhrasesTaskParameters + { + /// Initializes a new instance of KeyPhrasesTaskParameters. + public KeyPhrasesTaskParameters() + { + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/Pagination.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/Pagination.Serialization.cs new file mode 100644 index 000000000000..7a96213b14dc --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/Pagination.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class Pagination + { + internal static Pagination DeserializePagination(JsonElement element) + { + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("@nextLink")) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new Pagination(nextLink.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/Pagination.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/Pagination.cs new file mode 100644 index 000000000000..5c5d957a18d1 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/Pagination.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The Pagination. + internal partial class Pagination + { + /// Initializes a new instance of Pagination. + internal Pagination() + { + } + + /// Initializes a new instance of Pagination. + /// . + internal Pagination(string nextLink) + { + NextLink = nextLink; + } + + public string NextLink { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiDocumentEntities.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiDocumentEntities.Serialization.cs index bc835ba44dce..a18f4dcc405a 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiDocumentEntities.Serialization.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiDocumentEntities.Serialization.cs @@ -20,7 +20,7 @@ internal static PiiDocumentEntities DeserializePiiDocumentEntities(JsonElement e IReadOnlyList entities = default; IReadOnlyList warnings = default; Optional statistics = default; - Optional redactedText = default; + string redactedText = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) @@ -59,7 +59,7 @@ internal static PiiDocumentEntities DeserializePiiDocumentEntities(JsonElement e continue; } } - return new PiiDocumentEntities(id, entities, warnings, Optional.ToNullable(statistics), redactedText.Value); + return new PiiDocumentEntities(id, entities, warnings, Optional.ToNullable(statistics), redactedText); } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiDocumentEntities.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiDocumentEntities.cs index feab57ee4f2a..884aa5290459 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiDocumentEntities.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiDocumentEntities.cs @@ -19,8 +19,9 @@ internal partial class PiiDocumentEntities /// Unique, non-empty document identifier. /// Recognized entities in the document. /// Warnings encountered while processing document. - /// , , or is null. - internal PiiDocumentEntities(string id, IEnumerable entities, IEnumerable warnings) + /// . + /// , , , or is null. + internal PiiDocumentEntities(string id, IEnumerable entities, IEnumerable warnings, string redactedText) { if (id == null) { @@ -34,10 +35,15 @@ internal PiiDocumentEntities(string id, IEnumerable entities, IEnumerabl { throw new ArgumentNullException(nameof(warnings)); } + if (redactedText == null) + { + throw new ArgumentNullException(nameof(redactedText)); + } Id = id; Entities = entities.ToList(); Warnings = warnings.ToList(); + RedactedText = redactedText; } /// Initializes a new instance of PiiDocumentEntities. @@ -45,7 +51,7 @@ internal PiiDocumentEntities(string id, IEnumerable entities, IEnumerabl /// Recognized entities in the document. /// Warnings encountered while processing document. /// if showStats=true was specified in the request this field will contain information about the document payload. - /// Returns redacted text. + /// . internal PiiDocumentEntities(string id, IReadOnlyList entities, IReadOnlyList warnings, TextDocumentStatistics? statistics, string redactedText) { Id = id; @@ -63,7 +69,6 @@ internal PiiDocumentEntities(string id, IReadOnlyList entities, IReadOnl public IReadOnlyList Warnings { get; } /// if showStats=true was specified in the request this field will contain information about the document payload. public TextDocumentStatistics? Statistics { get; } - /// Returns redacted text. public string RedactedText { get; } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiEntitiesResult.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiResult.Serialization.cs similarity index 89% rename from sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiEntitiesResult.Serialization.cs rename to sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiResult.Serialization.cs index 193ea9ea46f9..6b4f0ff223a2 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiEntitiesResult.Serialization.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiResult.Serialization.cs @@ -12,9 +12,9 @@ namespace Azure.AI.TextAnalytics.Models { - internal partial class PiiEntitiesResult + internal partial class PiiResult { - internal static PiiEntitiesResult DeserializePiiEntitiesResult(JsonElement element) + internal static PiiResult DeserializePiiResult(JsonElement element) { IReadOnlyList documents = default; IReadOnlyList errors = default; @@ -53,7 +53,7 @@ internal static PiiEntitiesResult DeserializePiiEntitiesResult(JsonElement eleme continue; } } - return new PiiEntitiesResult(documents, errors, statistics.Value, modelVersion); + return new PiiResult(documents, errors, statistics.Value, modelVersion); } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiEntitiesResult.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiResult.cs similarity index 80% rename from sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiEntitiesResult.cs rename to sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiResult.cs index 429f27d2af6a..6b5cc53512d7 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiEntitiesResult.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiResult.cs @@ -12,15 +12,15 @@ namespace Azure.AI.TextAnalytics.Models { - /// The PiiEntitiesResult. - internal partial class PiiEntitiesResult + /// The PiiResult. + internal partial class PiiResult { - /// Initializes a new instance of PiiEntitiesResult. + /// Initializes a new instance of PiiResult. /// Response by document. /// Errors by document id. /// This field indicates which model is used for scoring. /// , , or is null. - internal PiiEntitiesResult(IEnumerable documents, IEnumerable errors, string modelVersion) + internal PiiResult(IEnumerable documents, IEnumerable errors, string modelVersion) { if (documents == null) { @@ -40,12 +40,12 @@ internal PiiEntitiesResult(IEnumerable documents, IEnumerab ModelVersion = modelVersion; } - /// Initializes a new instance of PiiEntitiesResult. + /// Initializes a new instance of PiiResult. /// Response by document. /// Errors by document id. /// if showStats=true was specified in the request this field will contain information about the request payload. /// This field indicates which model is used for scoring. - internal PiiEntitiesResult(IReadOnlyList documents, IReadOnlyList errors, TextDocumentBatchStatistics statistics, string modelVersion) + internal PiiResult(IReadOnlyList documents, IReadOnlyList errors, TextDocumentBatchStatistics statistics, string modelVersion) { Documents = documents; Errors = errors; diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTask.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTask.Serialization.cs new file mode 100644 index 000000000000..c3ad960d4975 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTask.Serialization.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class PiiTask : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Parameters)) + { + writer.WritePropertyName("parameters"); + writer.WriteObjectValue(Parameters); + } + writer.WritePropertyName("enable"); + writer.WriteBooleanValue(Enable); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTask.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTask.cs new file mode 100644 index 000000000000..a443b7b36893 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTask.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The PiiTask. + internal partial class PiiTask : TextAnalyticsTask + { + /// Initializes a new instance of PiiTask. + /// . + public PiiTask(bool enable) : base(enable) + { + } + + public PiiTaskParameters Parameters { get; set; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTaskParameters.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTaskParameters.Serialization.cs new file mode 100644 index 000000000000..7bb7a0844264 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTaskParameters.Serialization.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class PiiTaskParameters : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Domain)) + { + writer.WritePropertyName("domain"); + writer.WriteStringValue(Domain.Value.ToString()); + } + if (Optional.IsDefined(ModelVersion)) + { + writer.WritePropertyName("model-version"); + writer.WriteStringValue(ModelVersion); + } + if (Optional.IsDefined(StringIndexType)) + { + writer.WritePropertyName("stringIndexType"); + writer.WriteStringValue(StringIndexType.Value.ToString()); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTaskParameters.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTaskParameters.cs new file mode 100644 index 000000000000..d9c9fff124af --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTaskParameters.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The PiiTaskParameters. + internal partial class PiiTaskParameters + { + /// Initializes a new instance of PiiTaskParameters. + public PiiTaskParameters() + { + } + + public PiiTaskParametersDomain? Domain { get; set; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTaskParametersDomain.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTaskParametersDomain.cs new file mode 100644 index 000000000000..a25b74b0b2d4 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTaskParametersDomain.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The PiiTaskParametersDomain. + internal readonly partial struct PiiTaskParametersDomain : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public PiiTaskParametersDomain(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PhiValue = "phi"; + private const string NoneValue = "none"; + + /// phi. + public static PiiTaskParametersDomain Phi { get; } = new PiiTaskParametersDomain(PhiValue); + /// none. + public static PiiTaskParametersDomain None { get; } = new PiiTaskParametersDomain(NoneValue); + /// Determines if two values are the same. + public static bool operator ==(PiiTaskParametersDomain left, PiiTaskParametersDomain right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PiiTaskParametersDomain left, PiiTaskParametersDomain right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator PiiTaskParametersDomain(string value) => new PiiTaskParametersDomain(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PiiTaskParametersDomain other && Equals(other); + /// + public bool Equals(PiiTaskParametersDomain other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentAnalysisTasksItemProperties.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentAnalysisTasksItemProperties.Serialization.cs new file mode 100644 index 000000000000..134cb5d8994b --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentAnalysisTasksItemProperties.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class SentimentAnalysisTasksItemProperties + { + internal static SentimentAnalysisTasksItemProperties DeserializeSentimentAnalysisTasksItemProperties(JsonElement element) + { + Optional results = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results")) + { + results = SentimentResponse.DeserializeSentimentResponse(property.Value); + continue; + } + } + return new SentimentAnalysisTasksItemProperties(results.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentAnalysisTasksItemProperties.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentAnalysisTasksItemProperties.cs new file mode 100644 index 000000000000..82e1a1010ad4 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentAnalysisTasksItemProperties.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The Components1C6O47FSchemasTasksstatePropertiesTasksPropertiesSentimentanalysistasksItemsAllof1. + internal partial class SentimentAnalysisTasksItemProperties + { + /// Initializes a new instance of SentimentAnalysisTasksItemProperties. + internal SentimentAnalysisTasksItemProperties() + { + } + + /// Initializes a new instance of SentimentAnalysisTasksItemProperties. + /// . + internal SentimentAnalysisTasksItemProperties(SentimentResponse results) + { + Results = results; + } + + public SentimentResponse Results { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentTask.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentTask.Serialization.cs new file mode 100644 index 000000000000..35ac1f6cb952 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentTask.Serialization.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class SentimentTask : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Parameters)) + { + writer.WritePropertyName("parameters"); + writer.WriteObjectValue(Parameters); + } + writer.WritePropertyName("enable"); + writer.WriteBooleanValue(Enable); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentTask.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentTask.cs new file mode 100644 index 000000000000..f3890250ba29 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentTask.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The SentimentTask. + internal partial class SentimentTask : TextAnalyticsTask + { + /// Initializes a new instance of SentimentTask. + /// . + public SentimentTask(bool enable) : base(enable) + { + } + + public SentimentTaskParameters Parameters { get; set; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentTaskParameters.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentTaskParameters.Serialization.cs new file mode 100644 index 000000000000..e9377eb8b318 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentTaskParameters.Serialization.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class SentimentTaskParameters : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(ModelVersion)) + { + writer.WritePropertyName("model-version"); + writer.WriteStringValue(ModelVersion); + } + if (Optional.IsDefined(OpinionMining)) + { + writer.WritePropertyName("opinionMining"); + writer.WriteBooleanValue(OpinionMining.Value); + } + if (Optional.IsDefined(StringIndexType)) + { + writer.WritePropertyName("stringIndexType"); + writer.WriteStringValue(StringIndexType.Value.ToString()); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentTaskParameters.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentTaskParameters.cs new file mode 100644 index 000000000000..884cdbc989e1 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentTaskParameters.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The SentimentTaskParameters. + internal partial class SentimentTaskParameters + { + /// Initializes a new instance of SentimentTaskParameters. + public SentimentTaskParameters() + { + } + public bool? OpinionMining { get; set; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/State.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/State.cs new file mode 100644 index 000000000000..49895d2fdc9b --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/State.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The State. + internal readonly partial struct State : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public State(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NotstartedValue = "notstarted"; + private const string RunningValue = "running"; + private const string SucceededValue = "succeeded"; + private const string FailedValue = "failed"; + private const string CancelledValue = "cancelled"; + private const string CancellingValue = "cancelling"; + private const string PartiallycompletedValue = "partiallycompleted"; + + /// notstarted. + public static State Notstarted { get; } = new State(NotstartedValue); + /// running. + public static State Running { get; } = new State(RunningValue); + /// succeeded. + public static State Succeeded { get; } = new State(SucceededValue); + /// failed. + public static State Failed { get; } = new State(FailedValue); + /// cancelled. + public static State Cancelled { get; } = new State(CancelledValue); + /// cancelling. + public static State Cancelling { get; } = new State(CancellingValue); + /// partiallycompleted. + public static State Partiallycompleted { get; } = new State(PartiallycompletedValue); + /// Determines if two values are the same. + public static bool operator ==(State left, State right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(State left, State right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator State(string value) => new State(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is State other && Equals(other); + /// + public bool Equals(State other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TaskState.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TaskState.Serialization.cs new file mode 100644 index 000000000000..567fd173084e --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TaskState.Serialization.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class TaskState + { + internal static TaskState DeserializeTaskState(JsonElement element) + { + DateTimeOffset lastUpdateDateTime = default; + string name = default; + State status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("lastUpdateDateTime")) + { + lastUpdateDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("status")) + { + status = new State(property.Value.GetString()); + continue; + } + } + return new TaskState(lastUpdateDateTime, name, status); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TaskState.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TaskState.cs new file mode 100644 index 000000000000..cd82c187693f --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TaskState.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The TaskState. + internal partial class TaskState + { + /// Initializes a new instance of TaskState. + /// . + /// . + /// . + /// is null. + internal TaskState(DateTimeOffset lastUpdateDateTime, string name, State status) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + LastUpdateDateTime = lastUpdateDateTime; + Name = name; + Status = status; + } + + public DateTimeOffset LastUpdateDateTime { get; } + public string Name { get; } + public State Status { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksState.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksState.Serialization.cs new file mode 100644 index 000000000000..d88e67da906a --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksState.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class TasksState + { + internal static TasksState DeserializeTasksState(JsonElement element) + { + TasksStateTasks tasks = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tasks")) + { + tasks = TasksStateTasks.DeserializeTasksStateTasks(property.Value); + continue; + } + } + return new TasksState(tasks); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksState.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksState.cs new file mode 100644 index 000000000000..e68988156ce5 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksState.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The TasksState. + internal partial class TasksState + { + /// Initializes a new instance of TasksState. + /// . + /// is null. + internal TasksState(TasksStateTasks tasks) + { + if (tasks == null) + { + throw new ArgumentNullException(nameof(tasks)); + } + + Tasks = tasks; + } + + public TasksStateTasks Tasks { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasks.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasks.Serialization.cs new file mode 100644 index 000000000000..4fce5400939e --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasks.Serialization.cs @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class TasksStateTasks + { + internal static TasksStateTasks DeserializeTasksStateTasks(JsonElement element) + { + Optional> details = default; + int completed = default; + int failed = default; + int inProgress = default; + int total = default; + Optional> entityRecognitionTasks = default; + Optional> entityRecognitionPiiTasks = default; + Optional> entityLinkingTasks = default; + Optional> keyPhraseExtractionTasks = default; + Optional> sentimentAnalysisTasks = default; + Optional> customClassificationTasks = default; + Optional> customEntityRecognitionTasks = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("details")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TaskState.DeserializeTaskState(item)); + } + details = array; + continue; + } + if (property.NameEquals("completed")) + { + completed = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("failed")) + { + failed = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("inProgress")) + { + inProgress = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("total")) + { + total = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("entityRecognitionTasks")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TasksStateTasksEntityRecognitionTasksItem.DeserializeTasksStateTasksEntityRecognitionTasksItem(item)); + } + entityRecognitionTasks = array; + continue; + } + if (property.NameEquals("entityRecognitionPiiTasks")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TasksStateTasksEntityRecognitionPiiTasksItem.DeserializeTasksStateTasksEntityRecognitionPiiTasksItem(item)); + } + entityRecognitionPiiTasks = array; + continue; + } + if (property.NameEquals("entityLinkingTasks")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(EntityLinkingTasksItem.DeserializeEntityLinkingTasksItem(item)); + } + entityLinkingTasks = array; + continue; + } + if (property.NameEquals("keyPhraseExtractionTasks")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TasksStateTasksKeyPhraseExtractionTasksItem.DeserializeTasksStateTasksKeyPhraseExtractionTasksItem(item)); + } + keyPhraseExtractionTasks = array; + continue; + } + if (property.NameEquals("sentimentAnalysisTasks")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TasksStateTasksSentimentAnalysisTasksItem.DeserializeTasksStateTasksSentimentAnalysisTasksItem(item)); + } + sentimentAnalysisTasks = array; + continue; + } + if (property.NameEquals("customClassificationTasks")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CustomClassificationTasksItem.DeserializeCustomClassificationTasksItem(item)); + } + customClassificationTasks = array; + continue; + } + if (property.NameEquals("customEntityRecognitionTasks")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CustomEntityRecognitionTasksItem.DeserializeCustomEntityRecognitionTasksItem(item)); + } + customEntityRecognitionTasks = array; + continue; + } + } + return new TasksStateTasks(Optional.ToList(details), completed, failed, inProgress, total, Optional.ToList(entityRecognitionTasks), Optional.ToList(entityRecognitionPiiTasks), Optional.ToList(entityLinkingTasks), Optional.ToList(keyPhraseExtractionTasks), Optional.ToList(sentimentAnalysisTasks), Optional.ToList(customClassificationTasks), Optional.ToList(customEntityRecognitionTasks)); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasks.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasks.cs new file mode 100644 index 000000000000..b99404bc6408 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasks.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The TasksStateTasks. + internal partial class TasksStateTasks + { + /// Initializes a new instance of TasksStateTasks. + /// . + /// . + /// . + /// . + internal TasksStateTasks(int completed, int failed, int inProgress, int total) + { + Details = new ChangeTrackingList(); + Completed = completed; + Failed = failed; + InProgress = inProgress; + Total = total; + EntityRecognitionTasks = new ChangeTrackingList(); + EntityRecognitionPiiTasks = new ChangeTrackingList(); + EntityLinkingTasks = new ChangeTrackingList(); + KeyPhraseExtractionTasks = new ChangeTrackingList(); + SentimentAnalysisTasks = new ChangeTrackingList(); + CustomClassificationTasks = new ChangeTrackingList(); + CustomEntityRecognitionTasks = new ChangeTrackingList(); + } + + /// Initializes a new instance of TasksStateTasks. + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + internal TasksStateTasks(IReadOnlyList details, int completed, int failed, int inProgress, int total, IReadOnlyList entityRecognitionTasks, IReadOnlyList entityRecognitionPiiTasks, IReadOnlyList entityLinkingTasks, IReadOnlyList keyPhraseExtractionTasks, IReadOnlyList sentimentAnalysisTasks, IReadOnlyList customClassificationTasks, IReadOnlyList customEntityRecognitionTasks) + { + Details = details; + Completed = completed; + Failed = failed; + InProgress = inProgress; + Total = total; + EntityRecognitionTasks = entityRecognitionTasks; + EntityRecognitionPiiTasks = entityRecognitionPiiTasks; + EntityLinkingTasks = entityLinkingTasks; + KeyPhraseExtractionTasks = keyPhraseExtractionTasks; + SentimentAnalysisTasks = sentimentAnalysisTasks; + CustomClassificationTasks = customClassificationTasks; + CustomEntityRecognitionTasks = customEntityRecognitionTasks; + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksEntityRecognitionPiiTasksItem.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksEntityRecognitionPiiTasksItem.Serialization.cs new file mode 100644 index 000000000000..89b253df0c79 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksEntityRecognitionPiiTasksItem.Serialization.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class TasksStateTasksEntityRecognitionPiiTasksItem + { + internal static TasksStateTasksEntityRecognitionPiiTasksItem DeserializeTasksStateTasksEntityRecognitionPiiTasksItem(JsonElement element) + { + Optional results = default; + DateTimeOffset lastUpdateDateTime = default; + string name = default; + State status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results")) + { + results = PiiResult.DeserializePiiResult(property.Value); + continue; + } + if (property.NameEquals("lastUpdateDateTime")) + { + lastUpdateDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("status")) + { + status = new State(property.Value.GetString()); + continue; + } + } + return new TasksStateTasksEntityRecognitionPiiTasksItem(lastUpdateDateTime, name, status, results.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksEntityRecognitionPiiTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksEntityRecognitionPiiTasksItem.cs new file mode 100644 index 000000000000..eeb6e2123468 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksEntityRecognitionPiiTasksItem.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The TasksStateTasksEntityRecognitionPiiTasksItem. + internal partial class TasksStateTasksEntityRecognitionPiiTasksItem : TaskState + { + /// Initializes a new instance of TasksStateTasksEntityRecognitionPiiTasksItem. + /// . + /// . + /// . + /// is null. + internal TasksStateTasksEntityRecognitionPiiTasksItem(DateTimeOffset lastUpdateDateTime, string name, State status) : base(lastUpdateDateTime, name, status) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + } + + /// Initializes a new instance of TasksStateTasksEntityRecognitionPiiTasksItem. + /// . + /// . + /// . + /// . + /// is null. + internal TasksStateTasksEntityRecognitionPiiTasksItem(DateTimeOffset lastUpdateDateTime, string name, State status, PiiResult results) : base(lastUpdateDateTime, name, status) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + Results = results; + } + + public PiiResult Results { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksEntityRecognitionTasksItem.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksEntityRecognitionTasksItem.Serialization.cs new file mode 100644 index 000000000000..b012ec43b97b --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksEntityRecognitionTasksItem.Serialization.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class TasksStateTasksEntityRecognitionTasksItem + { + internal static TasksStateTasksEntityRecognitionTasksItem DeserializeTasksStateTasksEntityRecognitionTasksItem(JsonElement element) + { + Optional results = default; + DateTimeOffset lastUpdateDateTime = default; + string name = default; + State status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results")) + { + results = EntitiesResult.DeserializeEntitiesResult(property.Value); + continue; + } + if (property.NameEquals("lastUpdateDateTime")) + { + lastUpdateDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("status")) + { + status = new State(property.Value.GetString()); + continue; + } + } + return new TasksStateTasksEntityRecognitionTasksItem(lastUpdateDateTime, name, status, results.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksEntityRecognitionTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksEntityRecognitionTasksItem.cs new file mode 100644 index 000000000000..7c6795cecc31 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksEntityRecognitionTasksItem.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The TasksStateTasksEntityRecognitionTasksItem. + internal partial class TasksStateTasksEntityRecognitionTasksItem : TaskState + { + /// Initializes a new instance of TasksStateTasksEntityRecognitionTasksItem. + /// . + /// . + /// . + /// is null. + internal TasksStateTasksEntityRecognitionTasksItem(DateTimeOffset lastUpdateDateTime, string name, State status) : base(lastUpdateDateTime, name, status) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + } + + /// Initializes a new instance of TasksStateTasksEntityRecognitionTasksItem. + /// . + /// . + /// . + /// . + /// is null. + internal TasksStateTasksEntityRecognitionTasksItem(DateTimeOffset lastUpdateDateTime, string name, State status, EntitiesResult results) : base(lastUpdateDateTime, name, status) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + Results = results; + } + + public EntitiesResult Results { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksKeyPhraseExtractionTasksItem.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksKeyPhraseExtractionTasksItem.Serialization.cs new file mode 100644 index 000000000000..1e44d77ea0cf --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksKeyPhraseExtractionTasksItem.Serialization.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class TasksStateTasksKeyPhraseExtractionTasksItem + { + internal static TasksStateTasksKeyPhraseExtractionTasksItem DeserializeTasksStateTasksKeyPhraseExtractionTasksItem(JsonElement element) + { + Optional results = default; + DateTimeOffset lastUpdateDateTime = default; + string name = default; + State status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results")) + { + results = KeyPhraseResult.DeserializeKeyPhraseResult(property.Value); + continue; + } + if (property.NameEquals("lastUpdateDateTime")) + { + lastUpdateDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("status")) + { + status = new State(property.Value.GetString()); + continue; + } + } + return new TasksStateTasksKeyPhraseExtractionTasksItem(lastUpdateDateTime, name, status, results.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksKeyPhraseExtractionTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksKeyPhraseExtractionTasksItem.cs new file mode 100644 index 000000000000..430b199843e0 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksKeyPhraseExtractionTasksItem.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The TasksStateTasksKeyPhraseExtractionTasksItem. + internal partial class TasksStateTasksKeyPhraseExtractionTasksItem : TaskState + { + /// Initializes a new instance of TasksStateTasksKeyPhraseExtractionTasksItem. + /// . + /// . + /// . + /// is null. + internal TasksStateTasksKeyPhraseExtractionTasksItem(DateTimeOffset lastUpdateDateTime, string name, State status) : base(lastUpdateDateTime, name, status) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + } + + /// Initializes a new instance of TasksStateTasksKeyPhraseExtractionTasksItem. + /// . + /// . + /// . + /// . + /// is null. + internal TasksStateTasksKeyPhraseExtractionTasksItem(DateTimeOffset lastUpdateDateTime, string name, State status, KeyPhraseResult results) : base(lastUpdateDateTime, name, status) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + Results = results; + } + + public KeyPhraseResult Results { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksSentimentAnalysisTasksItem.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksSentimentAnalysisTasksItem.Serialization.cs new file mode 100644 index 000000000000..2020472b1034 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksSentimentAnalysisTasksItem.Serialization.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class TasksStateTasksSentimentAnalysisTasksItem + { + internal static TasksStateTasksSentimentAnalysisTasksItem DeserializeTasksStateTasksSentimentAnalysisTasksItem(JsonElement element) + { + Optional results = default; + DateTimeOffset lastUpdateDateTime = default; + string name = default; + State status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results")) + { + results = SentimentResponse.DeserializeSentimentResponse(property.Value); + continue; + } + if (property.NameEquals("lastUpdateDateTime")) + { + lastUpdateDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("status")) + { + status = new State(property.Value.GetString()); + continue; + } + } + return new TasksStateTasksSentimentAnalysisTasksItem(lastUpdateDateTime, name, status, results.Value); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksSentimentAnalysisTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksSentimentAnalysisTasksItem.cs new file mode 100644 index 000000000000..0cb9e7454fb9 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksSentimentAnalysisTasksItem.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics.Models +{ + /// The TasksStateTasksSentimentAnalysisTasksItem. + internal partial class TasksStateTasksSentimentAnalysisTasksItem : TaskState + { + /// Initializes a new instance of TasksStateTasksSentimentAnalysisTasksItem. + /// . + /// . + /// . + /// is null. + internal TasksStateTasksSentimentAnalysisTasksItem(DateTimeOffset lastUpdateDateTime, string name, State status) : base(lastUpdateDateTime, name, status) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + } + + /// Initializes a new instance of TasksStateTasksSentimentAnalysisTasksItem. + /// . + /// . + /// . + /// . + /// is null. + internal TasksStateTasksSentimentAnalysisTasksItem(DateTimeOffset lastUpdateDateTime, string name, State status, SentimentResponse results) : base(lastUpdateDateTime, name, status) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + Results = results; + } + + public SentimentResponse Results { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TextAnalyticsTask.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TextAnalyticsTask.Serialization.cs new file mode 100644 index 000000000000..7ef9df285e8a --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TextAnalyticsTask.Serialization.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + internal partial class TextAnalyticsTask : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("enable"); + writer.WriteBooleanValue(Enable); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TextAnalyticsTask.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TextAnalyticsTask.cs new file mode 100644 index 000000000000..f8db4ddd524d --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TextAnalyticsTask.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.TextAnalytics.Models +{ + /// The TextAnalyticsTask. + internal partial class TextAnalyticsTask + { + /// Initializes a new instance of TextAnalyticsTask. + /// . + public TextAnalyticsTask(bool enable) + { + Enable = enable; + } + + public bool Enable { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/ServiceAnalyzeHeaders.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/ServiceAnalyzeHeaders.cs new file mode 100644 index 000000000000..96ab042fb8d7 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/ServiceAnalyzeHeaders.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure; +using Azure.Core; + +namespace Azure.AI.TextAnalytics +{ + internal class ServiceAnalyzeHeaders + { + private readonly Response _response; + public ServiceAnalyzeHeaders(Response response) + { + _response = response; + } + public string OperationLocation => _response.Headers.TryGetValue("Operation-Location", out string value) ? value : null; + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/ServiceCancelHealthJobHeaders.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/ServiceCancelHealthJobHeaders.cs new file mode 100644 index 000000000000..69e03bbce350 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/ServiceCancelHealthJobHeaders.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure; +using Azure.Core; + +namespace Azure.AI.TextAnalytics +{ + internal class ServiceCancelHealthJobHeaders + { + private readonly Response _response; + public ServiceCancelHealthJobHeaders(Response response) + { + _response = response; + } + public string OperationLocation => _response.Headers.TryGetValue("Operation-Location", out string value) ? value : null; + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/ServiceHealthHeaders.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/ServiceHealthHeaders.cs new file mode 100644 index 000000000000..81d78fbd4d6c --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/ServiceHealthHeaders.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure; +using Azure.Core; + +namespace Azure.AI.TextAnalytics +{ + internal class ServiceHealthHeaders + { + private readonly Response _response; + public ServiceHealthHeaders(Response response) + { + _response = response; + } + public string OperationLocation => _response.Headers.TryGetValue("Operation-Location", out string value) ? value : null; + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/ServiceRestClient.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/ServiceRestClient.cs index 6d8c71a123ef..678e5126a21f 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/ServiceRestClient.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/ServiceRestClient.cs @@ -39,6 +39,336 @@ public ServiceRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipel _pipeline = pipeline; } + internal HttpMessage CreateAnalyzeRequest(AnalyzeBatchInput body) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw(endpoint, false); + uri.AppendRaw("/text/analytics/v3.2-preview.1", false); + uri.AppendPath("/analyze", false); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + request.Headers.Add("Accept", "application/json, text/json"); + if (body != null) + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(body); + request.Content = content; + } + return message; + } + + /// Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed. + /// Collection of documents to analyze and tasks to execute. + /// The cancellation token to use. + public async Task> AnalyzeAsync(AnalyzeBatchInput body = null, CancellationToken cancellationToken = default) + { + using var message = CreateAnalyzeRequest(body); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + var headers = new ServiceAnalyzeHeaders(message.Response); + switch (message.Response.Status) + { + case 202: + return ResponseWithHeaders.FromValue(headers, message.Response); + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed. + /// Collection of documents to analyze and tasks to execute. + /// The cancellation token to use. + public ResponseWithHeaders Analyze(AnalyzeBatchInput body = null, CancellationToken cancellationToken = default) + { + using var message = CreateAnalyzeRequest(body); + _pipeline.Send(message, cancellationToken); + var headers = new ServiceAnalyzeHeaders(message.Response); + switch (message.Response.Status) + { + case 202: + return ResponseWithHeaders.FromValue(headers, message.Response); + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateAnalyzeStatusRequest(Guid jobId, bool? showStats, int? top, int? skip) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw(endpoint, false); + uri.AppendRaw("/text/analytics/v3.2-preview.1", false); + uri.AppendPath("/analyze/jobs/", false); + uri.AppendPath(jobId, true); + if (showStats != null) + { + uri.AppendQuery("showStats", showStats.Value, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skip != null) + { + uri.AppendQuery("$skip", skip.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json, text/json"); + return message; + } + + /// Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are completed, the job will transition to the completed state and results will be available for each task. + /// Job ID. + /// (Optional) if set to true, response will contain request and document level statistics. + /// (Optional) Set the maximum number of results per task. When both $top and $skip are specified, $skip is applied first. + /// (Optional) Set the number of elements to offset in the response. When both $top and $skip are specified, $skip is applied first. + /// The cancellation token to use. + public async Task> AnalyzeStatusAsync(Guid jobId, bool? showStats = null, int? top = null, int? skip = null, CancellationToken cancellationToken = default) + { + using var message = CreateAnalyzeStatusRequest(jobId, showStats, top, skip); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + AnalyzeJobState value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AnalyzeJobState.DeserializeAnalyzeJobState(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are completed, the job will transition to the completed state and results will be available for each task. + /// Job ID. + /// (Optional) if set to true, response will contain request and document level statistics. + /// (Optional) Set the maximum number of results per task. When both $top and $skip are specified, $skip is applied first. + /// (Optional) Set the number of elements to offset in the response. When both $top and $skip are specified, $skip is applied first. + /// The cancellation token to use. + public Response AnalyzeStatus(Guid jobId, bool? showStats = null, int? top = null, int? skip = null, CancellationToken cancellationToken = default) + { + using var message = CreateAnalyzeStatusRequest(jobId, showStats, top, skip); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + AnalyzeJobState value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AnalyzeJobState.DeserializeAnalyzeJobState(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateHealthStatusRequest(Guid jobId, int? top, int? skip, bool? showStats) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw(endpoint, false); + uri.AppendRaw("/text/analytics/v3.2-preview.1", false); + uri.AppendPath("/entities/health/jobs/", false); + uri.AppendPath(jobId, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skip != null) + { + uri.AppendQuery("$skip", skip.Value, true); + } + if (showStats != null) + { + uri.AppendQuery("showStats", showStats.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json, text/json"); + return message; + } + + /// Get details of the healthcare prediction job specified by the jobId. + /// Job ID. + /// (Optional) Set the maximum number of results per task. When both $top and $skip are specified, $skip is applied first. + /// (Optional) Set the number of elements to offset in the response. When both $top and $skip are specified, $skip is applied first. + /// (Optional) if set to true, response will contain request and document level statistics. + /// The cancellation token to use. + public async Task> HealthStatusAsync(Guid jobId, int? top = null, int? skip = null, bool? showStats = null, CancellationToken cancellationToken = default) + { + using var message = CreateHealthStatusRequest(jobId, top, skip, showStats); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + HealthcareJobState value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = HealthcareJobState.DeserializeHealthcareJobState(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get details of the healthcare prediction job specified by the jobId. + /// Job ID. + /// (Optional) Set the maximum number of results per task. When both $top and $skip are specified, $skip is applied first. + /// (Optional) Set the number of elements to offset in the response. When both $top and $skip are specified, $skip is applied first. + /// (Optional) if set to true, response will contain request and document level statistics. + /// The cancellation token to use. + public Response HealthStatus(Guid jobId, int? top = null, int? skip = null, bool? showStats = null, CancellationToken cancellationToken = default) + { + using var message = CreateHealthStatusRequest(jobId, top, skip, showStats); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + HealthcareJobState value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = HealthcareJobState.DeserializeHealthcareJobState(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCancelHealthJobRequest(Guid jobId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw(endpoint, false); + uri.AppendRaw("/text/analytics/v3.2-preview.1", false); + uri.AppendPath("/entities/health/jobs/", false); + uri.AppendPath(jobId, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json, text/json"); + return message; + } + + /// Cancel healthcare prediction job. + /// Job ID. + /// The cancellation token to use. + public async Task> CancelHealthJobAsync(Guid jobId, CancellationToken cancellationToken = default) + { + using var message = CreateCancelHealthJobRequest(jobId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + var headers = new ServiceCancelHealthJobHeaders(message.Response); + switch (message.Response.Status) + { + case 204: + return ResponseWithHeaders.FromValue(headers, message.Response); + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Cancel healthcare prediction job. + /// Job ID. + /// The cancellation token to use. + public ResponseWithHeaders CancelHealthJob(Guid jobId, CancellationToken cancellationToken = default) + { + using var message = CreateCancelHealthJobRequest(jobId); + _pipeline.Send(message, cancellationToken); + var headers = new ServiceCancelHealthJobHeaders(message.Response); + switch (message.Response.Status) + { + case 204: + return ResponseWithHeaders.FromValue(headers, message.Response); + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateHealthRequest(MultiLanguageBatchInput input, string modelVersion, StringIndexType? stringIndexType) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw(endpoint, false); + uri.AppendRaw("/text/analytics/v3.2-preview.1", false); + uri.AppendPath("/entities/health/jobs", false); + if (modelVersion != null) + { + uri.AppendQuery("model-version", modelVersion, true); + } + if (stringIndexType != null) + { + uri.AppendQuery("stringIndexType", stringIndexType.Value.ToString(), true); + } + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + request.Headers.Add("Accept", "application/json, text/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(input); + request.Content = content; + return message; + } + + /// Start a healthcare analysis job to recognize healthcare related entities (drugs, conditions, symptoms, etc) and their relations. + /// Collection of documents to analyze. + /// (Optional) This value indicates which model will be used for scoring. If a model-version is not specified, the API should default to the latest, non-preview version. + /// (Optional) Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. + /// The cancellation token to use. + /// is null. + public async Task> HealthAsync(MultiLanguageBatchInput input, string modelVersion = null, StringIndexType? stringIndexType = null, CancellationToken cancellationToken = default) + { + if (input == null) + { + throw new ArgumentNullException(nameof(input)); + } + + using var message = CreateHealthRequest(input, modelVersion, stringIndexType); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + var headers = new ServiceHealthHeaders(message.Response); + switch (message.Response.Status) + { + case 202: + return ResponseWithHeaders.FromValue(headers, message.Response); + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Start a healthcare analysis job to recognize healthcare related entities (drugs, conditions, symptoms, etc) and their relations. + /// Collection of documents to analyze. + /// (Optional) This value indicates which model will be used for scoring. If a model-version is not specified, the API should default to the latest, non-preview version. + /// (Optional) Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. + /// The cancellation token to use. + /// is null. + public ResponseWithHeaders Health(MultiLanguageBatchInput input, string modelVersion = null, StringIndexType? stringIndexType = null, CancellationToken cancellationToken = default) + { + if (input == null) + { + throw new ArgumentNullException(nameof(input)); + } + + using var message = CreateHealthRequest(input, modelVersion, stringIndexType); + _pipeline.Send(message, cancellationToken); + var headers = new ServiceHealthHeaders(message.Response); + switch (message.Response.Status) + { + case 202: + return ResponseWithHeaders.FromValue(headers, message.Response); + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + internal HttpMessage CreateEntitiesRecognitionGeneralRequest(MultiLanguageBatchInput input, string modelVersion, bool? showStats, StringIndexType? stringIndexType) { var message = _pipeline.CreateMessage(); @@ -46,7 +376,7 @@ internal HttpMessage CreateEntitiesRecognitionGeneralRequest(MultiLanguageBatchI request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendRaw("/text/analytics/v3.1-preview.2", false); + uri.AppendRaw("/text/analytics/v3.2-preview.1", false); uri.AppendPath("/entities/recognition/general", false); if (modelVersion != null) { @@ -136,7 +466,7 @@ internal HttpMessage CreateEntitiesRecognitionPiiRequest(MultiLanguageBatchInput request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendRaw("/text/analytics/v3.1-preview.2", false); + uri.AppendRaw("/text/analytics/v3.2-preview.1", false); uri.AppendPath("/entities/recognition/pii", false); if (modelVersion != null) { @@ -170,11 +500,11 @@ internal HttpMessage CreateEntitiesRecognitionPiiRequest(MultiLanguageBatchInput /// Collection of documents to analyze. /// (Optional) This value indicates which model will be used for scoring. If a model-version is not specified, the API should default to the latest, non-preview version. /// (Optional) if set to true, response will contain request and document level statistics. - /// (Optional) if set to 'PHI', response will contain only PHI entities. + /// (Optional) if specified, will set the PII domain to include only a subset of the entity categories. Possible values include: 'PHI', 'none'. /// (Optional) Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. /// The cancellation token to use. /// is null. - public async Task> EntitiesRecognitionPiiAsync(MultiLanguageBatchInput input, string modelVersion = null, bool? showStats = null, string domain = null, StringIndexType? stringIndexType = null, CancellationToken cancellationToken = default) + public async Task> EntitiesRecognitionPiiAsync(MultiLanguageBatchInput input, string modelVersion = null, bool? showStats = null, string domain = null, StringIndexType? stringIndexType = null, CancellationToken cancellationToken = default) { if (input == null) { @@ -187,9 +517,9 @@ public async Task> EntitiesRecognitionPiiAsync(Multi { case 200: { - PiiEntitiesResult value = default; + PiiResult value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PiiEntitiesResult.DeserializePiiEntitiesResult(document.RootElement); + value = PiiResult.DeserializePiiResult(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -204,11 +534,11 @@ public async Task> EntitiesRecognitionPiiAsync(Multi /// Collection of documents to analyze. /// (Optional) This value indicates which model will be used for scoring. If a model-version is not specified, the API should default to the latest, non-preview version. /// (Optional) if set to true, response will contain request and document level statistics. - /// (Optional) if set to 'PHI', response will contain only PHI entities. + /// (Optional) if specified, will set the PII domain to include only a subset of the entity categories. Possible values include: 'PHI', 'none'. /// (Optional) Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. /// The cancellation token to use. /// is null. - public Response EntitiesRecognitionPii(MultiLanguageBatchInput input, string modelVersion = null, bool? showStats = null, string domain = null, StringIndexType? stringIndexType = null, CancellationToken cancellationToken = default) + public Response EntitiesRecognitionPii(MultiLanguageBatchInput input, string modelVersion = null, bool? showStats = null, string domain = null, StringIndexType? stringIndexType = null, CancellationToken cancellationToken = default) { if (input == null) { @@ -221,9 +551,9 @@ public Response EntitiesRecognitionPii(MultiLanguageBatchInpu { case 200: { - PiiEntitiesResult value = default; + PiiResult value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PiiEntitiesResult.DeserializePiiEntitiesResult(document.RootElement); + value = PiiResult.DeserializePiiResult(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -238,7 +568,7 @@ internal HttpMessage CreateEntitiesLinkingRequest(MultiLanguageBatchInput input, request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendRaw("/text/analytics/v3.1-preview.2", false); + uri.AppendRaw("/text/analytics/v3.2-preview.1", false); uri.AppendPath("/entities/linking", false); if (modelVersion != null) { @@ -328,7 +658,7 @@ internal HttpMessage CreateKeyPhrasesRequest(MultiLanguageBatchInput input, stri request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendRaw("/text/analytics/v3.1-preview.2", false); + uri.AppendRaw("/text/analytics/v3.2-preview.1", false); uri.AppendPath("/keyPhrases", false); if (modelVersion != null) { @@ -412,7 +742,7 @@ internal HttpMessage CreateLanguagesRequest(LanguageBatchInput input, string mod request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendRaw("/text/analytics/v3.1-preview.2", false); + uri.AppendRaw("/text/analytics/v3.2-preview.1", false); uri.AppendPath("/languages", false); if (modelVersion != null) { @@ -496,7 +826,7 @@ internal HttpMessage CreateSentimentRequest(MultiLanguageBatchInput input, strin request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendRaw("/text/analytics/v3.1-preview.2", false); + uri.AppendRaw("/text/analytics/v3.2-preview.1", false); uri.AppendPath("/sentiment", false); if (modelVersion != null) { diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntity.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntity.cs new file mode 100644 index 000000000000..b44370c17c37 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntity.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("HealthcareEntity")] + internal partial class HealthcareEntity : Entity + { + [CodeGenMember("IsNegated")] + internal bool IsNegated { get; } + + [CodeGenMember("Links")] + internal IReadOnlyList Links { get; } + + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareRelation.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareRelation.cs new file mode 100644 index 000000000000..a8635c4a2d70 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareRelation.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text.RegularExpressions; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("HealthcareRelation")] + internal partial class HealthcareRelation + { + /// Initializes a new instance of HealthcareRelation. + /// + /// Type of relation. Examples include: `DosageOfMedication` or 'FrequencyOfMedication', etc. + /// If true the relation between the entities is bidirectional, otherwise directionality is source to target. + /// Reference link to the source entity. + /// Reference link to the target entity. + /// , , or is null. + internal HealthcareRelation(IEnumerable entities, string relationType, bool bidirectional, string source, string target) + { + if (relationType == null) + { + throw new ArgumentNullException(nameof(relationType)); + } + if (source == null) + { + throw new ArgumentNullException(nameof(source)); + } + if (target == null) + { + throw new ArgumentNullException(nameof(target)); + } + + RelationType = relationType; + Bidirectional = bidirectional; + Source = source; + Target = target; + SourceEntity = ResolveHealthcareEntity(entities, source); + TargetEntity = ResolveHealthcareEntity(entities, target); + } + + private static Regex _healthcareEntityRegex = new Regex(@"\#/results/documents\/(?\d*)\/entities\/(?\d*)$", RegexOptions.Compiled, TimeSpan.FromSeconds(2)); + + internal static HealthcareEntity ResolveHealthcareEntity(IEnumerable entities, string reference) + { + var healthcareEntityMatch = _healthcareEntityRegex.Match(reference); + if (healthcareEntityMatch.Success) + { + int entityIndex = int.Parse(healthcareEntityMatch.Groups["entityIndex"].Value, CultureInfo.InvariantCulture); + //int entityIndex = int.Parse(healthcareEntityMatch.Groups[2].Value, CultureInfo.InvariantCulture); + + if (entityIndex < entities.Count()) + { + var entity = entities.ElementAt(entityIndex); + return new HealthcareEntity(entity.Text, entity.Category, + entity.Offset, entity.Length, entity.ConfidenceScore, + entity.IsNegated); + } + } + + throw new InvalidOperationException($"Failed to parse element reference: {reference}"); + } + + [CodeGenMember("Source")] + public string Source { get; } + [CodeGenMember("Target")] + public string Target { get; } + + public HealthcareEntity SourceEntity { get; } + + public HealthcareEntity TargetEntity { get; } + + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareResult.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareResult.cs new file mode 100644 index 000000000000..f5e631ec55e8 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareResult.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("HealthcareResult")] + public partial class HealthcareResult + { + [CodeGenMember("Documents")] + internal IReadOnlyList Documents { get; } + + [CodeGenMember("Errors")] + internal IReadOnlyList Errors { get; } + + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/JobManifestTasks.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/JobManifestTasks.cs new file mode 100644 index 000000000000..9ea2a3c2b30a --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/JobManifestTasks.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("JobManifestTasks")] + internal partial class JobManifestTasks + { + internal IList EntityRecognitionTasks { get; } + internal IList EntityRecognitionPiiTasks { get; } + internal IList EntityLinkingTasks { get; } + internal IList KeyPhraseExtractionTasks { get; } + internal IList SentimentAnalysisTasks { get; } + internal IList CustomClassificationTasks { get; } + internal IList CustomEntityRecognitionTasks { get; } + + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/JobMetaData.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/JobMetaData.cs new file mode 100644 index 000000000000..85ef0872f444 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/JobMetaData.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("JobMetadata")] + public partial class JobMetadata + { + [CodeGenMember("Documents")] + internal DateTimeOffset CreatedDateTime { get; } + + [CodeGenMember("Documents")] + internal string DisplayName { get; } + + [CodeGenMember("Documents")] + internal DateTimeOffset? ExpirationDateTime { get; } + + [CodeGenMember("Documents")] + internal Guid JobId { get; } + + [CodeGenMember("Documents")] + internal DateTimeOffset LastUpdateDateTime { get; } + + [CodeGenMember("Documents")] + internal State Status { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/KeyPhraseExtractionTasksItemProperties.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/KeyPhraseExtractionTasksItemProperties.cs new file mode 100644 index 000000000000..c055fda24809 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/KeyPhraseExtractionTasksItemProperties.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("Components1D9IzucSchemasTasksstatePropertiesTasksPropertiesKeyphraseextractiontasksItemsAllof1")] + internal partial class KeyPhraseExtractionTasksItemProperties + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/KeyPhraseTaskParameters.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/KeyPhraseTaskParameters.cs new file mode 100644 index 000000000000..897e183f989a --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/KeyPhraseTaskParameters.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("KeyPhrasesTaskParameters")] + internal partial class KeyPhrasesTaskParameters + { + /// AppId. + internal string ModelVersion { get; set; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/OperationHelpers.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/OperationHelpers.cs new file mode 100644 index 000000000000..40636c644ce9 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/OperationHelpers.cs @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading; +using System.Threading.Tasks; + +#nullable enable + +namespace Azure.Core +{ + internal static class OperationHelpers + { + public static TimeSpan DefaultPollingInterval { get; } = TimeSpan.FromSeconds(1); + + public static T GetValue(ref T? value) where T : class + { + if (value is null) + { + throw new InvalidOperationException("The operation has not completed yet."); + } + + return value; + } + + public static T GetValue(ref T? value) where T : struct + { + if (value == null) + { + throw new InvalidOperationException("The operation has not completed yet."); + } + + return value.Value; + } + + public static ValueTask> DefaultWaitForCompletionAsync(this Operation operation, CancellationToken cancellationToken) + where TResult : notnull + { + return operation.WaitForCompletionAsync(DefaultPollingInterval, cancellationToken); + } + + public static async ValueTask> DefaultWaitForCompletionAsync(this Operation operation, TimeSpan pollingInterval, CancellationToken cancellationToken) + where TResult : notnull + { + while (true) + { + await operation.UpdateStatusAsync(cancellationToken).ConfigureAwait(false); + if (operation.HasCompleted) + { + return Response.FromValue(operation.Value, operation.GetRawResponse()); + } + + await Task.Delay(pollingInterval, cancellationToken).ConfigureAwait(false); + } + } + + internal static Guid GetValue() + { + throw new NotImplementedException(); + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/PiiTaskParameters.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/PiiTaskParameters.cs new file mode 100644 index 000000000000..52691f43ae0c --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/PiiTaskParameters.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("PiiTaskParameters")] + internal partial class PiiTaskParameters + { + internal string ModelVersion { get; set; } + internal StringIndexType? StringIndexType { get; set; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/PiiTaskParametersDomain.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/PiiTaskParametersDomain.cs new file mode 100644 index 000000000000..6dd818e33b2b --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/PiiTaskParametersDomain.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("PiiTaskParametersDomain")] + internal readonly partial struct PiiTaskParametersDomain + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiEntitiesResult.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiResult.cs similarity index 81% rename from sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiEntitiesResult.cs rename to sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiResult.cs index 1d76eb7ffe67..e24ced5e9e3a 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiEntitiesResult.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiResult.cs @@ -11,17 +11,17 @@ namespace Azure.AI.TextAnalytics /// objects containing Personally Identifiable Information that were /// found in that document. /// - public class RecognizePiiEntitiesResult : TextAnalyticsResult + public class RecognizePiiResult : TextAnalyticsResult { private readonly PiiEntityCollection _entities; - internal RecognizePiiEntitiesResult(string id, TextDocumentStatistics statistics, PiiEntityCollection entities) + internal RecognizePiiResult(string id, TextDocumentStatistics statistics, PiiEntityCollection entities) : base(id, statistics) { _entities = entities; } - internal RecognizePiiEntitiesResult(string id, TextAnalyticsError error) : base(id, error) { } + internal RecognizePiiResult(string id, TextAnalyticsError error) : base(id, error) { } /// /// Gets the collection of PII entities containing Personally diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiEntitiesResultCollection.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiResultCollection.cs similarity index 72% rename from sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiEntitiesResultCollection.cs rename to sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiResultCollection.cs index 0f9f3f6d8159..31bf383d3e00 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiEntitiesResultCollection.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiResultCollection.cs @@ -7,12 +7,12 @@ namespace Azure.AI.TextAnalytics { /// - /// Collection of objects corresponding + /// Collection of objects corresponding /// to a batch of documents, and information about the batch operation. /// - public class RecognizePiiEntitiesResultCollection : ReadOnlyCollection + public class RecognizePiiResultCollection : ReadOnlyCollection { - internal RecognizePiiEntitiesResultCollection(IList list, TextDocumentBatchStatistics statistics, string modelVersion) : base(list) + internal RecognizePiiResultCollection(IList list, TextDocumentBatchStatistics statistics, string modelVersion) : base(list) { Statistics = statistics; ModelVersion = modelVersion; diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/SentimentAnalysisTasksItemProperties.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/SentimentAnalysisTasksItemProperties.cs new file mode 100644 index 000000000000..a2545cae8027 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/SentimentAnalysisTasksItemProperties.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("Components1C6O47FSchemasTasksstatePropertiesTasksPropertiesSentimentanalysistasksItemsAllof1")] + internal partial class SentimentAnalysisTasksItemProperties + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/SentimentTaskParameters.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/SentimentTaskParameters.cs new file mode 100644 index 000000000000..0ea392eb9213 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/SentimentTaskParameters.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("SentimentTaskParameters")] + internal partial class SentimentTaskParameters + { + internal string ModelVersion { get; set; } + internal StringIndexType? StringIndexType { get; set; } + + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TaskState.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TaskState.cs new file mode 100644 index 000000000000..617d163e6ced --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TaskState.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("State")] + internal partial struct State + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TasksStateTasks.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TasksStateTasks.cs new file mode 100644 index 000000000000..09a5b93aae48 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TasksStateTasks.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("TasksStateTasks")] + internal partial class TasksStateTasks + { + internal IReadOnlyList Details { get; } + internal int Completed { get; } + internal int Failed { get; } + internal int InProgress { get; } + internal int Total { get; } + internal IReadOnlyList EntityRecognitionTasks { get; } + internal IReadOnlyList EntityRecognitionPiiTasks { get; } + internal IReadOnlyList EntityLinkingTasks { get; } + internal IReadOnlyList KeyPhraseExtractionTasks { get; } + internal IReadOnlyList SentimentAnalysisTasks { get; } + internal IReadOnlyList CustomClassificationTasks { get; } + internal IReadOnlyList CustomEntityRecognitionTasks { get; } + + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TasksStateTasksEntityRecognitionPiiTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TasksStateTasksEntityRecognitionPiiTasksItem.cs new file mode 100644 index 000000000000..d645dfcdb506 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TasksStateTasksEntityRecognitionPiiTasksItem.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("TasksStateTasksEntityRecognitionPiiTasksItem")] + internal partial class TasksStateTasksEntityRecognitionPiiTasksItem + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TasksStateTasksEntityRecognitionTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TasksStateTasksEntityRecognitionTasksItem.cs new file mode 100644 index 000000000000..267cf8aa048a --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TasksStateTasksEntityRecognitionTasksItem.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("TasksStateTasksEntityRecognitionTasksItem")] + internal partial class TasksStateTasksEntityRecognitionTasksItem + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TasksStateTasksKeyPhraseExtractionTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TasksStateTasksKeyPhraseExtractionTasksItem.cs new file mode 100644 index 000000000000..9d40369021cf --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TasksStateTasksKeyPhraseExtractionTasksItem.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("TasksStateTasksKeyPhraseExtractionTasksItem")] + internal partial class TasksStateTasksKeyPhraseExtractionTasksItem + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TasksStateTasksSentimentAnalysisTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TasksStateTasksSentimentAnalysisTasksItem.cs new file mode 100644 index 000000000000..e80018d9f34f --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TasksStateTasksSentimentAnalysisTasksItem.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + [CodeGenModel("TasksStateTasksSentimentAnalysisTasksItem")] + internal partial class TasksStateTasksSentimentAnalysisTasksItem + { + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs index 114e83523565..199dba78e109 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs @@ -19,8 +19,8 @@ namespace Azure.AI.TextAnalytics public partial class TextAnalyticsClient { private readonly Uri _baseUri; - private readonly ServiceRestClient _serviceRestClient; - private readonly ClientDiagnostics _clientDiagnostics; + internal readonly ServiceRestClient _serviceRestClient; + internal readonly ClientDiagnostics _clientDiagnostics; private readonly string _apiVersion; private readonly TextAnalyticsClientOptions _options; private readonly string DefaultCognitiveScope = "https://cognitiveservices.azure.com/.default"; @@ -738,7 +738,7 @@ public virtual async Task> RecognizePiiEntitiesAsy { var documents = new List() { ConvertToMultiLanguageInput(document, language) }; - Response result = await _serviceRestClient.EntitiesRecognitionPiiAsync( + Response result = await _serviceRestClient.EntitiesRecognitionPiiAsync( new MultiLanguageBatchInput(documents), options.ModelVersion, options.IncludeStatistics, @@ -803,7 +803,7 @@ public virtual Response RecognizePiiEntities(string documen { var documents = new List() { ConvertToMultiLanguageInput(document, language) }; - Response result = _serviceRestClient.EntitiesRecognitionPii( + Response result = _serviceRestClient.EntitiesRecognitionPii( new MultiLanguageBatchInput(documents), options.ModelVersion, options.IncludeStatistics, @@ -855,7 +855,7 @@ public virtual Response RecognizePiiEntities(string documen /// that a given entity correctly matches the identified substring. /// Service returned a non-success /// status code. - public virtual async Task> RecognizePiiEntitiesBatchAsync(IEnumerable documents, string language = default, RecognizePiiEntitiesOptions options = default, CancellationToken cancellationToken = default) + public virtual async Task> RecognizePiiEntitiesBatchAsync(IEnumerable documents, string language = default, RecognizePiiEntitiesOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(documents, nameof(documents)); options ??= new RecognizePiiEntitiesOptions(); @@ -891,7 +891,7 @@ public virtual async Task> Recogn /// that a given entity correctly matches the identified substring. /// Service returned a non-success /// status code. - public virtual Response RecognizePiiEntitiesBatch(IEnumerable documents, string language = default, RecognizePiiEntitiesOptions options = default, CancellationToken cancellationToken = default) + public virtual Response RecognizePiiEntitiesBatch(IEnumerable documents, string language = default, RecognizePiiEntitiesOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(documents, nameof(documents)); options ??= new RecognizePiiEntitiesOptions(); @@ -922,7 +922,7 @@ public virtual Response RecognizePiiEntiti /// that a given entity correctly matches the identified substring. /// Service returned a non-success /// status code. - public virtual async Task> RecognizePiiEntitiesBatchAsync(IEnumerable documents, RecognizePiiEntitiesOptions options = default, CancellationToken cancellationToken = default) + public virtual async Task> RecognizePiiEntitiesBatchAsync(IEnumerable documents, RecognizePiiEntitiesOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(documents, nameof(documents)); options ??= new RecognizePiiEntitiesOptions(); @@ -953,7 +953,7 @@ public virtual async Task> Recogn /// that a given entity correctly matches the identified substring. /// Service returned a non-success /// status code. - public virtual Response RecognizePiiEntitiesBatch(IEnumerable documents, RecognizePiiEntitiesOptions options = default, CancellationToken cancellationToken = default) + public virtual Response RecognizePiiEntitiesBatch(IEnumerable documents, RecognizePiiEntitiesOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(documents, nameof(documents)); options ??= new RecognizePiiEntitiesOptions(); @@ -962,14 +962,14 @@ public virtual Response RecognizePiiEntiti return RecognizePiiEntitiesBatch(documentInputs, options, cancellationToken); } - private async Task> RecognizePiiEntitiesBatchAsync(MultiLanguageBatchInput batchInput, RecognizePiiEntitiesOptions options, CancellationToken cancellationToken) + private async Task> RecognizePiiEntitiesBatchAsync(MultiLanguageBatchInput batchInput, RecognizePiiEntitiesOptions options, CancellationToken cancellationToken) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TextAnalyticsClient)}.{nameof(RecognizePiiEntitiesBatch)}"); scope.Start(); try { - Response result = await _serviceRestClient.EntitiesRecognitionPiiAsync( + Response result = await _serviceRestClient.EntitiesRecognitionPiiAsync( batchInput, options.ModelVersion, options.IncludeStatistics, @@ -979,7 +979,7 @@ private async Task> RecognizePiiE var response = result.GetRawResponse(); IDictionary map = CreateIdToIndexMap(batchInput.Documents); - RecognizePiiEntitiesResultCollection results = Transforms.ConvertToRecognizePiiEntitiesResultCollection(result.Value, map); + RecognizePiiResultCollection results = Transforms.ConvertToRecognizePiiResultCollection(result.Value, map); return Response.FromValue(results, response); } catch (Exception e) @@ -989,14 +989,14 @@ private async Task> RecognizePiiE } } - private Response RecognizePiiEntitiesBatch(MultiLanguageBatchInput batchInput, RecognizePiiEntitiesOptions options, CancellationToken cancellationToken) + private Response RecognizePiiEntitiesBatch(MultiLanguageBatchInput batchInput, RecognizePiiEntitiesOptions options, CancellationToken cancellationToken) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TextAnalyticsClient)}.{nameof(RecognizePiiEntitiesBatch)}"); scope.Start(); try { - Response result = _serviceRestClient.EntitiesRecognitionPii( + Response result = _serviceRestClient.EntitiesRecognitionPii( batchInput, options.ModelVersion, options.IncludeStatistics, @@ -1006,7 +1006,7 @@ private Response RecognizePiiEntitiesBatch var response = result.GetRawResponse(); IDictionary map = CreateIdToIndexMap(batchInput.Documents); - RecognizePiiEntitiesResultCollection results = Transforms.ConvertToRecognizePiiEntitiesResultCollection(result.Value, map); + RecognizePiiResultCollection results = Transforms.ConvertToRecognizePiiResultCollection(result.Value, map); return Response.FromValue(results, response); } catch (Exception e) @@ -2076,6 +2076,148 @@ private Response RecognizeLinkedEntitie #endregion + #region Analyze Operation + + /// + /// Recognizes Analyze Operation async. + /// + /// + /// + /// A controlling the request lifetime. + /// A to wait on this long-running operation. Its upon successful + /// completion will contain layout elements extracted from the form. + public virtual AnalyzeOperation StartAnalyzeOperation(IEnumerable documents, TextAnalyticsRequestOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(documents, nameof(documents)); + + options ??= new TextAnalyticsRequestOptions(); + + MultiLanguageBatchInput documentInputs = ConvertToMultiLanguageInputs(documents); + + AnalyzeBatchInput analyzeDocumentInputs = new AnalyzeBatchInput(documentInputs, new JobManifestTasks()); + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TextAnalyticsClient)}.{nameof(StartAnalyzeHealth)}"); + scope.Start(); + + try + { + ResponseWithHeaders response = _serviceRestClient.Analyze(analyzeDocumentInputs, cancellationToken); + string location = response.Headers.OperationLocation; + + return new AnalyzeOperation(_serviceRestClient, _clientDiagnostics, location); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Recognizes layout elements from one or more passed-in forms. + /// + /// + /// + /// A controlling the request lifetime. + /// A to wait on this long-running operation. Its upon successful + /// completion will contain layout elements extracted from the form. + public virtual async Task StartAnalyzeOperationAsync(IEnumerable documents, TextAnalyticsRequestOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(documents, nameof(documents)); + + options ??= new TextAnalyticsRequestOptions(); + + MultiLanguageBatchInput documentInputs = ConvertToMultiLanguageInputs(documents); + AnalyzeBatchInput analyzeDocumentInputs = new AnalyzeBatchInput(documentInputs, new JobManifestTasks()); + + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TextAnalyticsClient)}.{nameof(StartAnalyzeHealth)}"); + scope.Start(); + + try + { + ResponseWithHeaders response = await _serviceRestClient.AnalyzeAsync(analyzeDocumentInputs, cancellationToken).ConfigureAwait(false); + string location = response.Headers.OperationLocation; + + return new AnalyzeOperation(_serviceRestClient, _clientDiagnostics, location); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + #endregion + + #region Health Async + + /// + /// Recognizes health entities async. + /// + /// + /// + /// A controlling the request lifetime. + /// A to wait on this long-running operation. Its upon successful + /// completion will contain layout elements extracted from the form. + public virtual AnalyzeHealthOperation StartAnalyzeHealth(IEnumerable documents, TextAnalyticsRequestOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(documents, nameof(documents)); + + options ??= new TextAnalyticsRequestOptions(); + + MultiLanguageBatchInput documentInputs = ConvertToMultiLanguageInputs(documents); + + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TextAnalyticsClient)}.{nameof(StartAnalyzeHealth)}"); + scope.Start(); + + try + { + ResponseWithHeaders response = _serviceRestClient.Health(documentInputs, options.ModelVersion, _stringCodeUnit, cancellationToken); + string location = response.Headers.OperationLocation; + + return new AnalyzeHealthOperation(_serviceRestClient, _clientDiagnostics, location); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Recognizes layout elements from one or more passed-in forms. + /// + /// + /// + /// A controlling the request lifetime. + /// A to wait on this long-running operation. Its upon successful + /// completion will contain layout elements extracted from the form. + public virtual async Task StartAnalyzeHealthAsync(IEnumerable documents, TextAnalyticsRequestOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(documents, nameof(documents)); + + options ??= new TextAnalyticsRequestOptions(); + + MultiLanguageBatchInput documentInputs = ConvertToMultiLanguageInputs(documents); + + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TextAnalyticsClient)}.{nameof(StartAnalyzeHealth)}"); + scope.Start(); + + try + { + ResponseWithHeaders response = await _serviceRestClient.HealthAsync(documentInputs, options.ModelVersion, _stringCodeUnit, cancellationToken).ConfigureAwait(false); + string location = response.Headers.OperationLocation; + + return new AnalyzeHealthOperation(_serviceRestClient, _clientDiagnostics, location); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + #endregion + #region Common private static IDictionary CreateIdToIndexMap(IEnumerable documents) diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsModelFactory.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsModelFactory.cs index 602b3e8ca7aa..9892d160ff7b 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsModelFactory.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsModelFactory.cs @@ -366,38 +366,38 @@ public static PiiEntityCollection PiiEntityCollection(IList entities, } /// - /// Initializes a new instance of for mocking purposes. + /// Initializes a new instance of for mocking purposes. /// /// Sets the property. /// Sets the property. /// Sets the collection of . - /// A new instance of for mocking purposes. - public static RecognizePiiEntitiesResult RecognizePiiEntitiesResult(string id, TextDocumentStatistics statistics, PiiEntityCollection entities) + /// A new instance of for mocking purposes. + public static RecognizePiiResult RecognizePiiResult(string id, TextDocumentStatistics statistics, PiiEntityCollection entities) { - return new RecognizePiiEntitiesResult(id, statistics, entities); + return new RecognizePiiResult(id, statistics, entities); } /// - /// Initializes a new instance of for mocking purposes. + /// Initializes a new instance of for mocking purposes. /// /// Sets the property. /// Sets the property. - /// A new instance of for mocking purposes. - public static RecognizePiiEntitiesResult RecognizePiiEntitiesResult(string id, TextAnalyticsError error) + /// A new instance of for mocking purposes. + public static RecognizePiiResult RecognizePiiResult(string id, TextAnalyticsError error) { - return new RecognizePiiEntitiesResult(id, error); + return new RecognizePiiResult(id, error); } /// - /// Initializes a new instance of for mocking purposes. + /// Initializes a new instance of for mocking purposes. /// - /// Sets the collection of . - /// Sets the property. - /// Sets the property. - /// A new instance of for mocking purposes. - public static RecognizePiiEntitiesResultCollection RecognizePiiEntitiesResultCollection(IEnumerable list, TextDocumentBatchStatistics statistics, string modelVersion) + /// Sets the collection of . + /// Sets the property. + /// Sets the property. + /// A new instance of for mocking purposes. + public static RecognizePiiResultCollection RecognizePiiResultCollection(IEnumerable list, TextDocumentBatchStatistics statistics, string modelVersion) { - return new RecognizePiiEntitiesResultCollection(list.ToList(), statistics, modelVersion); + return new RecognizePiiResultCollection(list.ToList(), statistics, modelVersion); } #endregion Recognize PII Entities diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs index 273e93b4ffac..c8fd6d26e455 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using System.Collections.Generic; using System.Linq; using Azure.AI.TextAnalytics.Models; @@ -167,25 +168,25 @@ internal static PiiEntityCollection ConvertToPiiEntityCollection(PiiDocumentEnti return new PiiEntityCollection(ConvertToPiiEntityList(documentEntities.Entities.ToList()), documentEntities.RedactedText, ConvertToWarnings(documentEntities.Warnings)); } - internal static RecognizePiiEntitiesResultCollection ConvertToRecognizePiiEntitiesResultCollection(PiiEntitiesResult results, IDictionary idToIndexMap) + internal static RecognizePiiResultCollection ConvertToRecognizePiiResultCollection(PiiResult results, IDictionary idToIndexMap) { - var recognizeEntities = new List(); + var recognizeEntities = new List(); //Read errors foreach (DocumentError error in results.Errors) { - recognizeEntities.Add(new RecognizePiiEntitiesResult(error.Id, ConvertToError(error.Error))); + recognizeEntities.Add(new RecognizePiiResult(error.Id, ConvertToError(error.Error))); } //Read document entities foreach (PiiDocumentEntities docEntities in results.Documents) { - recognizeEntities.Add(new RecognizePiiEntitiesResult(docEntities.Id, docEntities.Statistics ?? default, ConvertToPiiEntityCollection(docEntities))); + recognizeEntities.Add(new RecognizePiiResult(docEntities.Id, docEntities.Statistics ?? default, ConvertToPiiEntityCollection(docEntities))); } recognizeEntities = SortHeterogeneousCollection(recognizeEntities, idToIndexMap); - return new RecognizePiiEntitiesResultCollection(recognizeEntities, results.Statistics, results.ModelVersion); + return new RecognizePiiResultCollection(recognizeEntities, results.Statistics, results.ModelVersion); } #endregion diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/autorest.md b/sdk/textanalytics/Azure.AI.TextAnalytics/src/autorest.md index f0096e31d60b..d11960db35dd 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/autorest.md +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/autorest.md @@ -7,7 +7,7 @@ Run `dotnet msbuild /t:GenerateCode` to generate code. ``` yaml input-file: - - https://github.com/Azure/azure-rest-api-specs/blob/bc1d3e6f1d19840375907101b30579c16c8a5d76/specification/cognitiveservices/data-plane/TextAnalytics/preview/v3.1-preview.2/TextAnalytics.json + - $(this-folder)/swagger-latest.json ``` ### Make generated models internal by default diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/swagger-latest.json b/sdk/textanalytics/Azure.AI.TextAnalytics/src/swagger-latest.json new file mode 100644 index 000000000000..db2abec77ad9 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/swagger-latest.json @@ -0,0 +1,2669 @@ +{ + "swagger": "2.0", + "info": { + "version": "v3.2-preview.1", + "contact": { + "name": "Microsoft Cognitive Services", + "url": "https://azure.microsoft.com/en-us/services/cognitive-services/text-analytics/", + "email": "mlapi@microsoft.com" + }, + "title": "Text Analytics Client", + "description": "The Text Analytics API is a suite of natural language processing (NLP) services built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction and language detection. Further documentation can be found in https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview" + }, + "securityDefinitions": { + "apim_key": { + "type": "apiKey", + "name": "Ocp-Apim-Subscription-Key", + "in": "header" + } + }, + "security": [ + { + "apim_key": [] + } + ], + "x-ms-parameterized-host": { + "hostTemplate": "{Endpoint}/text/analytics/v3.2-preview.1", + "useSchemePrefix": false, + "parameters": [ + { + "$ref": "#/parameters/Endpoint" + } + ] + }, + "paths": { + "/analyze": { + "post": { + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "description": "Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed.", + "operationId": "Analyze", + "summary": "Submit analysis job", + "parameters": [ + { + "description": "Collection of documents to analyze and tasks to execute.", + "in": "body", + "name": "body", + "schema": { + "$ref": "#/definitions/AnalyzeBatchInput" + } + } + ], + "responses": { + "202": { + "description": "A successful call results with an Operation-Location header used to check the status of the analysis job.", + "headers": { + "Operation-Location": { + "type": "string" + } + } + }, + "400": { + "description": "Bad Request.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + }, + "500": { + "description": "Internal error response", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + } + }, + "x-ms-examples": { + "Successful Submit analysis job request": { + "$ref": ".//examples//SuccessfulAnalyzeRequest.json" + } + }, + "deprecated": false, + "x-ms-long-running-operation": true + } + }, + "/analyze/jobs/{jobId}": { + "get": { + "produces": [ + "application/json", + "text/json" + ], + "description": "Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are completed, the job will transition to the completed state and results will be available for each task.", + "operationId": "AnalyzeStatus", + "summary": "Get analysis status and results", + "parameters": [ + { + "$ref": "#/parameters/JobId" + }, + { + "$ref": "#/parameters/ShowStats" + }, + { + "default": 20, + "description": "(Optional) Set the maximum number of results per task. When both $top and $skip are specified, $skip is applied first.", + "in": "query", + "maximum": 50, + "minimum": 1, + "name": "$top", + "type": "integer" + }, + { + "default": 0, + "description": "(Optional) Set the number of elements to offset in the response. When both $top and $skip are specified, $skip is applied first.", + "in": "query", + "minimum": 0, + "name": "$skip", + "type": "integer" + } + ], + "responses": { + "200": { + "description": "Analysis job status and metadata.", + "schema": { + "$ref": "#/definitions/AnalyzeJobState" + } + }, + "404": { + "description": "Job ID not found.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + }, + "500": { + "description": "Internal error response", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + } + }, + "x-ms-examples": { + "Successful Get Analysis job status request": { + "$ref": ".//examples//SuccessfulAnalyzeStatusRequest.json" + } + }, + "deprecated": false + } + }, + "/entities/health/jobs/{jobId}": { + "get": { + "produces": [ + "application/json", + "text/json" + ], + "description": "Get details of the healthcare prediction job specified by the jobId.", + "operationId": "HealthStatus", + "summary": "Get healthcare analysis job status and results", + "parameters": [ + { + "$ref": "#/parameters/JobId" + }, + { + "default": 20, + "description": "(Optional) Set the maximum number of results per task. When both $top and $skip are specified, $skip is applied first.", + "in": "query", + "maximum": 50, + "minimum": 1, + "name": "$top", + "type": "integer" + }, + { + "default": 0, + "description": "(Optional) Set the number of elements to offset in the response. When both $top and $skip are specified, $skip is applied first.", + "in": "query", + "minimum": 0, + "name": "$skip", + "type": "integer" + }, + { + "$ref": "#/parameters/ShowStats" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/HealthcareJobState" + } + }, + "404": { + "description": "Job ID not found.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + }, + "500": { + "description": "Internal error response", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + } + }, + "x-ms-examples": { + "Successful Health request": { + "$ref": ".//examples//SuccessfulHealthStatusRequest.json" + } + }, + "deprecated": false + }, + "delete": { + "produces": [ + "application/json", + "text/json" + ], + "description": "Cancel healthcare prediction job.", + "operationId": "CancelHealthJob", + "summary": "Cancel healthcare prediction job", + "parameters": [ + { + "$ref": "#/parameters/JobId" + } + ], + "responses": { + "204": { + "description": "Cancel Job request has been received.", + "headers": { + "Operation-Location": { + "type": "string" + } + } + }, + "404": { + "description": "Job ID not found.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + }, + "500": { + "description": "Internal error response", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + } + }, + "x-ms-examples": { + "Successful Health request": { + "$ref": ".//examples//SuccessfulHealthDeleteRequest.json" + } + }, + "deprecated": false, + "x-ms-long-running-operation": true + } + }, + "/entities/health/jobs": { + "post": { + "summary": "Submit healthcare analysis job", + "description": "Start a healthcare analysis job to recognize healthcare related entities (drugs, conditions, symptoms, etc) and their relations.", + "operationId": "Health", + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ModelVersion" + }, + { + "$ref": "#/parameters/StringIndexType" + }, + { + "$ref": "#/parameters/MultiLanguageInput" + } + ], + "responses": { + "202": { + "description": "Accepted - call results in a link where the status of the submitted job can be checked via the GET operation.", + "headers": { + "Operation-Location": { + "type": "string" + } + } + }, + "400": { + "description": "Bad Request.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + }, + "500": { + "description": "Internal error response", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + } + }, + "x-ms-examples": { + "Successful Health request": { + "$ref": ".//examples//SuccessfulHealthRequest.json" + } + }, + "deprecated": false, + "x-ms-long-running-operation": true + } + }, + "/entities/recognition/general": { + "post": { + "summary": "Named Entity Recognition", + "description": "The API returns a list of general named entities in a given document. For the list of supported entity types, check Supported Entity Types in Text Analytics API. See the Supported languages in Text Analytics API for the list of enabled languages.", + "operationId": "EntitiesRecognitionGeneral", + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ModelVersion" + }, + { + "$ref": "#/parameters/ShowStats" + }, + { + "$ref": "#/parameters/StringIndexType" + }, + { + "$ref": "#/parameters/MultiLanguageInput" + } + ], + "responses": { + "200": { + "description": "A successful call results in a list of recognized entities returned for each valid document.", + "schema": { + "$ref": "#/definitions/EntitiesResult" + } + }, + "400": { + "description": "Bad Request.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + }, + "500": { + "description": "Internal error response", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + } + }, + "x-ms-examples": { + "Successful Entities request": { + "$ref": ".//examples//SuccessfulEntitiesRequest.json" + } + }, + "deprecated": false + } + }, + "/entities/recognition/pii": { + "post": { + "summary": "Entities containing personal information", + "description": "The API returns a list of entities with personal information (\\\"SSN\\\", \\\"Bank Account\\\" etc) in the document. For the list of supported entity types, check Supported Entity Types in Text Analytics API. See the Supported languages in Text Analytics API for the list of enabled languages.\n", + "operationId": "EntitiesRecognitionPii", + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ModelVersion" + }, + { + "$ref": "#/parameters/ShowStats" + }, + { + "name": "domain", + "in": "query", + "description": "(Optional) if specified, will set the PII domain to include only a subset of the entity categories. Possible values include: 'PHI', 'none'.", + "type": "string" + }, + { + "$ref": "#/parameters/StringIndexType" + }, + { + "$ref": "#/parameters/MultiLanguageInput" + } + ], + "responses": { + "200": { + "description": "A successful call results in a list of entities containing personal information returned for each valid document", + "schema": { + "$ref": "#/definitions/PiiResult" + } + }, + "400": { + "description": "Bad Request.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + }, + "500": { + "description": "Internal error response", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + } + }, + "x-ms-examples": { + "Successful Entity PII request": { + "$ref": ".//examples//SuccessfulEntityPIIRequest.json" + } + }, + "deprecated": false + } + }, + "/entities/linking": { + "post": { + "summary": "Linked entities from a well-known knowledge base", + "description": "The API returns a list of recognized entities with links to a well-known knowledge base. See the Supported languages in Text Analytics API for the list of enabled languages.", + "operationId": "EntitiesLinking", + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ModelVersion" + }, + { + "$ref": "#/parameters/ShowStats" + }, + { + "$ref": "#/parameters/StringIndexType" + }, + { + "$ref": "#/parameters/MultiLanguageInput" + } + ], + "responses": { + "200": { + "description": "A successful call results in a list of recognized entities with links to a well-known knowledge base returned for each valid document", + "schema": { + "$ref": "#/definitions/EntityLinkingResult" + } + }, + "400": { + "description": "Bad Request.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + }, + "500": { + "description": "Internal error response", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + } + }, + "x-ms-examples": { + "Successful Entity Linking request": { + "$ref": ".//examples//SuccessfulEntityLinkingRequest.json" + } + }, + "deprecated": false + } + }, + "/keyPhrases": { + "post": { + "summary": "Key Phrases", + "description": "The API returns a list of strings denoting the key phrases in the input text. See the Supported languages in Text Analytics API for the list of enabled languages.", + "operationId": "KeyPhrases", + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ModelVersion" + }, + { + "$ref": "#/parameters/ShowStats" + }, + { + "$ref": "#/parameters/MultiLanguageInput" + } + ], + "responses": { + "200": { + "description": "A successful response results in 0 or more key phrases identified in each valid document", + "schema": { + "$ref": "#/definitions/KeyPhraseResult" + } + }, + "400": { + "description": "Bad Request.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + }, + "500": { + "description": "Internal error response", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + } + }, + "x-ms-examples": { + "Successful Key Phrase request": { + "$ref": ".//examples//SuccessfulKeyPhrasesRequest.json" + } + }, + "deprecated": false + } + }, + "/languages": { + "post": { + "summary": "Detect Language", + "description": "The API returns the detected language and a numeric score between 0 and 1. Scores close to 1 indicate 100% certainty that the identified language is true. See the Supported languages in Text Analytics API for the list of enabled languages.", + "operationId": "Languages", + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ModelVersion" + }, + { + "$ref": "#/parameters/ShowStats" + }, + { + "$ref": "#/parameters/LanguageInput" + } + ], + "responses": { + "200": { + "description": "A successful call results in the detected language with the highest probability for each valid document", + "schema": { + "$ref": "#/definitions/LanguageResult" + } + }, + "400": { + "description": "Bad Request.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + }, + "500": { + "description": "Internal error response", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + } + }, + "x-ms-examples": { + "Successful Detect Language request": { + "$ref": ".//examples//SuccessfulLanguagesRequest.json" + } + }, + "deprecated": false + } + }, + "/sentiment": { + "post": { + "summary": "Sentiment", + "description": "The API returns a detailed sentiment analysis for the input text. The analysis is done in multiple levels of granularity, start from the a document level, down to sentence and key terms (aspects) and opinions.", + "operationId": "Sentiment", + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ModelVersion" + }, + { + "$ref": "#/parameters/ShowStats" + }, + { + "name": "opinionMining", + "in": "query", + "description": "(Optional) if set to true, response will contain input and document level statistics including aspect-based sentiment analysis results.", + "type": "boolean" + }, + { + "$ref": "#/parameters/StringIndexType" + }, + { + "$ref": "#/parameters/MultiLanguageInput" + } + ], + "responses": { + "200": { + "description": "A successful call results in a document sentiment prediction, as well as sentiment scores for each sentiment class (Positive, Negative, and Neutral)", + "schema": { + "$ref": "#/definitions/SentimentResponse" + } + }, + "400": { + "description": "Bad Request.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + }, + "500": { + "description": "Internal error response", + "schema": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-error-response": true + } + }, + "x-ms-examples": { + "Successful Sentiment request": { + "$ref": ".//examples//SuccessfulSentimentRequest.json" + } + }, + "deprecated": false + } + } + }, + "definitions": { + "JobManifest": { + "properties": { + "tasks": { + "description": "The set of tasks to execute on the input documents. Cannot specify the same task more than once.", + "properties": { + "entityRecognitionTasks": { + "type": "array", + "items": { + "$ref": "#/definitions/EntitiesTask" + } + }, + "entityRecognitionPiiTasks": { + "type": "array", + "items": { + "$ref": "#/definitions/PiiTask" + } + }, + "entityLinkingTasks": { + "type": "array", + "items": { + "$ref": "#/definitions/EntityLinkingTask" + } + }, + "keyPhraseExtractionTasks": { + "type": "array", + "items": { + "$ref": "#/definitions/KeyPhrasesTask" + } + }, + "sentimentAnalysisTasks": { + "type": "array", + "items": { + "$ref": "#/definitions/SentimentTask" + } + }, + "customClassificationTasks": { + "type": "array", + "items": { + "$ref": "#/definitions/CustomClassificationTask" + } + }, + "customEntityRecognitionTasks": { + "type": "array", + "items": { + "$ref": "#/definitions/CustomEntitiesTask" + } + } + }, + "type": "object" + } + }, + "required": [ + "tasks" + ], + "type": "object" + }, + "MultiLanguageBatchInput": { + "type": "object", + "required": [ + "documents" + ], + "properties": { + "documents": { + "type": "array", + "description": "The set of documents to process as part of this batch.", + "items": { + "$ref": "#/definitions/MultiLanguageInput" + } + } + }, + "description": "Contains a set of input documents to be analyzed by the service." + }, + "MultiLanguageInput": { + "type": "object", + "required": [ + "id", + "text" + ], + "properties": { + "id": { + "type": "string", + "description": "A unique, non-empty document identifier." + }, + "text": { + "type": "string", + "description": "The input text to process." + }, + "language": { + "type": "string", + "description": "(Optional) This is the 2 letter ISO 639-1 representation of a language. For example, use \"en\" for English; \"es\" for Spanish etc. If not set, use \"en\" for English as default." + } + }, + "description": "Contains an input document to be analyzed by the service." + }, + "DocumentError": { + "type": "object", + "required": [ + "id", + "error" + ], + "properties": { + "id": { + "type": "string", + "description": "Document Id." + }, + "error": { + "type": "object", + "description": "Document Error.", + "$ref": "#/definitions/TextAnalyticsError" + } + } + }, + "ErrorResponse": { + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "object", + "description": "Document Error.", + "$ref": "#/definitions/TextAnalyticsError" + } + } + }, + "TextAnalyticsError": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "string", + "enum": [ + "InvalidRequest", + "InvalidArgument", + "InternalServerError", + "ServiceUnavailable", + "NotFound" + ], + "x-ms-enum": { + "name": "ErrorCodeValue", + "modelAsString": false + }, + "description": "Error code." + }, + "message": { + "type": "string", + "description": "Error message." + }, + "target": { + "type": "string", + "description": "Error target." + }, + "innererror": { + "$ref": "#/definitions/InnerError", + "description": "Inner error contains more specific information." + }, + "details": { + "type": "array", + "description": "Details about specific errors that led to this reported error.", + "items": { + "$ref": "#/definitions/TextAnalyticsError" + } + } + } + }, + "TextAnalyticsTask": { + "type": "object", + "required": [ + "enable" + ], + "properties": { + "enable": { + "default": false, + "type": "boolean" + } + } + }, + "TextAnalyticsWarning": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "string", + "enum": [ + "LongWordsInDocument", + "DocumentTruncated" + ], + "x-ms-enum": { + "name": "WarningCodeValue", + "modelAsString": true + }, + "description": "Error code." + }, + "message": { + "type": "string", + "description": "Warning message." + }, + "targetRef": { + "type": "string", + "description": "A JSON pointer reference indicating the target object." + } + } + }, + "PiiTask": { + "allOf": [ + { + "$ref": "#/definitions/TextAnalyticsTask" + }, + { + "properties": { + "parameters": { + "properties": { + "domain": { + "default": "none", + "enum": [ + "phi", + "none" + ], + "type": "string" + }, + "model-version": { + "default": "latest", + "type": "string" + }, + "stringIndexType": { + "$ref": "#/definitions/StringIndexType" + } + }, + "type": "object" + } + }, + "type": "object" + } + ] + }, + "EntitiesTask": { + "allOf": [ + { + "$ref": "#/definitions/TextAnalyticsTask" + }, + { + "properties": { + "parameters": { + "properties": { + "model-version": { + "default": "latest", + "type": "string" + }, + "stringIndexType": { + "$ref": "#/definitions/StringIndexType" + } + }, + "type": "object" + } + }, + "type": "object" + } + ] + }, + "InnerError": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "string", + "enum": [ + "InvalidParameterValue", + "InvalidRequestBodyFormat", + "EmptyRequest", + "MissingInputRecords", + "InvalidDocument", + "ModelVersionIncorrect", + "InvalidDocumentBatch", + "UnsupportedLanguageCode", + "InvalidCountryHint" + ], + "x-ms-enum": { + "name": "InnerErrorCodeValue", + "modelAsString": true + }, + "description": "Error code." + }, + "message": { + "type": "string", + "description": "Error message." + }, + "details": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Error details." + }, + "target": { + "type": "string", + "description": "Error target." + }, + "innererror": { + "$ref": "#/definitions/InnerError", + "description": "Inner error contains more specific information." + } + } + }, + "AnalyzeBatchInput": { + "allOf": [ + { + "$ref": "#/definitions/JobDescriptor" + }, + { + "type": "object", + "required": [ + "analysisInput" + ], + "properties": { + "analysisInput": + { + "$ref": "#/definitions/MultiLanguageBatchInput" + } + } + }, + { + "$ref": "#/definitions/JobManifest" + } + ] + }, + "AnalyzeJobState": { + "allOf": [ + { + "$ref": "#/definitions/JobMetadata" + }, + { + "$ref": "#/definitions/TasksState" + }, + { + "properties": { + "errors": { + "items": { + "$ref": "#/definitions/TextAnalyticsError" + }, + "type": "array" + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + } + }, + "type": "object" + }, + { + "$ref": "#/definitions/Pagination" + } + ] + }, + "CustomClassification": { + "properties": { + "confidenceScore": { + "example": 0.87, + "format": "double", + "type": "number" + }, + "name": { + "example": "hotel booking", + "type": "string" + } + }, + "required": [ + "name", + "confidenceScore" + ], + "type": "object" + }, + "CustomClassificationResult": { + "properties": { + "documents": { + "description": "Response by document", + "items": { + "$ref": "#/definitions/CustomClassificationDocument" + }, + "type": "array" + }, + "errors": { + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + }, + "type": "array" + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + } + }, + "required": [ + "documents", + "errors" + ], + "type": "object" + }, + "CustomClassificationTask": { + "allOf": [ + { + "$ref": "#/definitions/TextAnalyticsTask" + }, + { + "properties": { + "parameters": { + "properties": { + "appId": { + "type": "string" + }, + "slotName": { + "type": "string" + } + }, + "required": [ + "appId", + "slotName" + ], + "type": "object" + } + }, + "required": [ + "parameters" + ], + "type": "object" + } + ] + }, + "CustomClassificationDocument": { + "type": "object", + "required": [ + "id", + "classifications" + ], + "properties": { + "id": { + "type": "string" + }, + "classifications": { + "items": { + "$ref": "#/definitions/CustomClassification" + }, + "type": "array" + } + } + }, + "CustomEntitiesDocument": { + "type": "object", + "required": [ + "id", + "entities" + ], + "properties": { + "id": { + "type": "string" + }, + "entities": { + "items": { + "$ref": "#/definitions/CustomEntity" + }, + "type": "array" + } + } + }, + "CustomEntitiesResult": { + "properties": { + "documents": { + "description": "Response by document", + "items": { + "$ref": "#/definitions/CustomEntitiesDocument" + }, + "type": "array" + }, + "errors": { + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + }, + "type": "array" + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + } + }, + "required": [ + "documents", + "errors" + ], + "type": "object" + }, + "CustomEntitiesTask": { + "allOf": [ + { + "$ref": "#/definitions/TextAnalyticsTask" + }, + { + "properties": { + "parameters": { + "properties": { + "appId": { + "type": "string" + }, + "slotName": { + "type": "string" + }, + "stringIndexType": { + "$ref": "#/definitions/StringIndexType" + } + }, + "required": [ + "appId", + "slotName" + ], + "type": "object" + } + }, + "required": [ + "parameters" + ], + "type": "object" + } + ] + }, + "CustomEntity": { + "allOf": [ + { + "$ref": "#/definitions/Entity" + }, + { + "type": "object", + "properties": { + "children": { + "example": [ + { + "category": "city", + "confidenceScore": 0.78, + "length": 3, + "offset": 5 + } + ], + "items": { + "$ref": "#/definitions/CustomEntity" + }, + "type": "array" + } + } + } + ] + }, + "SentimentResponse": { + "type": "object", + "required": [ + "documents", + "errors", + "modelVersion" + ], + "properties": { + "documents": { + "type": "array", + "description": "Sentiment analysis per document.", + "items": { + "$ref": "#/definitions/DocumentSentiment" + } + }, + "errors": { + "type": "array", + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + } + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + }, + "modelVersion": { + "type": "string", + "description": "This field indicates which model is used for scoring." + } + } + }, + "SentimentTask": { + "allOf": [ + { + "$ref": "#/definitions/TextAnalyticsTask" + }, + { + "properties": { + "parameters": { + "properties": { + "model-version": { + "default": "latest", + "type": "string" + }, + "opinionMining": { + "default": false, + "type": "boolean" + }, + "stringIndexType": { + "$ref": "#/definitions/StringIndexType" + } + }, + "type": "object" + } + }, + "type": "object" + } + ] + }, + "TaskState": { + "properties": { + "lastUpdateDateTime": { + "format": "date-time", + "type": "string" + }, + "name": { + "type": "string" + }, + "status": { + "enum": [ + "notstarted", + "running", + "succeeded", + "failed", + "cancelled", + "cancelling" + ], + "x-ms-enum": { + "modelAsString": false, + "name": "State" + } + } + }, + "required": [ + "name", + "status", + "lastUpdateDateTime" + ], + "type": "object" + }, + "TasksState": { + "properties": { + "tasks": { + "properties": { + "details": { + "items": { + "$ref": "#/definitions/TaskState" + }, + "type": "array" + }, + "completed": { + "type": "integer" + }, + "failed": { + "type": "integer" + }, + "inProgress": { + "type": "integer" + }, + "total": { + "type": "integer" + }, + "entityRecognitionTasks": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/TaskState" + }, + { + "type": "object", + "properties": { + "results": { + "$ref": "#/definitions/EntitiesResult" + } + } + } + ] + } + }, + "entityRecognitionPiiTasks": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/TaskState" + }, + { + "type": "object", + "properties": { + "results": { + "$ref": "#/definitions/PiiResult" + } + } + } + ] + } + }, + "entityLinkingTasks": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/TaskState" + }, + { + "type": "object", + "properties": { + "results": { + "$ref": "#/definitions/EntityLinkingResult" + } + } + } + ] + } + }, + "keyPhraseExtractionTasks": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/TaskState" + }, + { + "type": "object", + "properties": { + "results": { + "$ref": "#/definitions/KeyPhraseResult" + } + } + } + ] + } + }, + "sentimentAnalysisTasks": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/TaskState" + }, + { + "type": "object", + "properties": { + "results": { + "$ref": "#/definitions/SentimentResponse" + } + } + } + ] + } + }, + "customClassificationTasks": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/TaskState" + }, + { + "type": "object", + "properties": { + "results": { + "$ref": "#/definitions/CustomClassificationResult" + } + } + } + ] + } + }, + "customEntityRecognitionTasks": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/TaskState" + }, + { + "type": "object", + "properties": { + "results": { + "$ref": "#/definitions/CustomEntitiesResult" + } + } + } + ] + } + } + }, + "required": [ + "total", + "completed", + "failed", + "inProgress" + ], + "type": "object" + } + }, + "required": [ + "tasks" + ], + "type": "object" + }, + "DocumentSentiment": { + "type": "object", + "required": [ + "id", + "sentiment", + "confidenceScores", + "sentences", + "warnings" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "sentiment": { + "type": "string", + "description": "Predicted sentiment for document (Negative, Neutral, Positive, or Mixed).", + "enum": [ + "positive", + "neutral", + "negative", + "mixed" + ], + "x-ms-enum": { + "name": "DocumentSentimentValue", + "modelAsString": false + } + }, + "statistics": { + "$ref": "#/definitions/DocumentStatistics" + }, + "confidenceScores": { + "description": "Document level sentiment confidence scores between 0 and 1 for each sentiment class.", + "$ref": "#/definitions/SentimentConfidenceScorePerLabel" + }, + "sentences": { + "type": "array", + "description": "Sentence level sentiment analysis.", + "items": { + "$ref": "#/definitions/SentenceSentiment" + } + }, + "warnings": { + "type": "array", + "description": "Warnings encountered while processing document.", + "items": { + "$ref": "#/definitions/TextAnalyticsWarning" + } + } + } + }, + "RequestStatistics": { + "type": "object", + "required": [ + "documentsCount", + "validDocumentsCount", + "erroneousDocumentsCount", + "transactionsCount" + ], + "properties": { + "documentsCount": { + "type": "integer", + "format": "int32", + "description": "Number of documents submitted in the request." + }, + "validDocumentsCount": { + "type": "integer", + "format": "int32", + "description": "Number of valid documents. This excludes empty, over-size limit or non-supported languages documents." + }, + "erroneousDocumentsCount": { + "type": "integer", + "format": "int32", + "description": "Number of invalid documents. This includes empty, over-size limit or non-supported languages documents." + }, + "transactionsCount": { + "type": "integer", + "format": "int64", + "description": "Number of transactions for the request." + } + }, + "description": "if showStats=true was specified in the request this field will contain information about the request payload." + }, + "DocumentStatistics": { + "type": "object", + "required": [ + "charactersCount", + "transactionsCount" + ], + "properties": { + "charactersCount": { + "type": "integer", + "format": "int32", + "description": "Number of text elements recognized in the document." + }, + "transactionsCount": { + "type": "integer", + "format": "int32", + "description": "Number of transactions for the document." + } + }, + "description": "if showStats=true was specified in the request this field will contain information about the document payload." + }, + "SentimentConfidenceScorePerLabel": { + "type": "object", + "required": [ + "positive", + "neutral", + "negative" + ], + "properties": { + "positive": { + "type": "number", + "format": "double" + }, + "neutral": { + "type": "number", + "format": "double" + }, + "negative": { + "type": "number", + "format": "double" + } + }, + "description": "Represents the confidence scores between 0 and 1 across all sentiment classes: positive, neutral, negative." + }, + "SentenceSentiment": { + "type": "object", + "required": [ + "text", + "sentiment", + "confidenceScores", + "offset", + "length" + ], + "properties": { + "text": { + "type": "string", + "description": "The sentence text." + }, + "sentiment": { + "type": "string", + "description": "The predicted Sentiment for the sentence.", + "enum": [ + "positive", + "neutral", + "negative" + ], + "x-ms-enum": { + "name": "SentenceSentimentValue", + "modelAsString": false + } + }, + "confidenceScores": { + "description": "The sentiment confidence score between 0 and 1 for the sentence for all classes.", + "$ref": "#/definitions/SentimentConfidenceScorePerLabel" + }, + "offset": { + "type": "integer", + "format": "int32", + "description": "The sentence offset from the start of the document." + }, + "length": { + "type": "integer", + "format": "int32", + "description": "The length of the sentence." + }, + "aspects": { + "type": "array", + "description": "The array of aspect object for the sentence.", + "items": { + "$ref": "#/definitions/SentenceAspect" + } + }, + "opinions": { + "type": "array", + "description": "The array of opinion object for the sentence.", + "items": { + "$ref": "#/definitions/SentenceOpinion" + } + } + } + }, + "SentenceAspect": { + "type": "object", + "required": [ + "confidenceScores", + "length", + "offset", + "relations", + "sentiment", + "text" + ], + "properties": { + "sentiment": { + "type": "string", + "enum": [ + "positive", + "mixed", + "negative" + ], + "x-ms-enum": { + "name": "TokenSentimentValue", + "modelAsString": false + }, + "description": "Aspect level sentiment for the aspect in the sentence." + }, + "confidenceScores": { + "description": "Aspect level sentiment confidence scores for the aspect in the sentence.", + "$ref": "#/definitions/AspectConfidenceScoreLabel" + }, + "offset": { + "type": "integer", + "format": "int32", + "description": "The aspect offset from the start of the sentence." + }, + "length": { + "type": "integer", + "format": "int32", + "description": "The length of the aspect." + }, + "text": { + "type": "string", + "description": "The aspect text detected." + }, + "relations": { + "type": "array", + "description": "The array of either opinion or aspect object which is related to the aspect.", + "items": { + "$ref": "#/definitions/AspectRelation" + } + } + } + }, + "SentenceOpinion": { + "type": "object", + "required": [ + "confidenceScores", + "isNegated", + "length", + "offset", + "sentiment", + "text" + ], + "properties": { + "sentiment": { + "type": "string", + "enum": [ + "positive", + "mixed", + "negative" + ], + "x-ms-enum": { + "name": "TokenSentimentValue", + "modelAsString": false + }, + "description": "Opinion level sentiment for the aspect in the sentence." + }, + "confidenceScores": { + "description": "Opinion level sentiment confidence scores for the aspect in the sentence.", + "$ref": "#/definitions/AspectConfidenceScoreLabel" + }, + "offset": { + "type": "integer", + "format": "int32", + "description": "The opinion offset from the start of the sentence." + }, + "length": { + "type": "integer", + "format": "int32", + "description": "The length of the opinion." + }, + "text": { + "type": "string", + "description": "The aspect text detected." + }, + "isNegated": { + "type": "boolean", + "description": "The indicator representing if the opinion is negated." + } + } + }, + "AspectRelation": { + "type": "object", + "required": [ + "ref", + "relationType" + ], + "properties": { + "relationType": { + "type": "string", + "enum": [ + "opinion", + "aspect" + ], + "x-ms-enum": { + "name": "AspectRelationType", + "modelAsString": false + }, + "description": "The type related to the aspect." + }, + "ref": { + "type": "string", + "description": "The JSON pointer indicating the linked object." + } + } + }, + "AspectConfidenceScoreLabel": { + "type": "object", + "required": [ + "negative", + "positive" + ], + "properties": { + "positive": { + "type": "number", + "format": "double" + }, + "negative": { + "type": "number", + "format": "double" + } + }, + "description": "Represents the confidence scores across all sentiment classes: positive, neutral, negative." + }, + "EntitiesResult": { + "type": "object", + "required": [ + "documents", + "errors", + "modelVersion" + ], + "properties": { + "documents": { + "type": "array", + "description": "Response by document", + "items": { + "$ref": "#/definitions/DocumentEntities" + } + }, + "errors": { + "type": "array", + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + } + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + }, + "modelVersion": { + "type": "string", + "description": "This field indicates which model is used for scoring." + } + } + }, + "DocumentEntities": { + "type": "object", + "required": [ + "id", + "entities", + "warnings" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "entities": { + "type": "array", + "description": "Recognized entities in the document.", + "items": { + "$ref": "#/definitions/Entity" + } + }, + "warnings": { + "type": "array", + "description": "Warnings encountered while processing document.", + "items": { + "$ref": "#/definitions/TextAnalyticsWarning" + } + }, + "statistics": { + "description": "if showStats=true was specified in the request this field will contain information about the document payload.", + "$ref": "#/definitions/DocumentStatistics" + } + } + }, + "PiiDocumentEntities": { + "type": "object", + "required": [ + "id", + "entities", + "warnings", + "redactedText" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "entities": { + "type": "array", + "description": "Recognized entities in the document.", + "items": { + "$ref": "#/definitions/Entity" + } + }, + "warnings": { + "type": "array", + "description": "Warnings encountered while processing document.", + "items": { + "$ref": "#/definitions/TextAnalyticsWarning" + } + }, + "statistics": { + "description": "if showStats=true was specified in the request this field will contain information about the document payload.", + "$ref": "#/definitions/DocumentStatistics" + }, + "redactedText": { + "type": "string" + } + } + }, + "Entity": { + "type": "object", + "required": [ + "text", + "category", + "offset", + "length", + "confidenceScore" + ], + "properties": { + "text": { + "type": "string", + "description": "Entity text as appears in the request." + }, + "category": { + "type": "string", + "description": "Entity type." + }, + "subcategory": { + "type": "string", + "description": "(Optional) Entity sub type." + }, + "offset": { + "type": "integer", + "format": "int32", + "description": "Start position for the entity text. Use of different 'stringIndexType' values can affect the offset returned." + }, + "length": { + "type": "integer", + "format": "int32", + "description": "Length for the entity text. Use of different 'stringIndexType' values can affect the length returned." + }, + "confidenceScore": { + "type": "number", + "format": "double", + "description": "Confidence score between 0 and 1 of the extracted entity." + } + } + }, + "EntityLinkingResult": { + "type": "object", + "required": [ + "documents", + "errors", + "modelVersion" + ], + "properties": { + "documents": { + "type": "array", + "description": "Response by document", + "items": { + "$ref": "#/definitions/DocumentLinkedEntities" + } + }, + "errors": { + "type": "array", + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + } + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + }, + "modelVersion": { + "type": "string", + "description": "This field indicates which model is used for scoring." + } + } + }, + "DocumentLinkedEntities": { + "type": "object", + "required": [ + "id", + "entities", + "warnings" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "entities": { + "type": "array", + "description": "Recognized well-known entities in the document.", + "items": { + "$ref": "#/definitions/LinkedEntity" + } + }, + "warnings": { + "type": "array", + "description": "Warnings encountered while processing document.", + "items": { + "$ref": "#/definitions/TextAnalyticsWarning" + } + }, + "statistics": { + "description": "if showStats=true was specified in the request this field will contain information about the document payload.", + "$ref": "#/definitions/DocumentStatistics" + } + } + }, + "EntityLinkingTask": { + "allOf": [ + { + "$ref": "#/definitions/TextAnalyticsTask" + }, + { + "properties": { + "parameters": { + "properties": { + "model-version": { + "default": "latest", + "type": "string" + }, + "stringIndexType": { + "$ref": "#/definitions/StringIndexType" + } + }, + "type": "object" + } + }, + "type": "object" + } + ] + }, + "HealthcareJobState": { + "allOf": [ + { + "$ref": "#/definitions/JobMetadata" + }, + { + "properties": { + "results": { + "$ref": "#/definitions/HealthcareResult" + } + }, + "type": "object" + }, + { + "$ref": "#/definitions/Pagination" + } + ] + }, + "HealthcareResult": { + "type": "object", + "required": [ + "documents", + "errors", + "modelVersion" + ], + "properties": { + "documents": { + "type": "array", + "description": "Response by document", + "items": { + "$ref": "#/definitions/DocumentHealthcareEntities" + } + }, + "errors": { + "type": "array", + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + } + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + }, + "modelVersion": { + "type": "string", + "description": "This field indicates which model is used for scoring." + } + } + }, + "DocumentHealthcareEntities": { + "type": "object", + "required": [ + "id", + "entities", + "relations", + "warnings" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "entities": { + "description": "Healthcare entities.", + "type": "array", + "items": { + "$ref": "#/definitions/HealthcareEntity" + } + }, + "relations": { + "type": "array", + "description": "Healthcare entity relations.", + "items": { + "$ref": "#/definitions/HealthcareRelation" + } + }, + "warnings": { + "type": "array", + "description": "Warnings encountered while processing document.", + "items": { + "$ref": "#/definitions/TextAnalyticsWarning" + } + }, + "statistics": { + "description": "if showStats=true was specified in the request this field will contain information about the document payload.", + "$ref": "#/definitions/DocumentStatistics" + } + } + }, + "HealthcareEntity": { + "allOf": [ + { + "$ref": "#/definitions/Entity" + }, + { + "required": [ + "isNegated" + ], + "properties": { + "isNegated": { + "type": "boolean" + }, + "links": { + "description": "Entity references in known data sources.", + "type": "array", + "items": { + "$ref": "#/definitions/HealthcareEntityLink" + } + } + } + } + ] + }, + "HealthcareRelation": { + "type": "object", + "required": [ + "relationType", + "bidirectional", + "source", + "target" + ], + "properties": { + "relationType": { + "description": "Type of relation. Examples include: `DosageOfMedication` or 'FrequencyOfMedication', etc.", + "type": "string" + }, + "bidirectional": { + "description": "If true the relation between the entities is bidirectional, otherwise directionality is source to target.", + "type": "boolean" + }, + "source": { + "description": "Reference link to the source entity.", + "type": "string" + }, + "target": { + "description": "Reference link to the target entity.", + "type": "string" + } + } + }, + "HealthcareEntityLink": { + "type": "object", + "required": [ + "dataSource", + "id" + ], + "properties": { + "dataSource": { + "description": "Entity Catalog. Examples include: UMLS, CHV, MSH, etc.", + "type": "string" + }, + "id": { + "description": "Entity id in the given source catalog.", + "type": "string" + } + } + }, + "LinkedEntity": { + "type": "object", + "required": [ + "name", + "matches", + "language", + "url", + "dataSource" + ], + "properties": { + "name": { + "type": "string", + "description": "Entity Linking formal name." + }, + "matches": { + "type": "array", + "description": "List of instances this entity appears in the text.", + "items": { + "$ref": "#/definitions/Match" + } + }, + "language": { + "type": "string", + "description": "Language used in the data source." + }, + "id": { + "type": "string", + "description": "Unique identifier of the recognized entity from the data source." + }, + "url": { + "type": "string", + "description": "URL for the entity's page from the data source." + }, + "dataSource": { + "type": "string", + "description": "Data source used to extract entity linking, such as Wiki/Bing etc." + }, + "bingId": { + "type": "string", + "description": "Bing Entity Search API unique identifier of the recognized entity." + } + } + }, + "Match": { + "type": "object", + "required": [ + "confidenceScore", + "text", + "offset", + "length" + ], + "properties": { + "confidenceScore": { + "type": "number", + "format": "double", + "description": "If a well-known item is recognized, a decimal number denoting the confidence level between 0 and 1 will be returned." + }, + "text": { + "type": "string", + "description": "Entity text as appears in the request." + }, + "offset": { + "type": "integer", + "format": "int32", + "description": "Start position for the entity match text." + }, + "length": { + "type": "integer", + "format": "int32", + "description": "Length for the entity match text." + } + } + }, + "JobDescriptor": { + "properties": { + "displayName": { + "description": "Optional display name for the analysis job.", + "type": "string" + } + }, + "type": "object" + }, + "JobMetadata": { + "properties": { + "createdDateTime": { + "format": "date-time", + "type": "string" + }, + "displayName": { + "type": "string" + }, + "expirationDateTime": { + "format": "date-time", + "type": "string" + }, + "jobId": { + "format": "uuid", + "type": "string" + }, + "lastUpdateDateTime": { + "format": "date-time", + "type": "string" + }, + "status": { + "enum": [ + "notstarted", + "running", + "succeeded", + "failed", + "cancelled", + "cancelling", + "partiallycompleted" + ], + "type": "string", + "x-ms-enum": { + "modelAsString": false, + "name": "State" + } + } + }, + "required": [ + "jobId", + "lastUpdateDateTime", + "createdDateTime", + "status" + ], + "type": "object" + }, + "KeyPhraseResult": { + "type": "object", + "required": [ + "documents", + "errors", + "modelVersion" + ], + "properties": { + "documents": { + "type": "array", + "description": "Response by document", + "items": { + "$ref": "#/definitions/DocumentKeyPhrases" + } + }, + "errors": { + "type": "array", + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + } + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + }, + "modelVersion": { + "type": "string", + "description": "This field indicates which model is used for scoring." + } + } + }, + "DocumentKeyPhrases": { + "type": "object", + "required": [ + "id", + "keyPhrases", + "warnings" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "keyPhrases": { + "type": "array", + "description": "A list of representative words or phrases. The number of key phrases returned is proportional to the number of words in the input document.", + "items": { + "type": "string" + } + }, + "warnings": { + "type": "array", + "description": "Warnings encountered while processing document.", + "items": { + "$ref": "#/definitions/TextAnalyticsWarning" + } + }, + "statistics": { + "description": "if showStats=true was specified in the request this field will contain information about the document payload.", + "$ref": "#/definitions/DocumentStatistics" + } + } + }, + "KeyPhrasesTask": { + "allOf": [ + { + "$ref": "#/definitions/TextAnalyticsTask" + }, + { + "properties": { + "parameters": { + "properties": { + "model-version": { + "default": "latest", + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + ] + }, + "LanguageBatchInput": { + "type": "object", + "required": [ + "documents" + ], + "properties": { + "documents": { + "type": "array", + "items": { + "$ref": "#/definitions/LanguageInput" + } + } + } + }, + "LanguageInput": { + "type": "object", + "required": [ + "id", + "text" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "text": { + "type": "string" + }, + "countryHint": { + "type": "string" + } + } + }, + "Pagination": { + "properties": { + "@nextLink": { + "type": "string" + } + }, + "type": "object" + }, + "PiiResult": { + "type": "object", + "required": [ + "documents", + "errors", + "modelVersion" + ], + "properties": { + "documents": { + "type": "array", + "description": "Response by document", + "items": { + "$ref": "#/definitions/PiiDocumentEntities" + } + }, + "errors": { + "type": "array", + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + } + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + }, + "modelVersion": { + "type": "string", + "description": "This field indicates which model is used for scoring." + } + } + }, + "LanguageResult": { + "type": "object", + "required": [ + "documents", + "errors", + "modelVersion" + ], + "properties": { + "documents": { + "type": "array", + "description": "Response by document", + "items": { + "$ref": "#/definitions/DocumentLanguage" + } + }, + "errors": { + "type": "array", + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + } + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + }, + "modelVersion": { + "type": "string", + "description": "This field indicates which model is used for scoring." + } + } + }, + "DocumentLanguage": { + "type": "object", + "required": [ + "id", + "detectedLanguage", + "warnings" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "detectedLanguage": { + "description": "Detected Language.", + "$ref": "#/definitions/DetectedLanguage" + }, + "warnings": { + "type": "array", + "description": "Warnings encountered while processing document.", + "items": { + "$ref": "#/definitions/TextAnalyticsWarning" + } + }, + "statistics": { + "description": "if showStats=true was specified in the request this field will contain information about the document payload.", + "$ref": "#/definitions/DocumentStatistics" + } + } + }, + "DetectedLanguage": { + "type": "object", + "required": [ + "name", + "iso6391Name", + "confidenceScore" + ], + "properties": { + "name": { + "type": "string", + "description": "Long name of a detected language (e.g. English, French)." + }, + "iso6391Name": { + "type": "string", + "description": "A two letter representation of the detected language according to the ISO 639-1 standard (e.g. en, fr)." + }, + "confidenceScore": { + "type": "number", + "format": "double", + "description": "A confidence score between 0 and 1. Scores close to 1 indicate 100% certainty that the identified language is true." + } + } + }, + "StringIndexType": { + "default": "TextElements_v8", + "enum": [ + "TextElements_v8", + "UnicodeCodePoint", + "Utf16CodeUnit" + ], + "x-ms-enum": { + "name": "StringIndexType", + "modelAsString": false, + "values": [ + { + "value": "TextElements_v8", + "description": "Returned offset and length values will correspond to TextElements (Graphemes and Grapheme clusters) confirming to the Unicode 8.0.0 standard. Use this option if your application is written in .Net Framework or .Net Core and you will be using StringInfo." + }, + { + "value": "UnicodeCodePoint", + "description": "Returned offset and length values will correspond to Unicode code points. Use this option if your application is written in a language that support Unicode, for example Python." + }, + { + "value": "Utf16CodeUnit", + "description": "Returned offset and length values will correspond to UTF-16 code units. Use this option if your application is written in a language that support Unicode, for example Java, JavaScript." + } + ] + }, + "type": "string" + } + }, + "parameters": { + "Endpoint": { + "name": "Endpoint", + "description": "Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).", + "x-ms-parameter-location": "client", + "required": true, + "type": "string", + "in": "path", + "x-ms-skip-url-encoding": true + }, + "StringIndexType": { + "name": "stringIndexType", + "in": "query", + "type": "string", + "description": "(Optional) Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets", + "default": "TextElements_v8", + "enum": [ + "TextElements_v8", + "UnicodeCodePoint", + "Utf16CodeUnit" + ], + "x-ms-enum": { + "name": "StringIndexType", + "modelAsString": true, + "values": [ + { + "value": "TextElements_v8", + "description": "Returned offset and length values will correspond to TextElements (Graphemes and Grapheme clusters) confirming to the Unicode 8.0.0 standard. Use this option if your application is written in .Net Framework or .Net Core and you will be using StringInfo." + }, + { + "value": "UnicodeCodePoint", + "description": "Returned offset and length values will correspond to Unicode code points. Use this option if your application is written in a language that support Unicode, for example Python." + }, + { + "value": "Utf16CodeUnit", + "description": "Returned offset and length values will correspond to UTF-16 code units. Use this option if your application is written in a language that support Unicode, for example Java, JavaScript." + } + ] + }, + "x-ms-parameter-location": "method" + }, + "JobId": { + "description": "Job ID", + "format": "uuid", + "in": "path", + "name": "jobId", + "required": true, + "type": "string", + "x-ms-parameter-location": "method" + }, + "ShowStats": { + "name": "showStats", + "in": "query", + "description": "(Optional) if set to true, response will contain request and document level statistics.", + "type": "boolean", + "required": false, + "x-ms-parameter-location": "method" + }, + "ModelVersion": { + "name": "model-version", + "in": "query", + "description": "(Optional) This value indicates which model will be used for scoring. If a model-version is not specified, the API should default to the latest, non-preview version. ", + "type": "string", + "required": false, + "x-ms-parameter-location": "method" + }, + "MultiLanguageInput": { + "in": "body", + "name": "input", + "description": "Collection of documents to analyze.", + "required": true, + "schema": { + "$ref": "#/definitions/MultiLanguageBatchInput" + }, + "x-ms-parameter-location": "method" + }, + "LanguageInput": { + "in": "body", + "name": "input", + "description": "Collection of documents to analyze for language endpoint.", + "required": true, + "schema": { + "$ref": "#/definitions/LanguageBatchInput" + }, + "x-ms-parameter-location": "method" + } + } +} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/swagger.json b/sdk/textanalytics/Azure.AI.TextAnalytics/src/swagger.json new file mode 100644 index 000000000000..608c80cba431 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/swagger.json @@ -0,0 +1,2591 @@ +{ + "swagger": "2.0", + "info": { + "version": "v3.2-preview.1", + "contact": { + "name": "Microsoft Cognitive Services", + "url": "https://azure.microsoft.com/en-us/services/cognitive-services/text-analytics/", + "email": "mlapi@microsoft.com" + }, + "title": "Text Analytics Client", + "description": "The Text Analytics API is a suite of natural language processing (NLP) services built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction and language detection. Further documentation can be found in https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview" + }, + "securityDefinitions": { + "apim_key": { + "type": "apiKey", + "name": "Ocp-Apim-Subscription-Key", + "in": "header" + } + }, + "security": [ + { + "apim_key": [] + } + ], + "x-ms-parameterized-host": { + "hostTemplate": "{Endpoint}/text/analytics/v3.2-preview.1", + "useSchemePrefix": false, + "parameters": [ + { + "$ref": "#/parameters/Endpoint" + } + ] + }, + "paths": { + "/analyze": { + "post": { + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "description": "Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed.", + "operationId": "Analyze", + "summary": "Submit analysis job", + "parameters": [ + { + "description": "Collection of documents to analyze and tasks to execute.", + "in": "body", + "name": "body", + "schema": { + "$ref": "#/definitions/AnalyzeBatchInput" + } + } + ], + "responses": { + "202": { + "description": "A successful call results with an Operation-Location header used to check the status of the analysis job.", + "headers": { + "Operation-Location": { + "type": "string" + } + } + }, + "default": { + "description": "Error response.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Successful Submit analysis job request": { + "$ref": ".//examples//SuccessfulAnalyzeRequest.json" + } + }, + "deprecated": false, + "x-ms-long-running-operation": true + } + }, + "/analyze/jobs/{jobId}": { + "get": { + "produces": [ + "application/json", + "text/json" + ], + "description": "Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are completed, the job will transition to the completed state and results will be available for each task.", + "operationId": "AnalyzeStatus", + "summary": "Get analysis status and results", + "parameters": [ + { + "$ref": "#/parameters/JobId" + }, + { + "$ref": "#/parameters/ShowStats" + }, + { + "default": 20, + "description": "(Optional) Set the maximum number of results per task. When both $top and $skip are specified, $skip is applied first.", + "in": "query", + "maximum": 50, + "minimum": 1, + "name": "$top", + "type": "integer" + }, + { + "default": 0, + "description": "(Optional) Set the number of elements to offset in the response. When both $top and $skip are specified, $skip is applied first.", + "in": "query", + "minimum": 0, + "name": "$skip", + "type": "integer" + } + ], + "responses": { + "200": { + "description": "Analysis job status and metadata.", + "schema": { + "$ref": "#/definitions/AnalyzeJobState" + } + }, + "default": { + "description": "Error response.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Successful Get Analysis job status request": { + "$ref": ".//examples//SuccessfulAnalyzeStatusRequest.json" + } + }, + "deprecated": false + } + }, + "/entities/healthcare/jobs/{jobId}": { + "get": { + "produces": [ + "application/json", + "text/json" + ], + "description": "Get details of the healthcare prediction job specified by the jobId.", + "operationId": "HealthStatus", + "summary": "Get healthcare analysis job status and results", + "parameters": [ + { + "$ref": "#/parameters/JobId" + }, + { + "default": 20, + "description": "(Optional) Set the maximum number of results per task. When both $top and $skip are specified, $skip is applied first.", + "in": "query", + "maximum": 50, + "minimum": 1, + "name": "$top", + "type": "integer" + }, + { + "default": 0, + "description": "(Optional) Set the number of elements to offset in the response. When both $top and $skip are specified, $skip is applied first.", + "in": "query", + "minimum": 0, + "name": "$skip", + "type": "integer" + }, + { + "$ref": "#/parameters/ShowStats" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/HealthcareJobState" + } + }, + "default": { + "description": "Error response.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Successful Health request": { + "$ref": ".//examples//SuccessfulHealthStatusRequest.json" + } + }, + "deprecated": false + }, + "delete": { + "produces": [ + "application/json", + "text/json" + ], + "description": "Cancel healthcare prediction job.", + "operationId": "CancelHealthJob", + "summary": "Cancel healthcare prediction job", + "parameters": [ + { + "$ref": "#/parameters/JobId" + } + ], + "responses": { + "204": { + "description": "Cancel Job request has been received.", + "headers": { + "Operation-Location": { + "type": "string" + } + } + }, + "default": { + "description": "Error response.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Successful Health request": { + "$ref": ".//examples//SuccessfulHealthDeleteRequest.json" + } + }, + "deprecated": false, + "x-ms-long-running-operation": true + } + }, + "/entities/healthcare/jobs": { + "post": { + "summary": "Submit healthcare analysis job", + "description": "Start a healthcare analysis job to recognize healthcare related entities (drugs, conditions, symptoms, etc) and their relations.", + "operationId": "Health", + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ModelVersion" + }, + { + "$ref": "#/parameters/StringIndexType" + }, + { + "$ref": "#/parameters/MultiLanguageInput" + } + ], + "responses": { + "202": { + "description": "Accepted - call results in a link where the status of the submitted job can be checked via the GET operation.", + "headers": { + "Operation-Location": { + "type": "string" + } + } + }, + "default": { + "description": "Error response.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Successful Health request": { + "$ref": ".//examples//SuccessfulHealthRequest.json" + } + }, + "deprecated": false, + "x-ms-long-running-operation": true + } + }, + "/entities/recognition/general": { + "post": { + "summary": "Named Entity Recognition", + "description": "The API returns a list of general named entities in a given document. For the list of supported entity types, check Supported Entity Types in Text Analytics API. See the Supported languages in Text Analytics API for the list of enabled languages.", + "operationId": "EntitiesRecognitionGeneral", + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ModelVersion" + }, + { + "$ref": "#/parameters/ShowStats" + }, + { + "$ref": "#/parameters/StringIndexType" + }, + { + "$ref": "#/parameters/MultiLanguageInput" + } + ], + "responses": { + "200": { + "description": "A successful call results in a list of recognized entities returned for each valid document.", + "schema": { + "$ref": "#/definitions/EntitiesResult" + } + }, + "default": { + "description": "Error response.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Successful Entities request": { + "$ref": ".//examples//SuccessfulEntitiesRequest.json" + } + }, + "deprecated": false + } + }, + "/entities/recognition/pii": { + "post": { + "summary": "Entities containing personal information", + "description": "The API returns a list of entities with personal information (\\\"SSN\\\", \\\"Bank Account\\\" etc) in the document. For the list of supported entity types, check Supported Entity Types in Text Analytics API. See the Supported languages in Text Analytics API for the list of enabled languages.\n", + "operationId": "EntitiesRecognitionPii", + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ModelVersion" + }, + { + "$ref": "#/parameters/ShowStats" + }, + { + "name": "domain", + "in": "query", + "description": "(Optional) if specified, will set the PII domain to include only a subset of the entity categories. Possible values include: 'PHI', 'none'.", + "type": "string" + }, + { + "$ref": "#/parameters/StringIndexType" + }, + { + "$ref": "#/parameters/MultiLanguageInput" + } + ], + "responses": { + "200": { + "description": "A successful call results in a list of entities containing personal information returned for each valid document", + "schema": { + "$ref": "#/definitions/PiiResult" + } + }, + "default": { + "description": "Error response.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Successful Entity PII request": { + "$ref": ".//examples//SuccessfulEntityPIIRequest.json" + } + }, + "deprecated": false + } + }, + "/entities/linking": { + "post": { + "summary": "Linked entities from a well-known knowledge base", + "description": "The API returns a list of recognized entities with links to a well-known knowledge base. See the Supported languages in Text Analytics API for the list of enabled languages.", + "operationId": "EntitiesLinking", + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ModelVersion" + }, + { + "$ref": "#/parameters/ShowStats" + }, + { + "$ref": "#/parameters/StringIndexType" + }, + { + "$ref": "#/parameters/MultiLanguageInput" + } + ], + "responses": { + "200": { + "description": "A successful call results in a list of recognized entities with links to a well-known knowledge base returned for each valid document", + "schema": { + "$ref": "#/definitions/EntityLinkingResult" + } + }, + "default": { + "description": "Error response.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + + }, + "x-ms-examples": { + "Successful Entity Linking request": { + "$ref": ".//examples//SuccessfulEntityLinkingRequest.json" + } + }, + "deprecated": false + } + }, + "/keyPhrases": { + "post": { + "summary": "Key Phrases", + "description": "The API returns a list of strings denoting the key phrases in the input text. See the Supported languages in Text Analytics API for the list of enabled languages.", + "operationId": "KeyPhrases", + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ModelVersion" + }, + { + "$ref": "#/parameters/ShowStats" + }, + { + "$ref": "#/parameters/MultiLanguageInput" + } + ], + "responses": { + "200": { + "description": "A successful response results in 0 or more key phrases identified in each valid document", + "schema": { + "$ref": "#/definitions/KeyPhraseResult" + } + }, + "default": { + "description": "Error response.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Successful Key Phrase request": { + "$ref": ".//examples//SuccessfulKeyPhrasesRequest.json" + } + }, + "deprecated": false + } + }, + "/languages": { + "post": { + "summary": "Detect Language", + "description": "The API returns the detected language and a numeric score between 0 and 1. Scores close to 1 indicate 100% certainty that the identified language is true. See the Supported languages in Text Analytics API for the list of enabled languages.", + "operationId": "Languages", + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ModelVersion" + }, + { + "$ref": "#/parameters/ShowStats" + }, + { + "$ref": "#/parameters/LanguageInput" + } + ], + "responses": { + "200": { + "description": "A successful call results in the detected language with the highest probability for each valid document", + "schema": { + "$ref": "#/definitions/LanguageResult" + } + }, + "default": { + "description": "Error response.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Successful Detect Language request": { + "$ref": ".//examples//SuccessfulLanguagesRequest.json" + } + }, + "deprecated": false + } + }, + "/sentiment": { + "post": { + "summary": "Sentiment", + "description": "The API returns a detailed sentiment analysis for the input text. The analysis is done in multiple levels of granularity, start from the a document level, down to sentence and key terms (aspects) and opinions.", + "operationId": "Sentiment", + "consumes": [ + "application/json", + "text/json" + ], + "produces": [ + "application/json", + "text/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ModelVersion" + }, + { + "$ref": "#/parameters/ShowStats" + }, + { + "name": "opinionMining", + "in": "query", + "description": "(Optional) if set to true, response will contain input and document level statistics including aspect-based sentiment analysis results.", + "type": "boolean" + }, + { + "$ref": "#/parameters/StringIndexType" + }, + { + "$ref": "#/parameters/MultiLanguageInput" + } + ], + "responses": { + "200": { + "description": "A successful call results in a document sentiment prediction, as well as sentiment scores for each sentiment class (Positive, Negative, and Neutral)", + "schema": { + "$ref": "#/definitions/SentimentResponse" + } + }, + "default": { + "description": "Error response.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Successful Sentiment request": { + "$ref": ".//examples//SuccessfulSentimentRequest.json" + } + }, + "deprecated": false + } + } + }, + "definitions": { + "JobManifest": { + "properties": { + "tasks": { + "description": "The set of tasks to execute on the input documents. Cannot specify the same task more than once.", + "properties": { + "entityRecognitionTasks": { + "type": "array", + "items": { + "$ref": "#/definitions/EntitiesTask" + } + }, + "entityRecognitionPiiTasks": { + "type": "array", + "items": { + "$ref": "#/definitions/PiiTask" + } + }, + "entityLinkingTasks": { + "type": "array", + "items": { + "$ref": "#/definitions/EntityLinkingTask" + } + }, + "keyPhraseExtractionTasks": { + "type": "array", + "items": { + "$ref": "#/definitions/KeyPhrasesTask" + } + }, + "sentimentAnalysisTasks": { + "type": "array", + "items": { + "$ref": "#/definitions/SentimentTask" + } + }, + "customClassificationTasks": { + "type": "array", + "items": { + "$ref": "#/definitions/CustomClassificationTask" + } + }, + "customEntityRecognitionTasks": { + "type": "array", + "items": { + "$ref": "#/definitions/CustomEntitiesTask" + } + } + }, + "type": "object" + } + }, + "required": [ + "tasks" + ], + "type": "object" + }, + "MultiLanguageBatchInput": { + "type": "object", + "required": [ + "documents" + ], + "properties": { + "documents": { + "type": "array", + "description": "The set of documents to process as part of this batch.", + "items": { + "$ref": "#/definitions/MultiLanguageInput" + } + } + }, + "description": "Contains a set of input documents to be analyzed by the service." + }, + "MultiLanguageInput": { + "type": "object", + "required": [ + "id", + "text" + ], + "properties": { + "id": { + "type": "string", + "description": "A unique, non-empty document identifier." + }, + "text": { + "type": "string", + "description": "The input text to process." + }, + "language": { + "type": "string", + "description": "(Optional) This is the 2 letter ISO 639-1 representation of a language. For example, use \"en\" for English; \"es\" for Spanish etc. If not set, use \"en\" for English as default." + } + }, + "description": "Contains an input document to be analyzed by the service." + }, + "DocumentError": { + "type": "object", + "required": [ + "id", + "error" + ], + "properties": { + "id": { + "type": "string", + "description": "Document Id." + }, + "error": { + "type": "object", + "description": "Document Error.", + "$ref": "#/definitions/TextAnalyticsError" + } + } + }, + "ErrorResponse": { + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "object", + "description": "Document Error.", + "$ref": "#/definitions/TextAnalyticsError" + } + } + }, + "TextAnalyticsError": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "string", + "enum": [ + "InvalidRequest", + "InvalidArgument", + "InternalServerError", + "ServiceUnavailable", + "NotFound" + ], + "x-ms-enum": { + "name": "ErrorCodeValue", + "modelAsString": false + }, + "description": "Error code." + }, + "message": { + "type": "string", + "description": "Error message." + }, + "target": { + "type": "string", + "description": "Error target." + }, + "innererror": { + "$ref": "#/definitions/InnerError", + "description": "Inner error contains more specific information." + }, + "details": { + "type": "array", + "description": "Details about specific errors that led to this reported error.", + "items": { + "$ref": "#/definitions/TextAnalyticsError" + } + } + } + }, + "TextAnalyticsTask": { + "type": "object", + "required": [ + "enable" + ], + "properties": { + "enable": { + "default": false, + "type": "boolean" + } + } + }, + "TextAnalyticsWarning": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "string", + "enum": [ + "LongWordsInDocument", + "DocumentTruncated" + ], + "x-ms-enum": { + "name": "WarningCodeValue", + "modelAsString": true + }, + "description": "Error code." + }, + "message": { + "type": "string", + "description": "Warning message." + }, + "targetRef": { + "type": "string", + "description": "A JSON pointer reference indicating the target object." + } + } + }, + "PiiTask": { + "allOf": [ + { + "$ref": "#/definitions/TextAnalyticsTask" + }, + { + "properties": { + "parameters": { + "properties": { + "domain": { + "default": "none", + "enum": [ + "phi", + "none" + ], + "type": "string" + }, + "model-version": { + "default": "latest", + "type": "string" + }, + "stringIndexType": { + "$ref": "#/definitions/StringIndexType" + } + }, + "type": "object" + } + }, + "type": "object" + } + ] + }, + "EntitiesTask": { + "allOf": [ + { + "$ref": "#/definitions/TextAnalyticsTask" + }, + { + "properties": { + "parameters": { + "properties": { + "model-version": { + "default": "latest", + "type": "string" + }, + "stringIndexType": { + "$ref": "#/definitions/StringIndexType" + } + }, + "type": "object" + } + }, + "type": "object" + } + ] + }, + "InnerError": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "string", + "enum": [ + "InvalidParameterValue", + "InvalidRequestBodyFormat", + "EmptyRequest", + "MissingInputRecords", + "InvalidDocument", + "ModelVersionIncorrect", + "InvalidDocumentBatch", + "UnsupportedLanguageCode", + "InvalidCountryHint" + ], + "x-ms-enum": { + "name": "InnerErrorCodeValue", + "modelAsString": true + }, + "description": "Error code." + }, + "message": { + "type": "string", + "description": "Error message." + }, + "details": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Error details." + }, + "target": { + "type": "string", + "description": "Error target." + }, + "innererror": { + "$ref": "#/definitions/InnerError", + "description": "Inner error contains more specific information." + } + } + }, + "AnalyzeBatchInput": { + "allOf": [ + { + "$ref": "#/definitions/JobDescriptor" + }, + { + "type": "object", + "required": [ + "analysisInput" + ], + "properties": { + "analysisInput": { + "$ref": "#/definitions/MultiLanguageBatchInput" + } + } + }, + { + "$ref": "#/definitions/JobManifest" + } + ] + }, + "AnalyzeJobState": { + "allOf": [ + { + "$ref": "#/definitions/JobMetadata" + }, + { + "$ref": "#/definitions/TasksState" + }, + { + "properties": { + "errors": { + "items": { + "$ref": "#/definitions/TextAnalyticsError" + }, + "type": "array" + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + } + }, + "type": "object" + }, + { + "$ref": "#/definitions/Pagination" + } + ] + }, + "CustomClassification": { + "properties": { + "confidenceScore": { + "example": 0.87, + "format": "double", + "type": "number" + }, + "name": { + "example": "hotel booking", + "type": "string" + } + }, + "required": [ + "name", + "confidenceScore" + ], + "type": "object" + }, + "CustomClassificationResult": { + "properties": { + "documents": { + "description": "Response by document", + "items": { + "$ref": "#/definitions/CustomClassificationDocument" + }, + "type": "array" + }, + "errors": { + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + }, + "type": "array" + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + } + }, + "required": [ + "documents", + "errors" + ], + "type": "object" + }, + "CustomClassificationTask": { + "allOf": [ + { + "$ref": "#/definitions/TextAnalyticsTask" + }, + { + "properties": { + "parameters": { + "properties": { + "appId": { + "type": "string" + }, + "slotName": { + "type": "string" + } + }, + "required": [ + "appId", + "slotName" + ], + "type": "object" + } + }, + "required": [ + "parameters" + ], + "type": "object" + } + ] + }, + "CustomClassificationDocument": { + "type": "object", + "required": [ + "id", + "classifications" + ], + "properties": { + "id": { + "type": "string" + }, + "classifications": { + "items": { + "$ref": "#/definitions/CustomClassification" + }, + "type": "array" + } + } + }, + "CustomEntitiesDocument": { + "type": "object", + "required": [ + "id", + "entities" + ], + "properties": { + "id": { + "type": "string" + }, + "entities": { + "items": { + "$ref": "#/definitions/CustomEntity" + }, + "type": "array" + } + } + }, + "CustomEntitiesResult": { + "properties": { + "documents": { + "description": "Response by document", + "items": { + "$ref": "#/definitions/CustomEntitiesDocument" + }, + "type": "array" + }, + "errors": { + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + }, + "type": "array" + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + } + }, + "required": [ + "documents", + "errors" + ], + "type": "object" + }, + "CustomEntitiesTask": { + "allOf": [ + { + "$ref": "#/definitions/TextAnalyticsTask" + }, + { + "properties": { + "parameters": { + "properties": { + "appId": { + "type": "string" + }, + "slotName": { + "type": "string" + }, + "stringIndexType": { + "$ref": "#/definitions/StringIndexType" + } + }, + "required": [ + "appId", + "slotName" + ], + "type": "object" + } + }, + "required": [ + "parameters" + ], + "type": "object" + } + ] + }, + "CustomEntity": { + "allOf": [ + { + "$ref": "#/definitions/Entity" + }, + { + "type": "object", + "properties": { + "children": { + "example": [ + { + "category": "city", + "confidenceScore": 0.78, + "length": 3, + "offset": 5 + } + ], + "items": { + "$ref": "#/definitions/CustomEntity" + }, + "type": "array" + } + } + } + ] + }, + "SentimentResponse": { + "type": "object", + "required": [ + "documents", + "errors", + "modelVersion" + ], + "properties": { + "documents": { + "type": "array", + "description": "Sentiment analysis per document.", + "items": { + "$ref": "#/definitions/DocumentSentiment" + } + }, + "errors": { + "type": "array", + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + } + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + }, + "modelVersion": { + "type": "string", + "description": "This field indicates which model is used for scoring." + } + } + }, + "SentimentTask": { + "allOf": [ + { + "$ref": "#/definitions/TextAnalyticsTask" + }, + { + "properties": { + "parameters": { + "properties": { + "model-version": { + "default": "latest", + "type": "string" + }, + "opinionMining": { + "default": false, + "type": "boolean" + }, + "stringIndexType": { + "$ref": "#/definitions/StringIndexType" + } + }, + "type": "object" + } + }, + "type": "object" + } + ] + }, + "TaskState": { + "properties": { + "lastUpdateDateTime": { + "format": "date-time", + "type": "string" + }, + "name": { + "type": "string" + }, + "status": { + "enum": [ + "notstarted", + "running", + "succeeded", + "failed", + "cancelled", + "cancelling" + ], + "x-ms-enum": { + "modelAsString": false, + "name": "State" + } + } + }, + "required": [ + "name", + "status", + "lastUpdateDateTime" + ], + "type": "object" + }, + "TasksState": { + "properties": { + "tasks": { + "properties": { + "details": { + "items": { + "$ref": "#/definitions/TaskState" + }, + "type": "array" + }, + "completed": { + "type": "integer" + }, + "failed": { + "type": "integer" + }, + "inProgress": { + "type": "integer" + }, + "total": { + "type": "integer" + }, + "entityRecognitionTasks": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/TaskState" + }, + { + "type": "object", + "properties": { + "results": { + "$ref": "#/definitions/EntitiesResult" + } + } + } + ] + } + }, + "entityRecognitionPiiTasks": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/TaskState" + }, + { + "type": "object", + "properties": { + "results": { + "$ref": "#/definitions/PiiResult" + } + } + } + ] + } + }, + "entityLinkingTasks": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/TaskState" + }, + { + "type": "object", + "properties": { + "results": { + "$ref": "#/definitions/EntityLinkingResult" + } + } + } + ] + } + }, + "keyPhraseExtractionTasks": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/TaskState" + }, + { + "type": "object", + "properties": { + "results": { + "$ref": "#/definitions/KeyPhraseResult" + } + } + } + ] + } + }, + "sentimentAnalysisTasks": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/TaskState" + }, + { + "type": "object", + "properties": { + "results": { + "$ref": "#/definitions/SentimentResponse" + } + } + } + ] + } + }, + "customClassificationTasks": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/TaskState" + }, + { + "type": "object", + "properties": { + "results": { + "$ref": "#/definitions/CustomClassificationResult" + } + } + } + ] + } + }, + "customEntityRecognitionTasks": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/TaskState" + }, + { + "type": "object", + "properties": { + "results": { + "$ref": "#/definitions/CustomEntitiesResult" + } + } + } + ] + } + } + }, + "required": [ + "total", + "completed", + "failed", + "inProgress" + ], + "type": "object" + } + }, + "required": [ + "tasks" + ], + "type": "object" + }, + "DocumentSentiment": { + "type": "object", + "required": [ + "id", + "sentiment", + "confidenceScores", + "sentences", + "warnings" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "sentiment": { + "type": "string", + "description": "Predicted sentiment for document (Negative, Neutral, Positive, or Mixed).", + "enum": [ + "positive", + "neutral", + "negative", + "mixed" + ], + "x-ms-enum": { + "name": "DocumentSentimentValue", + "modelAsString": false + } + }, + "statistics": { + "$ref": "#/definitions/DocumentStatistics" + }, + "confidenceScores": { + "description": "Document level sentiment confidence scores between 0 and 1 for each sentiment class.", + "$ref": "#/definitions/SentimentConfidenceScorePerLabel" + }, + "sentences": { + "type": "array", + "description": "Sentence level sentiment analysis.", + "items": { + "$ref": "#/definitions/SentenceSentiment" + } + }, + "warnings": { + "type": "array", + "description": "Warnings encountered while processing document.", + "items": { + "$ref": "#/definitions/TextAnalyticsWarning" + } + } + } + }, + "RequestStatistics": { + "type": "object", + "required": [ + "documentsCount", + "validDocumentsCount", + "erroneousDocumentsCount", + "transactionsCount" + ], + "properties": { + "documentsCount": { + "type": "integer", + "format": "int32", + "description": "Number of documents submitted in the request." + }, + "validDocumentsCount": { + "type": "integer", + "format": "int32", + "description": "Number of valid documents. This excludes empty, over-size limit or non-supported languages documents." + }, + "erroneousDocumentsCount": { + "type": "integer", + "format": "int32", + "description": "Number of invalid documents. This includes empty, over-size limit or non-supported languages documents." + }, + "transactionsCount": { + "type": "integer", + "format": "int64", + "description": "Number of transactions for the request." + } + }, + "description": "if showStats=true was specified in the request this field will contain information about the request payload." + }, + "DocumentStatistics": { + "type": "object", + "required": [ + "charactersCount", + "transactionsCount" + ], + "properties": { + "charactersCount": { + "type": "integer", + "format": "int32", + "description": "Number of text elements recognized in the document." + }, + "transactionsCount": { + "type": "integer", + "format": "int32", + "description": "Number of transactions for the document." + } + }, + "description": "if showStats=true was specified in the request this field will contain information about the document payload." + }, + "SentimentConfidenceScorePerLabel": { + "type": "object", + "required": [ + "positive", + "neutral", + "negative" + ], + "properties": { + "positive": { + "type": "number", + "format": "double" + }, + "neutral": { + "type": "number", + "format": "double" + }, + "negative": { + "type": "number", + "format": "double" + } + }, + "description": "Represents the confidence scores between 0 and 1 across all sentiment classes: positive, neutral, negative." + }, + "SentenceSentiment": { + "type": "object", + "required": [ + "text", + "sentiment", + "confidenceScores", + "offset", + "length" + ], + "properties": { + "text": { + "type": "string", + "description": "The sentence text." + }, + "sentiment": { + "type": "string", + "description": "The predicted Sentiment for the sentence.", + "enum": [ + "positive", + "neutral", + "negative" + ], + "x-ms-enum": { + "name": "SentenceSentimentValue", + "modelAsString": false + } + }, + "confidenceScores": { + "description": "The sentiment confidence score between 0 and 1 for the sentence for all classes.", + "$ref": "#/definitions/SentimentConfidenceScorePerLabel" + }, + "offset": { + "type": "integer", + "format": "int32", + "description": "The sentence offset from the start of the document." + }, + "length": { + "type": "integer", + "format": "int32", + "description": "The length of the sentence." + }, + "aspects": { + "type": "array", + "description": "The array of aspect object for the sentence.", + "items": { + "$ref": "#/definitions/SentenceAspect" + } + }, + "opinions": { + "type": "array", + "description": "The array of opinion object for the sentence.", + "items": { + "$ref": "#/definitions/SentenceOpinion" + } + } + } + }, + "SentenceAspect": { + "type": "object", + "required": [ + "confidenceScores", + "length", + "offset", + "relations", + "sentiment", + "text" + ], + "properties": { + "sentiment": { + "type": "string", + "enum": [ + "positive", + "mixed", + "negative" + ], + "x-ms-enum": { + "name": "TokenSentimentValue", + "modelAsString": false + }, + "description": "Aspect level sentiment for the aspect in the sentence." + }, + "confidenceScores": { + "description": "Aspect level sentiment confidence scores for the aspect in the sentence.", + "$ref": "#/definitions/AspectConfidenceScoreLabel" + }, + "offset": { + "type": "integer", + "format": "int32", + "description": "The aspect offset from the start of the sentence." + }, + "length": { + "type": "integer", + "format": "int32", + "description": "The length of the aspect." + }, + "text": { + "type": "string", + "description": "The aspect text detected." + }, + "relations": { + "type": "array", + "description": "The array of either opinion or aspect object which is related to the aspect.", + "items": { + "$ref": "#/definitions/AspectRelation" + } + } + } + }, + "SentenceOpinion": { + "type": "object", + "required": [ + "confidenceScores", + "isNegated", + "length", + "offset", + "sentiment", + "text" + ], + "properties": { + "sentiment": { + "type": "string", + "enum": [ + "positive", + "mixed", + "negative" + ], + "x-ms-enum": { + "name": "TokenSentimentValue", + "modelAsString": false + }, + "description": "Opinion level sentiment for the aspect in the sentence." + }, + "confidenceScores": { + "description": "Opinion level sentiment confidence scores for the aspect in the sentence.", + "$ref": "#/definitions/AspectConfidenceScoreLabel" + }, + "offset": { + "type": "integer", + "format": "int32", + "description": "The opinion offset from the start of the sentence." + }, + "length": { + "type": "integer", + "format": "int32", + "description": "The length of the opinion." + }, + "text": { + "type": "string", + "description": "The aspect text detected." + }, + "isNegated": { + "type": "boolean", + "description": "The indicator representing if the opinion is negated." + } + } + }, + "AspectRelation": { + "type": "object", + "required": [ + "ref", + "relationType" + ], + "properties": { + "relationType": { + "type": "string", + "enum": [ + "opinion", + "aspect" + ], + "x-ms-enum": { + "name": "AspectRelationType", + "modelAsString": false + }, + "description": "The type related to the aspect." + }, + "ref": { + "type": "string", + "description": "The JSON pointer indicating the linked object." + } + } + }, + "AspectConfidenceScoreLabel": { + "type": "object", + "required": [ + "negative", + "positive" + ], + "properties": { + "positive": { + "type": "number", + "format": "double" + }, + "negative": { + "type": "number", + "format": "double" + } + }, + "description": "Represents the confidence scores across all sentiment classes: positive, neutral, negative." + }, + "EntitiesResult": { + "type": "object", + "required": [ + "documents", + "errors", + "modelVersion" + ], + "properties": { + "documents": { + "type": "array", + "description": "Response by document", + "items": { + "$ref": "#/definitions/DocumentEntities" + } + }, + "errors": { + "type": "array", + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + } + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + }, + "modelVersion": { + "type": "string", + "description": "This field indicates which model is used for scoring." + } + } + }, + "DocumentEntities": { + "type": "object", + "required": [ + "id", + "entities", + "warnings" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "entities": { + "type": "array", + "description": "Recognized entities in the document.", + "items": { + "$ref": "#/definitions/Entity" + } + }, + "warnings": { + "type": "array", + "description": "Warnings encountered while processing document.", + "items": { + "$ref": "#/definitions/TextAnalyticsWarning" + } + }, + "statistics": { + "description": "if showStats=true was specified in the request this field will contain information about the document payload.", + "$ref": "#/definitions/DocumentStatistics" + } + } + }, + "DocumentPiiEntities": { + "type": "object", + "required": [ + "id", + "entities", + "warnings" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "entities": { + "type": "array", + "description": "Recognized entities in the document.", + "items": { + "$ref": "#/definitions/PiiEntity" + } + }, + "warnings": { + "type": "array", + "description": "Warnings encountered while processing document.", + "items": { + "$ref": "#/definitions/TextAnalyticsWarning" + } + }, + "statistics": { + "description": "if showStats=true was specified in the request this field will contain information about the document payload.", + "$ref": "#/definitions/DocumentStatistics" + } + } + }, + "Entity": { + "type": "object", + "required": [ + "text", + "category", + "offset", + "length", + "confidenceScore" + ], + "properties": { + "text": { + "type": "string", + "description": "Entity text as appears in the request." + }, + "category": { + "type": "string", + "description": "Entity type." + }, + "subcategory": { + "type": "string", + "description": "(Optional) Entity sub type." + }, + "offset": { + "type": "integer", + "format": "int32", + "description": "Start position for the entity text. Use of different 'stringIndexType' values can affect the offset returned." + }, + "length": { + "type": "integer", + "format": "int32", + "description": "Length for the entity text. Use of different 'stringIndexType' values can affect the length returned." + }, + "confidenceScore": { + "type": "number", + "format": "double", + "description": "Confidence score between 0 and 1 of the extracted entity." + } + } + }, + "PiiEntity": { + "allOf": [ + { + "$ref": "#/definitions/Entity" + }, + { + "type": "object", + "required": [ + "redactedText" + ], + "properties": { + "redactedText": { + "type": "string" + } + } + } + ] + }, + "EntityLinkingResult": { + "type": "object", + "required": [ + "documents", + "errors", + "modelVersion" + ], + "properties": { + "documents": { + "type": "array", + "description": "Response by document", + "items": { + "$ref": "#/definitions/DocumentLinkedEntities" + } + }, + "errors": { + "type": "array", + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + } + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + }, + "modelVersion": { + "type": "string", + "description": "This field indicates which model is used for scoring." + } + } + }, + "DocumentLinkedEntities": { + "type": "object", + "required": [ + "id", + "entities", + "warnings" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "entities": { + "type": "array", + "description": "Recognized well-known entities in the document.", + "items": { + "$ref": "#/definitions/LinkedEntity" + } + }, + "warnings": { + "type": "array", + "description": "Warnings encountered while processing document.", + "items": { + "$ref": "#/definitions/TextAnalyticsWarning" + } + }, + "statistics": { + "description": "if showStats=true was specified in the request this field will contain information about the document payload.", + "$ref": "#/definitions/DocumentStatistics" + } + } + }, + "EntityLinkingTask": { + "allOf": [ + { + "$ref": "#/definitions/TextAnalyticsTask" + }, + { + "properties": { + "parameters": { + "properties": { + "model-version": { + "default": "latest", + "type": "string" + }, + "stringIndexType": { + "$ref": "#/definitions/StringIndexType" + } + }, + "type": "object" + } + }, + "type": "object" + } + ] + }, + "HealthcareJobState": { + "allOf": [ + { + "$ref": "#/definitions/JobMetadata" + }, + { + "properties": { + "results": { + "$ref": "#/definitions/HealthcareResult" + } + }, + "type": "object" + }, + { + "$ref": "#/definitions/Pagination" + } + ] + }, + "HealthcareResult": { + "type": "object", + "required": [ + "documents", + "errors", + "modelVersion" + ], + "properties": { + "documents": { + "type": "array", + "description": "Response by document", + "items": { + "$ref": "#/definitions/DocumentHealthcareEntities" + } + }, + "errors": { + "type": "array", + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + } + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + }, + "modelVersion": { + "type": "string", + "description": "This field indicates which model is used for scoring." + } + } + }, + "DocumentHealthcareEntities": { + "type": "object", + "required": [ + "id", + "entities", + "relations", + "warnings" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "entities": { + "description": "Healthcare entities.", + "type": "array", + "items": { + "$ref": "#/definitions/HealthcareEntity" + } + }, + "relations": { + "type": "array", + "description": "Healthcare entity relations.", + "items": { + "$ref": "#/definitions/HealthcareRelation" + } + }, + "warnings": { + "type": "array", + "description": "Warnings encountered while processing document.", + "items": { + "$ref": "#/definitions/TextAnalyticsWarning" + } + }, + "statistics": { + "description": "if showStats=true was specified in the request this field will contain information about the document payload.", + "$ref": "#/definitions/DocumentStatistics" + } + } + }, + "HealthcareEntity": { + "allOf": [ + { + "$ref": "#/definitions/Entity" + }, + { + "required": [ + "isNegated" + ], + "properties": { + "isNegated": { + "type": "boolean" + }, + "links": { + "description": "Entity references in known data sources.", + "type": "array", + "items": { + "$ref": "#/definitions/HealthcareEntityLink" + } + } + } + } + ] + }, + "HealthcareRelation": { + "type": "object", + "required": [ + "relationType", + "bidirectional", + "source", + "target" + ], + "properties": { + "relationType": { + "description": "Type of relation. Examples include: `DosageOfMedication` or 'FrequencyOfMedication', etc.", + "type": "string" + }, + "bidirectional": { + "description": "If true the relation between the entities is bidirectional, otherwise directionality is source to target.", + "type": "boolean" + }, + "source": { + "description": "Reference link to the source entity.", + "type": "string" + }, + "target": { + "description": "Reference link to the target entity.", + "type": "string" + } + } + }, + "HealthcareEntityLink": { + "type": "object", + "required": [ + "dataSource", + "id" + ], + "properties": { + "dataSource": { + "description": "Entity Catalog. Examples include: UMLS, CHV, MSH, etc.", + "type": "string" + }, + "id": { + "description": "Entity id in the given source catalog.", + "type": "string" + } + } + }, + "LinkedEntity": { + "type": "object", + "required": [ + "name", + "matches", + "language", + "url", + "dataSource" + ], + "properties": { + "name": { + "type": "string", + "description": "Entity Linking formal name." + }, + "matches": { + "type": "array", + "description": "List of instances this entity appears in the text.", + "items": { + "$ref": "#/definitions/Match" + } + }, + "language": { + "type": "string", + "description": "Language used in the data source." + }, + "id": { + "type": "string", + "description": "Unique identifier of the recognized entity from the data source." + }, + "url": { + "type": "string", + "description": "URL for the entity's page from the data source." + }, + "dataSource": { + "type": "string", + "description": "Data source used to extract entity linking, such as Wiki/Bing etc." + } + } + }, + "Match": { + "type": "object", + "required": [ + "confidenceScore", + "text", + "offset", + "length" + ], + "properties": { + "confidenceScore": { + "type": "number", + "format": "double", + "description": "If a well-known item is recognized, a decimal number denoting the confidence level between 0 and 1 will be returned." + }, + "text": { + "type": "string", + "description": "Entity text as appears in the request." + }, + "offset": { + "type": "integer", + "format": "int32", + "description": "Start position for the entity match text." + }, + "length": { + "type": "integer", + "format": "int32", + "description": "Length for the entity match text." + } + } + }, + "JobDescriptor": { + "properties": { + "displayName": { + "description": "Optional display name for the analysis job.", + "type": "string" + } + }, + "type": "object" + }, + "JobMetadata": { + "properties": { + "createdDateTime": { + "format": "date-time", + "type": "string" + }, + "displayName": { + "type": "string" + }, + "expirationDateTime": { + "format": "date-time", + "type": "string" + }, + "jobId": { + "format": "uuid", + "type": "string" + }, + "lastUpdateDateTime": { + "format": "date-time", + "type": "string" + }, + "status": { + "enum": [ + "notstarted", + "running", + "succeeded", + "failed", + "cancelled", + "cancelling", + "partiallycompleted" + ], + "type": "string", + "x-ms-enum": { + "modelAsString": false, + "name": "State" + } + } + }, + "required": [ + "jobId", + "lastUpdateDateTime", + "createdDateTime", + "status" + ], + "type": "object" + }, + "KeyPhraseResult": { + "type": "object", + "required": [ + "documents", + "errors", + "modelVersion" + ], + "properties": { + "documents": { + "type": "array", + "description": "Response by document", + "items": { + "$ref": "#/definitions/DocumentKeyPhrases" + } + }, + "errors": { + "type": "array", + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + } + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + }, + "modelVersion": { + "type": "string", + "description": "This field indicates which model is used for scoring." + } + } + }, + "DocumentKeyPhrases": { + "type": "object", + "required": [ + "id", + "keyPhrases", + "warnings" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "keyPhrases": { + "type": "array", + "description": "A list of representative words or phrases. The number of key phrases returned is proportional to the number of words in the input document.", + "items": { + "type": "string" + } + }, + "warnings": { + "type": "array", + "description": "Warnings encountered while processing document.", + "items": { + "$ref": "#/definitions/TextAnalyticsWarning" + } + }, + "statistics": { + "description": "if showStats=true was specified in the request this field will contain information about the document payload.", + "$ref": "#/definitions/DocumentStatistics" + } + } + }, + "KeyPhrasesTask": { + "allOf": [ + { + "$ref": "#/definitions/TextAnalyticsTask" + }, + { + "properties": { + "parameters": { + "properties": { + "model-version": { + "default": "latest", + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + ] + }, + "LanguageBatchInput": { + "type": "object", + "required": [ + "documents" + ], + "properties": { + "documents": { + "type": "array", + "items": { + "$ref": "#/definitions/LanguageInput" + } + } + } + }, + "LanguageInput": { + "type": "object", + "required": [ + "id", + "text" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "text": { + "type": "string" + }, + "countryHint": { + "type": "string" + } + } + }, + "Pagination": { + "properties": { + "@nextLink": { + "type": "string" + } + }, + "type": "object" + }, + "PiiResult": { + "type": "object", + "required": [ + "documents", + "errors", + "modelVersion" + ], + "properties": { + "documents": { + "type": "array", + "description": "Response by document", + "items": { + "$ref": "#/definitions/DocumentPiiEntities" + } + }, + "errors": { + "type": "array", + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + } + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + }, + "modelVersion": { + "type": "string", + "description": "This field indicates which model is used for scoring." + } + } + }, + "LanguageResult": { + "type": "object", + "required": [ + "documents", + "errors", + "modelVersion" + ], + "properties": { + "documents": { + "type": "array", + "description": "Response by document", + "items": { + "$ref": "#/definitions/DocumentLanguage" + } + }, + "errors": { + "type": "array", + "description": "Errors by document id.", + "items": { + "$ref": "#/definitions/DocumentError" + } + }, + "statistics": { + "$ref": "#/definitions/RequestStatistics" + }, + "modelVersion": { + "type": "string", + "description": "This field indicates which model is used for scoring." + } + } + }, + "DocumentLanguage": { + "type": "object", + "required": [ + "id", + "detectedLanguage", + "warnings" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique, non-empty document identifier." + }, + "detectedLanguage": { + "description": "Detected Language.", + "$ref": "#/definitions/DetectedLanguage" + }, + "warnings": { + "type": "array", + "description": "Warnings encountered while processing document.", + "items": { + "$ref": "#/definitions/TextAnalyticsWarning" + } + }, + "statistics": { + "description": "if showStats=true was specified in the request this field will contain information about the document payload.", + "$ref": "#/definitions/DocumentStatistics" + } + } + }, + "DetectedLanguage": { + "type": "object", + "required": [ + "name", + "iso6391Name", + "confidenceScore" + ], + "properties": { + "name": { + "type": "string", + "description": "Long name of a detected language (e.g. English, French)." + }, + "iso6391Name": { + "type": "string", + "description": "A two letter representation of the detected language according to the ISO 639-1 standard (e.g. en, fr)." + }, + "confidenceScore": { + "type": "number", + "format": "double", + "description": "A confidence score between 0 and 1. Scores close to 1 indicate 100% certainty that the identified language is true." + } + } + }, + "StringIndexType": { + "default": "TextElements_v8", + "enum": [ + "TextElements_v8", + "UnicodeCodePoint", + "Utf16CodeUnit" + ], + "x-ms-enum": { + "name": "StringIndexType", + "modelAsString": false, + "values": [ + { + "value": "TextElements_v8", + "description": "Returned offset and length values will correspond to TextElements (Graphemes and Grapheme clusters) confirming to the Unicode 8.0.0 standard. Use this option if your application is written in .Net Framework or .Net Core and you will be using StringInfo." + }, + { + "value": "UnicodeCodePoint", + "description": "Returned offset and length values will correspond to Unicode code points. Use this option if your application is written in a language that support Unicode, for example Python." + }, + { + "value": "Utf16CodeUnit", + "description": "Returned offset and length values will correspond to UTF-16 code units. Use this option if your application is written in a language that support Unicode, for example Java, JavaScript." + } + ] + }, + "type": "string" + } + }, + "parameters": { + "Endpoint": { + "name": "Endpoint", + "description": "Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).", + "x-ms-parameter-location": "client", + "required": true, + "type": "string", + "in": "path", + "x-ms-skip-url-encoding": true + }, + "StringIndexType": { + "name": "stringIndexType", + "in": "query", + "type": "string", + "description": "(Optional) Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets", + "default": "TextElements_v8", + "enum": [ + "TextElements_v8", + "UnicodeCodePoint", + "Utf16CodeUnit" + ], + "x-ms-enum": { + "name": "StringIndexType", + "modelAsString": true, + "values": [ + { + "value": "TextElements_v8", + "description": "Returned offset and length values will correspond to TextElements (Graphemes and Grapheme clusters) confirming to the Unicode 8.0.0 standard. Use this option if your application is written in .Net Framework or .Net Core and you will be using StringInfo." + }, + { + "value": "UnicodeCodePoint", + "description": "Returned offset and length values will correspond to Unicode code points. Use this option if your application is written in a language that support Unicode, for example Python." + }, + { + "value": "Utf16CodeUnit", + "description": "Returned offset and length values will correspond to UTF-16 code units. Use this option if your application is written in a language that support Unicode, for example Java, JavaScript." + } + ] + }, + "x-ms-parameter-location": "method" + }, + "JobId": { + "description": "Job ID", + "format": "uuid", + "in": "path", + "name": "jobId", + "required": true, + "type": "string", + "x-ms-parameter-location": "method" + }, + "ShowStats": { + "name": "showStats", + "in": "query", + "description": "(Optional) if set to true, response will contain request and document level statistics.", + "type": "boolean", + "required": false, + "x-ms-parameter-location": "method" + }, + "ModelVersion": { + "name": "model-version", + "in": "query", + "description": "(Optional) This value indicates which model will be used for scoring. If a model-version is not specified, the API should default to the latest, non-preview version. ", + "type": "string", + "required": false, + "x-ms-parameter-location": "method" + }, + "MultiLanguageInput": { + "in": "body", + "name": "input", + "description": "Collection of documents to analyze.", + "required": true, + "schema": { + "$ref": "#/definitions/MultiLanguageBatchInput" + }, + "x-ms-parameter-location": "method" + }, + "LanguageInput": { + "in": "body", + "name": "input", + "description": "Collection of documents to analyze for language endpoint.", + "required": true, + "schema": { + "$ref": "#/definitions/LanguageBatchInput" + }, + "x-ms-parameter-location": "method" + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeHealthOperation.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeHealthOperation.cs new file mode 100644 index 000000000000..f1c042b1874d --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeHealthOperation.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.AI.TextAnalytics.Models; +using Azure.Core.TestFramework; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Diagnostics; + +namespace Azure.AI.TextAnalytics.Samples +{ + [LiveOnly] + public partial class TextAnalyticsSamples + { + [Test] + public async System.Threading.Tasks.Task AnalyzeHealthAsync() + { + string endpoint = TestEnvironment.Endpoint; + string apiKey = TestEnvironment.ApiKey; + + #region Snippet:TextAnalyticsSample2CreateClient + var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); + #endregion + + #region Snippet:AnalyzeHealth + + IEnumerable documents = new List() + { + new TextDocumentInput("1", "RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. The patient had a cardiac catheterization in July of this year revealing total occlusion of the RCA and 50% left main disease , with a strong family history of coronary artery disease with a brother dying at the age of 52 from a myocardial infarction and another brother who is status post coronary artery bypass grafting. The patient had a stress echocardiogram done on July , 2001 , which showed no wall motion abnormalities , but this was a difficult study due to body habitus. The patient went for six minutes with minimal ST depressions in the anterior lateral leads , thought due to fatigue and wrist pain , his anginal equivalent. Due to the patient's increased symptoms and family history and history left main disease with total occasional of his RCA was referred for revascularization with open heart surgery.") + }; + + AnalyzeHealthOperation operation = await client.StartAnalyzeHealthAsync(documents, new TextAnalyticsRequestOptions() { ModelVersion = "latest" }); + + Response response = await operation.WaitForCompletionAsync(); + + GetDiagnosis(response); + GetRelations(response); + + GetReport(response); + + #endregion + } + + private void GetReport(Response response) + { + IList results = response.Value.Documents; + Console.WriteLine("Health Report -"); + foreach (HealthcareResult result in results) + { + foreach (HealthcareEntity entity in result.Documents[0].Entities) + { + Console.WriteLine($"Text {entity.Text}"); + Console.WriteLine($"Category {entity.Category}"); + Console.WriteLine($"ConfidenceScore {entity.ConfidenceScore}"); + Console.WriteLine($"Offset {entity.Offset}"); + } + + foreach (HealthcareRelation relation in result.Documents[0].Relations) + { + Console.WriteLine($"Relation Type {relation.RelationType} with bidirectional as {relation.Bidirectional}."); + Console.WriteLine($"Source Entity Text {relation.SourceEntity.Text}."); + Console.WriteLine($"Source Entity Category {relation.SourceEntity.Category}."); + Console.WriteLine($"Source Entity Length {relation.SourceEntity.Length}."); + Console.WriteLine($"Target Entity {relation.TargetEntity.Text}."); + Console.WriteLine($"Target Entity Category {relation.TargetEntity.Category}."); + Console.WriteLine($"Target Entity Length {relation.TargetEntity.Length}."); + } + } + } + + private void GetDiagnosis(Response response) + { + IList results = response.Value.Documents; + Console.WriteLine("Diagnosis for the resport -"); + foreach (HealthcareResult result in results) + { + foreach (HealthcareEntity entities in result.Documents[0].Entities) + { + if (entities.Category == "Diagnosis") + { + Console.WriteLine(entities.Text); + } + } + } + } + + private void GetRelations(Response response) + { + IList results = response.Value.Documents; + + foreach (HealthcareResult result in results) + { + foreach (HealthcareRelation relation in result.Documents[0].Relations) + { + Console.WriteLine($"Relation Type {relation.RelationType} with bidirectional as {relation.Bidirectional}."); + + Console.WriteLine($"Source Entity: {relation.SourceEntity.Text} is related to Target Entity: {relation.TargetEntity.Text}."); + } + } + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperation.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperation.cs new file mode 100644 index 000000000000..374392358da7 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperation.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Azure.AI.TextAnalytics.Samples +{ + [LiveOnly] + public partial class TextAnalyticsSamples + { + [Test] + public void AnalyzeOperation() + { + Environment.SetEnvironmentVariable("CLIENT_ID", ""); + Environment.SetEnvironmentVariable("TENANT_ID", ""); + Environment.SetEnvironmentVariable("CLIENT_SECRET", ""); + + string endpoint = "https://cognitiveusw2dev.azure-api.net"; + string apiKey = ".."; + + #region Snippet:TextAnalyticsSample2CreateClient + var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); + #endregion + + #region Snippet:AnalyzeOperation + + IEnumerable documents = new List() + { + new TextDocumentInput("1", "Hello there!") + }; + + + AnalyzeOperation operation = client.StartAnalyzeOperation(documents, new TextAnalyticsRequestOptions() { ModelVersion = "latest" }); + + operation.WaitForCompletionAsync().ConfigureAwait(false); + + #endregion + } + + [Test] + public async Task AnalyzeOperationAsync() + { + Environment.SetEnvironmentVariable("CLIENT_ID", ""); + Environment.SetEnvironmentVariable("TENANT_ID", ""); + Environment.SetEnvironmentVariable("CLIENT_SECRET", ""); + + string endpoint = "https://cognitiveusw2dev.azure-api.net"; + string apiKey = ".."; + + #region Snippet:TextAnalyticsSample2CreateClient + var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); + #endregion + + #region Snippet:AnalyzeOperation + + IEnumerable documents = new List() + { + new TextDocumentInput("1", "Hello there!") + }; + + + AnalyzeOperation operation = await client.StartAnalyzeOperationAsync(documents, new TextAnalyticsRequestOptions() { ModelVersion = "latest" }); + + Response response = await operation.WaitForCompletionAsync(); + + Console.WriteLine("Here", response); + #endregion + } + } +}