Skip to content

Commit d79ed17

Browse files
authored
[TA] Hide StringIndexType (Azure#21618)
1 parent 65cbea8 commit d79ed17

17 files changed

+43
-330
lines changed

sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- Changed type `RecognizePiiEntitiesOptions.DomainFilter` from `PiiEntityDomainType?` to `PiiEntityDomainType`.
2222
- Changed type `AnalyzeActionsOptions.IncludeStatistics` from `bool` to `bool?`.
2323
- Removed property `Statistics` from `AnalyzeActionsResult` as it is not currently returned by the service even if the user passes `IncludeStatistics = true`.
24+
- Removed property `StringIndexType` from `TextAnalyticsRequestOptions`. This SDK will keep using `UTF-16` code unit as the default encoding.
2425

2526
## 5.1.0-beta.7 (2021-05-18)
2627
### New features

sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -664,25 +664,6 @@ internal SentimentConfidenceScores() { }
664664
public double Positive { get { throw null; } }
665665
}
666666
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
667-
public readonly partial struct StringIndexType : System.IEquatable<Azure.AI.TextAnalytics.StringIndexType>
668-
{
669-
private readonly object _dummy;
670-
private readonly int _dummyPrimitive;
671-
public StringIndexType(string value) { throw null; }
672-
public static Azure.AI.TextAnalytics.StringIndexType TextElementV8 { get { throw null; } }
673-
public static Azure.AI.TextAnalytics.StringIndexType UnicodeCodePoint { get { throw null; } }
674-
public static Azure.AI.TextAnalytics.StringIndexType Utf16CodeUnit { get { throw null; } }
675-
public bool Equals(Azure.AI.TextAnalytics.StringIndexType other) { throw null; }
676-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
677-
public override bool Equals(object obj) { throw null; }
678-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
679-
public override int GetHashCode() { throw null; }
680-
public static bool operator ==(Azure.AI.TextAnalytics.StringIndexType left, Azure.AI.TextAnalytics.StringIndexType right) { throw null; }
681-
public static implicit operator Azure.AI.TextAnalytics.StringIndexType (string value) { throw null; }
682-
public static bool operator !=(Azure.AI.TextAnalytics.StringIndexType left, Azure.AI.TextAnalytics.StringIndexType right) { throw null; }
683-
public override string ToString() { throw null; }
684-
}
685-
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
686667
public readonly partial struct TargetSentiment
687668
{
688669
private readonly object _dummy;
@@ -955,7 +936,6 @@ public TextAnalyticsRequestOptions() { }
955936
public bool? DisableServiceLogs { get { throw null; } set { } }
956937
public bool IncludeStatistics { get { throw null; } set { } }
957938
public string ModelVersion { get { throw null; } set { } }
958-
public Azure.AI.TextAnalytics.StringIndexType StringIndexType { get { throw null; } set { } }
959939
}
960940
public partial class TextAnalyticsResult
961941
{
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using Azure.AI.TextAnalytics.Models;
5+
6+
namespace Azure.AI.TextAnalytics
7+
{
8+
internal static class Constants
9+
{
10+
public static readonly StringIndexType DefaultStringIndexType = StringIndexType.Utf16CodeUnit;
11+
public const string DefaultCognitiveScope = "https://cognitiveservices.azure.com/.default";
12+
public const string AuthorizationHeader = "Ocp-Apim-Subscription-Key";
13+
}
14+
}

sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntitiesTaskParameters.cs

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityLinkingTaskParameters.cs

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/SentimentAnalysisTaskParameters.cs

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/StringIndexType.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/textanalytics/Azure.AI.TextAnalytics/src/StringIndexType.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
using Azure.Core;
55

6-
namespace Azure.AI.TextAnalytics
6+
namespace Azure.AI.TextAnalytics.Models
77
{
88
[CodeGenModel("StringIndexType")]
9-
public readonly partial struct StringIndexType
9+
internal readonly partial struct StringIndexType
1010
{
1111
}
1212
}

sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ public class TextAnalyticsClient
2222
internal readonly TextAnalyticsRestClient _serviceRestClient;
2323
internal readonly ClientDiagnostics _clientDiagnostics;
2424
private readonly TextAnalyticsClientOptions _options;
25-
private readonly string DefaultCognitiveScope = "https://cognitiveservices.azure.com/.default";
26-
private const string AuthorizationHeader = "Ocp-Apim-Subscription-Key";
2725

2826
/// <summary>
2927
/// Protected constructor to allow mocking.
@@ -65,7 +63,7 @@ public TextAnalyticsClient(Uri endpoint, TokenCredential credential, TextAnalyti
6563
_clientDiagnostics = new TextAnalyticsClientDiagnostics(options);
6664
_options = options;
6765

68-
var pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, DefaultCognitiveScope));
66+
var pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, Constants.DefaultCognitiveScope));
6967
_serviceRestClient = new TextAnalyticsRestClient(_clientDiagnostics, pipeline, endpoint.AbsoluteUri, TextAnalyticsClientOptions.GetVersionString(options.Version));
7068
}
7169

