Skip to content

Commit

Permalink
TextAnalytics API Refactoring (Azure#8905)
Browse files Browse the repository at this point in the history
* 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
annelo-msft authored Dec 5, 2019
1 parent 9c11f73 commit 24a8f2e
Show file tree
Hide file tree
Showing 50 changed files with 1,254 additions and 1,396 deletions.
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; }
}
}
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; }
}
}
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();
}
}
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; }
}
}

This file was deleted.

This file was deleted.

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; }
}
}
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; }
}
}
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; }
}
}
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; }
}
}
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; }
}
}
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; }
}
}
Loading

0 comments on commit 24a8f2e

Please sign in to comment.