forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TextAnalytics API Refactoring (Azure#8905)
* move errors to document result * api updates per feedback * Remove interface * Include Statistics * updates per API feedback * shift to result collections * TextAnalysisOptions * reenable recognize entity single * reenable recognize entity batch * reenable key phrases * reenable remaining * API feedback * bug fix * pr feedback * pr feedback
- Loading branch information
1 parent
9c11f73
commit 24a8f2e
Showing
50 changed files
with
1,254 additions
and
1,396 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
sdk/cognitiveservices/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeSentimentResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Azure.AI.TextAnalytics | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
public class AnalyzeSentimentResult : TextAnalysisResult | ||
{ | ||
internal AnalyzeSentimentResult(string id, TextDocumentStatistics statistics, TextSentiment documentSentiment, IList<TextSentiment> sentenceSentiments) | ||
: base(id, statistics) | ||
{ | ||
DocumentSentiment = documentSentiment; | ||
SentenceSentiments = new ReadOnlyCollection<TextSentiment>(sentenceSentiments); | ||
} | ||
|
||
internal AnalyzeSentimentResult(string id, string errorMessage) | ||
: base(id, errorMessage) | ||
{ | ||
} | ||
|
||
// TODO: set DocumentSentiment.Length | ||
/// <summary> | ||
/// </summary> | ||
public TextSentiment DocumentSentiment { get; } | ||
|
||
/// <summary> | ||
/// </summary> | ||
public IReadOnlyCollection<TextSentiment> SentenceSentiments { get; } | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...tiveservices/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeSentimentResultCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Azure.AI.TextAnalytics | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
public class AnalyzeSentimentResultCollection : ReadOnlyCollection<AnalyzeSentimentResult> | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
/// <param name="list"></param> | ||
/// <param name="statistics"></param> | ||
/// <param name="modelVersion"></param> | ||
internal AnalyzeSentimentResultCollection(IList<AnalyzeSentimentResult> list, TextBatchStatistics statistics, string modelVersion) : base(list) | ||
{ | ||
Statistics = statistics; | ||
ModelVersion = modelVersion; | ||
} | ||
|
||
/// <summary> | ||
/// </summary> | ||
public TextBatchStatistics Statistics { get; } | ||
|
||
/// <summary> | ||
/// </summary> | ||
public string ModelVersion { get; } | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
sdk/cognitiveservices/textanalytics/Azure.AI.TextAnalytics/src/DetectLanguageResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
|
||
namespace Azure.AI.TextAnalytics | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
public class DetectLanguageResult : TextAnalysisResult | ||
{ | ||
internal DetectLanguageResult(string id, TextDocumentStatistics statistics, IList<DetectedLanguage> detectedLanguages) | ||
: base(id, statistics) | ||
{ | ||
DetectedLanguages = new ReadOnlyCollection<DetectedLanguage>(detectedLanguages); | ||
} | ||
|
||
internal DetectLanguageResult(string id, string errorMessage) | ||
: base(id, errorMessage) | ||
{ | ||
DetectedLanguages = new ReadOnlyCollection<DetectedLanguage>(new List<DetectedLanguage>()); | ||
} | ||
|
||
/// <summary> | ||
/// </summary> | ||
public IReadOnlyCollection<DetectedLanguage> DetectedLanguages { get; } | ||
|
||
/// <summary> | ||
/// </summary> | ||
public DetectedLanguage PrimaryLanguage => DetectedLanguages.OrderBy(l => l.Score).FirstOrDefault(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...nitiveservices/textanalytics/Azure.AI.TextAnalytics/src/DetectLanguageResultCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Azure.AI.TextAnalytics | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
public class DetectLanguageResultCollection : ReadOnlyCollection<DetectLanguageResult> | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
/// <param name="list"></param> | ||
/// <param name="statistics"></param> | ||
/// <param name="modelVersion"></param> | ||
internal DetectLanguageResultCollection(IList<DetectLanguageResult> list, TextBatchStatistics statistics, string modelVersion) : base(list) | ||
{ | ||
Statistics = statistics; | ||
ModelVersion = modelVersion; | ||
} | ||
|
||
/// <summary> | ||
/// </summary> | ||
public TextBatchStatistics Statistics { get; } | ||
|
||
/// <summary> | ||
/// </summary> | ||
public string ModelVersion { get; } | ||
} | ||
} |
26 changes: 0 additions & 26 deletions
26
sdk/cognitiveservices/textanalytics/Azure.AI.TextAnalytics/src/DocumentError.cs
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
...cognitiveservices/textanalytics/Azure.AI.TextAnalytics/src/DocumentResultCollection{T}.cs
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
sdk/cognitiveservices/textanalytics/Azure.AI.TextAnalytics/src/ExtractKeyPhrasesResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Azure.AI.TextAnalytics | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
public class ExtractKeyPhrasesResult : TextAnalysisResult | ||
{ | ||
internal ExtractKeyPhrasesResult(string id, TextDocumentStatistics statistics, IList<string> keyPhrases) | ||
: base(id, statistics) | ||
{ | ||
KeyPhrases = new ReadOnlyCollection<string>(keyPhrases); | ||
} | ||
|
||
internal ExtractKeyPhrasesResult(string id, string errorMessage) | ||
: base(id, errorMessage) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// </summary> | ||
public IReadOnlyCollection<string> KeyPhrases { get; } | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...iveservices/textanalytics/Azure.AI.TextAnalytics/src/ExtractKeyPhrasesResultCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Azure.AI.TextAnalytics | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
public class ExtractKeyPhrasesResultCollection : ReadOnlyCollection<ExtractKeyPhrasesResult> | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
/// <param name="list"></param> | ||
/// <param name="statistics"></param> | ||
/// <param name="modelVersion"></param> | ||
internal ExtractKeyPhrasesResultCollection(IList<ExtractKeyPhrasesResult> list, TextBatchStatistics statistics, string modelVersion) : base(list) | ||
{ | ||
Statistics = statistics; | ||
ModelVersion = modelVersion; | ||
} | ||
|
||
/// <summary> | ||
/// </summary> | ||
public TextBatchStatistics Statistics { get; } | ||
|
||
/// <summary> | ||
/// </summary> | ||
public string ModelVersion { get; } | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...cognitiveservices/textanalytics/Azure.AI.TextAnalytics/src/ExtractLinkedEntitiesResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Azure.AI.TextAnalytics | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
public class ExtractLinkedEntitiesResult : TextAnalysisResult | ||
{ | ||
internal ExtractLinkedEntitiesResult(string id, TextDocumentStatistics statistics, IList<LinkedEntity> linkedEntities) | ||
: base(id, statistics) | ||
{ | ||
LinkedEntities = new ReadOnlyCollection<LinkedEntity>(linkedEntities); | ||
} | ||
|
||
internal ExtractLinkedEntitiesResult(string id, string errorMessage) | ||
: base(id, errorMessage) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// </summary> | ||
public IReadOnlyCollection<LinkedEntity> LinkedEntities { get; } | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...ervices/textanalytics/Azure.AI.TextAnalytics/src/ExtractLinkedEntitiesResultCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Azure.AI.TextAnalytics | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
public class ExtractLinkedEntitiesResultCollection : ReadOnlyCollection<ExtractLinkedEntitiesResult> | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
/// <param name="list"></param> | ||
/// <param name="statistics"></param> | ||
/// <param name="modelVersion"></param> | ||
internal ExtractLinkedEntitiesResultCollection(IList<ExtractLinkedEntitiesResult> list, TextBatchStatistics statistics, string modelVersion) : base(list) | ||
{ | ||
Statistics = statistics; | ||
ModelVersion = modelVersion; | ||
} | ||
|
||
/// <summary> | ||
/// </summary> | ||
public TextBatchStatistics Statistics { get; } | ||
|
||
/// <summary> | ||
/// </summary> | ||
public string ModelVersion { get; } | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
sdk/cognitiveservices/textanalytics/Azure.AI.TextAnalytics/src/RecognizeEntitiesResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Azure.AI.TextAnalytics | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
public class RecognizeEntitiesResult : TextAnalysisResult | ||
{ | ||
internal RecognizeEntitiesResult(string id, TextDocumentStatistics statistics, IList<NamedEntity> entities) | ||
: base(id, statistics) | ||
{ | ||
NamedEntities = new ReadOnlyCollection<NamedEntity>(entities); | ||
} | ||
|
||
internal RecognizeEntitiesResult(string id, string errorMessage) | ||
: base(id, errorMessage) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// </summary> | ||
public IReadOnlyCollection<NamedEntity> NamedEntities { get; } | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...iveservices/textanalytics/Azure.AI.TextAnalytics/src/RecognizeEntitiesResultCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Azure.AI.TextAnalytics | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
public class RecognizeEntitiesResultCollection : ReadOnlyCollection<RecognizeEntitiesResult> | ||
{ | ||
/// <summary> | ||
/// </summary> | ||
/// <param name="list"></param> | ||
/// <param name="statistics"></param> | ||
/// <param name="modelVersion"></param> | ||
internal RecognizeEntitiesResultCollection(IList<RecognizeEntitiesResult> list, TextBatchStatistics statistics, string modelVersion) : base(list) | ||
{ | ||
Statistics = statistics; | ||
ModelVersion = modelVersion; | ||
} | ||
|
||
/// <summary> | ||
/// </summary> | ||
public TextBatchStatistics Statistics { get; } | ||
|
||
/// <summary> | ||
/// </summary> | ||
public string ModelVersion { get; } | ||
} | ||
} |
Oops, something went wrong.