@@ -104,7 +102,7 @@ public TextAnalyticsClient(Uri endpoint, AzureKeyCredential credential, TextAnal
104102
_clientDiagnostics = new TextAnalyticsClientDiagnostics(options);
105103
_options = options;
106104

107-
var pipeline = HttpPipelineBuilder.Build(options, new AzureKeyCredentialPolicy(credential, AuthorizationHeader));
105+
var pipeline = HttpPipelineBuilder.Build(options, new AzureKeyCredentialPolicy(credential, Constants.AuthorizationHeader));
108106
_serviceRestClient = new TextAnalyticsRestClient(_clientDiagnostics, pipeline, endpoint.AbsoluteUri, TextAnalyticsClientOptions.GetVersionString(options.Version));
109107
}
110108

@@ -433,7 +431,7 @@ public virtual async Task<Response<CategorizedEntityCollection>> RecognizeEntiti
433431

434432
Response<EntitiesResult> result = await _serviceRestClient.EntitiesRecognitionGeneralAsync(
435433
new MultiLanguageBatchInput(documents),
436-
stringIndexType: StringIndexType.Utf16CodeUnit,
434+
stringIndexType: Constants.DefaultStringIndexType,
437435
cancellationToken: cancellationToken).ConfigureAwait(false);
438436
Response response = result.GetRawResponse();
439437

@@ -491,7 +489,7 @@ public virtual Response<CategorizedEntityCollection> RecognizeEntities(string do
491489

492490
Response<EntitiesResult> result = _serviceRestClient.EntitiesRecognitionGeneral(
493491
new MultiLanguageBatchInput(documents),
494-
stringIndexType: StringIndexType.Utf16CodeUnit,
492+
stringIndexType: Constants.DefaultStringIndexType,
495493
cancellationToken: cancellationToken);
496494
Response response = result.GetRawResponse();
497495

@@ -819,7 +817,7 @@ private async Task<Response<RecognizeEntitiesResultCollection>> RecognizeEntitie
819817
options.ModelVersion,
820818
options.IncludeStatistics,
821819
options.DisableServiceLogs,
822-
options.StringIndexType,
820+
Constants.DefaultStringIndexType,
823821
cancellationToken).ConfigureAwait(false);
824822
var response = result.GetRawResponse();
825823

@@ -846,7 +844,7 @@ private Response<RecognizeEntitiesResultCollection> RecognizeEntitiesBatch(Multi
846844
options.ModelVersion,
847845
options.IncludeStatistics,
848846
options.DisableServiceLogs,
849-
options.StringIndexType,
847+
Constants.DefaultStringIndexType,
850848
cancellationToken);
851849
var response = result.GetRawResponse();
852850

@@ -914,7 +912,7 @@ public virtual async Task<Response<PiiEntityCollection>> RecognizePiiEntitiesAsy
914912
options.IncludeStatistics,
915913
options.DisableServiceLogs,
916914
options.DomainFilter.GetString(),
917-
options.StringIndexType,
915+
Constants.DefaultStringIndexType,
918916
options.CategoriesFilter.Count == 0 ? null : options.CategoriesFilter,
919917
cancellationToken: cancellationToken).ConfigureAwait(false);
920918
Response response = result.GetRawResponse();
@@ -984,7 +982,7 @@ public virtual Response<PiiEntityCollection> RecognizePiiEntities(string documen
984982
options.IncludeStatistics,
985983
options.DisableServiceLogs,
986984
options.DomainFilter.GetString(),
987-
options.StringIndexType,
985+
Constants.DefaultStringIndexType,
988986
options.CategoriesFilter.Count == 0 ? null : options.CategoriesFilter,
989987
cancellationToken: cancellationToken);
990988
Response response = result.GetRawResponse();
@@ -1164,7 +1162,7 @@ private async Task<Response<RecognizePiiEntitiesResultCollection>> RecognizePiiE
11641162
options.IncludeStatistics,
11651163
options.DisableServiceLogs,
11661164
options.DomainFilter.GetString(),
1167-
options.StringIndexType,
1165+
Constants.DefaultStringIndexType,
11681166
options.CategoriesFilter.Count == 0 ? null : options.CategoriesFilter,
11691167
cancellationToken).ConfigureAwait(false);
11701168
var response = result.GetRawResponse();
@@ -1193,7 +1191,7 @@ private Response<RecognizePiiEntitiesResultCollection> RecognizePiiEntitiesBatch
11931191
options.IncludeStatistics,
11941192
options.DisableServiceLogs,
11951193
options.DomainFilter.GetString(),
1196-
options.StringIndexType,
1194+
Constants.DefaultStringIndexType,
11971195
options.CategoriesFilter.Count == 0 ? null : options.CategoriesFilter,
11981196
cancellationToken);
11991197
var response = result.GetRawResponse();
@@ -1309,7 +1307,7 @@ public virtual async Task<Response<DocumentSentiment>> AnalyzeSentimentAsync(str
13091307
options.IncludeStatistics,
13101308
options.DisableServiceLogs,
13111309
options.IncludeOpinionMining,
1312-
options.StringIndexType,
1310+
Constants.DefaultStringIndexType,
13131311
cancellationToken).ConfigureAwait(false);
13141312
Response response = result.GetRawResponse();
13151313

@@ -1370,7 +1368,7 @@ public virtual Response<DocumentSentiment> AnalyzeSentiment(string document, str
13701368
options.IncludeStatistics,
13711369
options.DisableServiceLogs,
13721370
options.IncludeOpinionMining,
1373-
options.StringIndexType,
1371+
Constants.DefaultStringIndexType,
13741372
cancellationToken);
13751373
Response response = result.GetRawResponse();
13761374

@@ -1647,7 +1645,7 @@ private async Task<Response<AnalyzeSentimentResultCollection>> AnalyzeSentimentB
16471645
options.IncludeStatistics,
16481646
options.DisableServiceLogs,
16491647
options.IncludeOpinionMining,
1650-
options.StringIndexType,
1648+
Constants.DefaultStringIndexType,
16511649
cancellationToken).ConfigureAwait(false);
16521650
var response = result.GetRawResponse();
16531651

@@ -1675,7 +1673,7 @@ private Response<AnalyzeSentimentResultCollection> AnalyzeSentimentBatch(MultiLa
16751673
options.IncludeStatistics,
16761674
options.DisableServiceLogs,
16771675
options.IncludeOpinionMining,
1678-
options.StringIndexType,
1676+
Constants.DefaultStringIndexType,
16791677
cancellationToken);
16801678
var response = result.GetRawResponse();
16811679

@@ -2178,7 +2176,7 @@ public virtual async Task<Response<LinkedEntityCollection>> RecognizeLinkedEntit
21782176

21792177
Response<EntityLinkingResult> result = await _serviceRestClient.EntitiesLinkingAsync(
21802178
new MultiLanguageBatchInput(documents),
2181-
stringIndexType: StringIndexType.Utf16CodeUnit,
2179+
stringIndexType: Constants.DefaultStringIndexType,
21822180
cancellationToken: cancellationToken).ConfigureAwait(false);
21832181
Response response = result.GetRawResponse();
21842182

@@ -2234,7 +2232,7 @@ public virtual Response<LinkedEntityCollection> RecognizeLinkedEntities(string d
22342232

22352233
Response<EntityLinkingResult> result = _serviceRestClient.EntitiesLinking(
22362234
new MultiLanguageBatchInput(documents),
2237-
stringIndexType: StringIndexType.Utf16CodeUnit,
2235+
stringIndexType: Constants.DefaultStringIndexType,
22382236
cancellationToken: cancellationToken);
22392237
Response response = result.GetRawResponse();
22402238

@@ -2542,7 +2540,7 @@ private async Task<Response<RecognizeLinkedEntitiesResultCollection>> RecognizeL
25422540
options.ModelVersion,
25432541
options.IncludeStatistics,
25442542
options.DisableServiceLogs,
2545-
options.StringIndexType,
2543+
Constants.DefaultStringIndexType,
25462544
cancellationToken).ConfigureAwait(false);
25472545
var response = result.GetRawResponse();
25482546

@@ -2568,7 +2566,7 @@ private Response<RecognizeLinkedEntitiesResultCollection> RecognizeLinkedEntitie
25682566
options.ModelVersion,
25692567
options.IncludeStatistics,
25702568
options.DisableServiceLogs,
2571-
options.StringIndexType,
2569+
Constants.DefaultStringIndexType,
25722570
cancellationToken);
25732571
var response = result.GetRawResponse();
25742572

@@ -2738,7 +2736,7 @@ private AnalyzeHealthcareEntitiesOperation StartAnalyzeHealthcareEntities(MultiL
27382736
ResponseWithHeaders<TextAnalyticsHealthHeaders> response = _serviceRestClient.Health(
27392737
batchInput,
27402738
options.ModelVersion,
2741-
options.StringIndexType,
2739+
Constants.DefaultStringIndexType,
27422740
options.DisableServiceLogs,
27432741
cancellationToken);
27442742
string location = response.Headers.OperationLocation;
@@ -2766,7 +2764,7 @@ private async Task<AnalyzeHealthcareEntitiesOperation> StartAnalyzeHealthcareEnt
27662764
ResponseWithHeaders<TextAnalyticsHealthHeaders> response = await _serviceRestClient.HealthAsync(
27672765
batchInput,
27682766
options.ModelVersion,
2769-
options.StringIndexType,
2767+
Constants.DefaultStringIndexType,
27702768
options.DisableServiceLogs,
27712769
cancellationToken).ConfigureAwait(false);
27722770
string location = response.Headers.OperationLocation;

sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsRequestOptions.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ internal TextAnalyticsRequestOptions(bool includeStatistics, string modelVersion
4242
/// </summary>
4343
public string ModelVersion { get; set; }
4444

45-
/// <summary>
46-
/// Specifies the method used to interpret string offsets. Defaults to
47-
/// <see cref="StringIndexType.Utf16CodeUnit"/>.
48-
/// </summary>
49-
public StringIndexType StringIndexType { get; set; } = StringIndexType.Utf16CodeUnit;
50-
5145
/// <summary>
5246
/// The default value of this property is 'false', except for methods like 'StartAnalyzeHealthcareEntities' and 'RecognizePiiEntities'.
5347
/// This means, Text Analytics service logs your input text for 48 hours, solely to allow for troubleshooting issues.

0 commit comments

Comments
 (0)