| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.Linq; |
| | 7 | | using Azure.AI.TextAnalytics.Models; |
| | 8 | |
|
| | 9 | | namespace Azure.AI.TextAnalytics |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Model factory that enables mocking for the Text Analytics library. |
| | 13 | | /// </summary> |
| | 14 | | public static class TextAnalyticsModelFactory |
| | 15 | | { |
| | 16 | | #region Common |
| | 17 | | /// <summary> |
| | 18 | | /// Initializes a new instance of <see cref="TextAnalytics.TextDocumentStatistics"/> for mocking purposes. |
| | 19 | | /// </summary> |
| | 20 | | /// <param name="characterCount">Sets the <see cref="TextDocumentStatistics.CharacterCount"/> property.</param> |
| | 21 | | /// <param name="transactionCount">Sets the <see cref="TextDocumentStatistics.TransactionCount"/> property.</par |
| | 22 | | /// <returns>A new instance of <see cref="TextAnalytics.TextDocumentStatistics"/> for mocking purposes.</returns |
| | 23 | | public static TextDocumentStatistics TextDocumentStatistics(int characterCount, int transactionCount) |
| | 24 | | { |
| 0 | 25 | | return new TextDocumentStatistics(characterCount, transactionCount); |
| | 26 | | } |
| | 27 | |
|
| | 28 | | /// <summary> |
| | 29 | | /// Initializes a new instance of <see cref="TextAnalytics.TextDocumentBatchStatistics"/> for mocking purposes. |
| | 30 | | /// </summary> |
| | 31 | | /// <param name="documentCount">Sets the <see cref="TextDocumentBatchStatistics.DocumentCount"/> property.</para |
| | 32 | | /// <param name="validDocumentCount">Sets the <see cref="TextDocumentBatchStatistics.ValidDocumentCount"/> prope |
| | 33 | | /// <param name="invalidDocumentCount">Sets the <see cref="TextDocumentBatchStatistics.InvalidDocumentCount"/> p |
| | 34 | | /// <param name="transactionCount">Sets the <see cref="TextDocumentBatchStatistics.TransactionCount"/> property. |
| | 35 | | /// <returns>A new instance of <see cref="TextAnalytics.TextDocumentBatchStatistics"/> for mocking purposes.</re |
| | 36 | | public static TextDocumentBatchStatistics TextDocumentBatchStatistics(int documentCount, int validDocumentCount, |
| | 37 | | { |
| 0 | 38 | | return new TextDocumentBatchStatistics(documentCount, validDocumentCount, invalidDocumentCount, transactionC |
| | 39 | | } |
| | 40 | |
|
| | 41 | | /// <summary> |
| | 42 | | /// Initializes a new instance of <see cref="TextAnalytics.TextAnalyticsError"/> for mocking purposes. |
| | 43 | | /// </summary> |
| | 44 | | /// <param name="code">Sets the <see cref="TextAnalyticsError.ErrorCode"/> property.</param> |
| | 45 | | /// <param name="message">Sets the <see cref="TextAnalyticsError.Message"/> property.</param> |
| | 46 | | /// <param name="target">Sets the <see cref="TextAnalyticsError.Target"/> property.</param> |
| | 47 | | /// <returns>A new instance of <see cref="TextAnalytics.TextAnalyticsError"/> for mocking purposes.</returns> |
| | 48 | | public static TextAnalyticsError TextAnalyticsError(string code, string message, string target = default) |
| | 49 | | { |
| 0 | 50 | | return new TextAnalyticsError(code, message, target); |
| | 51 | | } |
| | 52 | |
|
| | 53 | | /// <summary> |
| | 54 | | /// Initializes a new instance of <see cref="TextAnalytics.TextAnalyticsWarning"/> for mocking purposes. |
| | 55 | | /// </summary> |
| | 56 | | /// <param name="code">Sets the <see cref="TextAnalyticsWarning.WarningCode"/> property.</param> |
| | 57 | | /// <param name="message">Sets the <see cref="TextAnalyticsWarning.Message"/> property.</param> |
| | 58 | | /// <returns>A new instance of <see cref="TextAnalytics.TextAnalyticsWarning"/> for mocking purposes.</returns> |
| | 59 | | public static TextAnalyticsWarning TextAnalyticsWarning(string code, string message) |
| | 60 | | { |
| 0 | 61 | | return new TextAnalyticsWarning(code, message); |
| | 62 | | } |
| | 63 | |
|
| | 64 | | #endregion Common |
| | 65 | |
|
| | 66 | | #region Analyze Sentiment |
| | 67 | | /// <summary> |
| | 68 | | /// Initializes a new instance of <see cref="TextAnalytics.SentimentConfidenceScores"/> for mocking purposes. |
| | 69 | | /// </summary> |
| | 70 | | /// <param name="positiveScore">Sets the <see cref="SentimentConfidenceScores.Positive"/> property.</param> |
| | 71 | | /// <param name="neutralScore">Sets the <see cref="SentimentConfidenceScores.Neutral"/> property.</param> |
| | 72 | | /// <param name="negativeScore">Sets the <see cref="SentimentConfidenceScores.Negative"/> property.</param> |
| | 73 | | /// <returns>A new instance of <see cref="TextAnalytics.SentimentConfidenceScores"/> for mocking purposes.</retu |
| | 74 | | public static SentimentConfidenceScores SentimentConfidenceScores(double positiveScore, double neutralScore, dou |
| | 75 | | { |
| 0 | 76 | | return new SentimentConfidenceScores(positiveScore, neutralScore, negativeScore); |
| | 77 | | } |
| | 78 | |
|
| | 79 | | /// <summary> |
| | 80 | | /// Initializes a new instance of <see cref="TextAnalytics.DocumentSentiment"/> for mocking purposes. |
| | 81 | | /// </summary> |
| | 82 | | /// <param name="sentiment">Sets the <see cref="DocumentSentiment.Sentiment"/> property.</param> |
| | 83 | | /// <param name="positiveScore">Sets the <see cref="SentimentConfidenceScores.Positive"/> property.</param> |
| | 84 | | /// <param name="neutralScore">Sets the <see cref="SentimentConfidenceScores.Neutral"/> property.</param> |
| | 85 | | /// <param name="negativeScore">Sets the <see cref="SentimentConfidenceScores.Negative"/> property.</param> |
| | 86 | | /// <param name="sentenceSentiments">Sets the <see cref="DocumentSentiment.Sentences"/> property.</param> |
| | 87 | | /// <param name="warnings">Sets the <see cref="DetectedLanguage.Warnings"/> property.</param> |
| | 88 | | /// <returns>A new instance of <see cref="TextAnalytics.DocumentSentiment"/> for mocking purposes.</returns> |
| | 89 | | public static DocumentSentiment DocumentSentiment(TextSentiment sentiment, double positiveScore, double neutralS |
| | 90 | | { |
| 0 | 91 | | warnings ??= new List<TextAnalyticsWarning>(); |
| 0 | 92 | | return new DocumentSentiment(sentiment, positiveScore, neutralScore, negativeScore, sentenceSentiments, warn |
| | 93 | | } |
| | 94 | |
|
| | 95 | | /// <summary> |
| | 96 | | /// Initializes a new instance of <see cref="TextAnalytics.SentenceSentiment"/> for mocking purposes. |
| | 97 | | /// </summary> |
| | 98 | | /// <param name="sentiment">Sets the <see cref="SentenceSentiment.Sentiment"/> property.</param> |
| | 99 | | /// <param name="text">Sets the <see cref="SentenceSentiment.Text"/> property.</param> |
| | 100 | | /// <param name="positiveScore">Sets the <see cref="SentimentConfidenceScores.Positive"/> property.</param> |
| | 101 | | /// <param name="neutralScore">Sets the <see cref="SentimentConfidenceScores.Neutral"/> property.</param> |
| | 102 | | /// <param name="negativeScore">Sets the <see cref="SentimentConfidenceScores.Negative"/> property.</param> |
| | 103 | | /// <returns>A new instance of <see cref="TextAnalytics.SentenceSentiment"/> for mocking purposes.</returns> |
| | 104 | | public static SentenceSentiment SentenceSentiment(TextSentiment sentiment, string text, double positiveScore, do |
| | 105 | | { |
| 0 | 106 | | return new SentenceSentiment(sentiment, text, positiveScore, neutralScore, negativeScore); |
| | 107 | | } |
| | 108 | |
|
| | 109 | | /// <summary> |
| | 110 | | /// Initializes a new instance of <see cref="TextAnalytics.AnalyzeSentimentResult"/> for mocking purposes. |
| | 111 | | /// </summary> |
| | 112 | | /// <param name="id">Sets the <see cref="TextAnalyticsResult.Id"/> property.</param> |
| | 113 | | /// <param name="statistics">Sets the <see cref="TextAnalyticsResult.Statistics"/> property.</param> |
| | 114 | | /// <param name="documentSentiment">Sets the <see cref="AnalyzeSentimentResult.DocumentSentiment"/> property.</p |
| | 115 | | /// <returns>A new instance of <see cref="TextAnalytics.AnalyzeSentimentResult"/> for mocking purposes.</returns |
| | 116 | | public static AnalyzeSentimentResult AnalyzeSentimentResult(string id, TextDocumentStatistics statistics, Docume |
| | 117 | | { |
| 0 | 118 | | return new AnalyzeSentimentResult(id, statistics, documentSentiment); |
| | 119 | | } |
| | 120 | |
|
| | 121 | | /// <summary> |
| | 122 | | /// Initializes a new instance of <see cref="TextAnalytics.AnalyzeSentimentResult"/> for mocking purposes. |
| | 123 | | /// </summary> |
| | 124 | | /// <param name="id">Sets the <see cref="TextAnalyticsResult.Id"/> property.</param> |
| | 125 | | /// <param name="error">Sets the <see cref="TextAnalyticsResult.Error"/> property.</param> |
| | 126 | | /// <returns>A new instance of <see cref="TextAnalytics.AnalyzeSentimentResult"/> for mocking purposes.</returns |
| | 127 | | public static AnalyzeSentimentResult AnalyzeSentimentResult(string id, TextAnalyticsError error) |
| | 128 | | { |
| 0 | 129 | | return new AnalyzeSentimentResult(id, error); |
| | 130 | | } |
| | 131 | |
|
| | 132 | | /// <summary> |
| | 133 | | /// Initializes a new instance of <see cref="TextAnalytics.AnalyzeSentimentResultCollection"/> for mocking purpo |
| | 134 | | /// </summary> |
| | 135 | | /// <param name="list">Sets the collection of <see cref="TextAnalytics.AnalyzeSentimentResult"/>.</param> |
| | 136 | | /// <param name="statistics">Sets the <see cref="AnalyzeSentimentResultCollection.Statistics"/> property.</param |
| | 137 | | /// <param name="modelVersion">Sets the <see cref="AnalyzeSentimentResultCollection.ModelVersion"/> property.</p |
| | 138 | | /// <returns>A new instance of <see cref="TextAnalytics.AnalyzeSentimentResultCollection"/> for mocking purposes |
| | 139 | | public static AnalyzeSentimentResultCollection AnalyzeSentimentResultCollection(IEnumerable<AnalyzeSentimentResu |
| | 140 | | { |
| 0 | 141 | | return new AnalyzeSentimentResultCollection(list.ToList(), statistics, modelVersion); |
| | 142 | | } |
| | 143 | |
|
| | 144 | | #endregion Analyze Sentiment |
| | 145 | |
|
| | 146 | | #region Detect Language |
| | 147 | | /// <summary> |
| | 148 | | /// Initializes a new instance of <see cref="TextAnalytics.DetectedLanguage"/> for mocking purposes. |
| | 149 | | /// </summary> |
| | 150 | | /// <param name="name">Sets the <see cref="DetectedLanguage.Name"/> property.</param> |
| | 151 | | /// <param name="iso6391Name">Sets the <see cref="DetectedLanguage.Iso6391Name"/> property.</param> |
| | 152 | | /// <param name="confidenceScore">Sets the <see cref="DetectedLanguage.ConfidenceScore"/> property.</param> |
| | 153 | | /// <param name="warnings">Sets the <see cref="DetectedLanguage.Warnings"/> property.</param> |
| | 154 | | /// <returns>A new instance of <see cref="TextAnalytics.DetectedLanguage"/> for mocking purposes.</returns> |
| | 155 | | public static DetectedLanguage DetectedLanguage(string name, string iso6391Name, double confidenceScore, IList<T |
| | 156 | | { |
| 0 | 157 | | warnings ??= new List<TextAnalyticsWarning>(); |
| 0 | 158 | | return new DetectedLanguage(new DetectedLanguage_internal(name, iso6391Name, confidenceScore), warnings); |
| | 159 | | } |
| | 160 | |
|
| | 161 | | /// <summary> |
| | 162 | | /// Initializes a new instance of <see cref="TextAnalytics.DetectLanguageResult"/> for mocking purposes. |
| | 163 | | /// </summary> |
| | 164 | | /// <param name="id">Sets the <see cref="TextAnalyticsResult.Id"/> property.</param> |
| | 165 | | /// <param name="statistics">Sets the <see cref="TextAnalyticsResult.Statistics"/> property.</param> |
| | 166 | | /// <param name="detectedLanguage">Sets the <see cref="TextAnalytics.DetectedLanguage"/> property.</param> |
| | 167 | | /// <returns>A new instance of <see cref="TextAnalytics.DetectLanguageResult"/> for mocking purposes.</returns> |
| | 168 | | public static DetectLanguageResult DetectLanguageResult(string id, TextDocumentStatistics statistics, DetectedLa |
| | 169 | | { |
| 0 | 170 | | return new DetectLanguageResult(id, statistics, detectedLanguage); |
| | 171 | | } |
| | 172 | |
|
| | 173 | | /// <summary> |
| | 174 | | /// Initializes a new instance of <see cref="TextAnalytics.DetectLanguageResult"/> for mocking purposes. |
| | 175 | | /// </summary> |
| | 176 | | /// <param name="id">Sets the <see cref="TextAnalyticsResult.Id"/> property.</param> |
| | 177 | | /// <param name="error">Sets the <see cref="TextAnalyticsResult.Error"/> property.</param> |
| | 178 | | /// <returns>A new instance of <see cref="TextAnalytics.DetectLanguageResult"/> for mocking purposes.</returns> |
| | 179 | | public static DetectLanguageResult DetectLanguageResult(string id, TextAnalyticsError error) |
| | 180 | | { |
| 0 | 181 | | return new DetectLanguageResult(id, error); |
| | 182 | | } |
| | 183 | |
|
| | 184 | | /// <summary> |
| | 185 | | /// Initializes a new instance of <see cref="TextAnalytics.DetectLanguageResultCollection"/> for mocking purpose |
| | 186 | | /// </summary> |
| | 187 | | /// <param name="list">Sets the collection of <see cref="TextAnalytics.DetectLanguageResult"/>.</param> |
| | 188 | | /// <param name="statistics">Sets the <see cref="DetectLanguageResultCollection.Statistics"/> property.</param> |
| | 189 | | /// <param name="modelVersion">Sets the <see cref="DetectLanguageResultCollection.ModelVersion"/> property.</par |
| | 190 | | /// <returns>A new instance of <see cref="TextAnalytics.DetectLanguageResultCollection"/> for mocking purposes.< |
| | 191 | | public static DetectLanguageResultCollection DetectLanguageResultCollection(IEnumerable<DetectLanguageResult> li |
| | 192 | | { |
| 0 | 193 | | return new DetectLanguageResultCollection(list.ToList(), statistics, modelVersion); |
| | 194 | | } |
| | 195 | |
|
| | 196 | | #endregion Detect Language |
| | 197 | |
|
| | 198 | | #region Recognize Entities |
| | 199 | | /// <summary> |
| | 200 | | /// Initializes a new instance of <see cref="TextAnalytics.CategorizedEntity"/> for mocking purposes. |
| | 201 | | /// </summary> |
| | 202 | | /// <param name="text">Sets the <see cref="CategorizedEntity.Text"/> property.</param> |
| | 203 | | /// <param name="category">Sets the <see cref="CategorizedEntity.Category"/> property.</param> |
| | 204 | | /// <param name="subCategory">Sets the <see cref="CategorizedEntity.SubCategory"/> property.</param> |
| | 205 | | /// <param name="score">Sets the <see cref="CategorizedEntity.ConfidenceScore"/> property.</param> |
| | 206 | | /// <returns>A new instance of <see cref="TextAnalytics.CategorizedEntity"/> for mocking purposes.</returns> |
| | 207 | | public static CategorizedEntity CategorizedEntity(string text, string category, string subCategory, double score |
| | 208 | | { |
| 0 | 209 | | return new CategorizedEntity(text, category, subCategory, score); |
| | 210 | | } |
| | 211 | |
|
| | 212 | | /// <summary> |
| | 213 | | /// Initializes a new instance of <see cref="TextAnalytics.CategorizedEntityCollection"/> for mocking purposes. |
| | 214 | | /// </summary> |
| | 215 | | /// <param name="entities">Sets the collection of <see cref="TextAnalytics.CategorizedEntity"/>.</param> |
| | 216 | | /// <param name="warnings">Sets the <see cref="CategorizedEntityCollection.Warnings"/> property.</param> |
| | 217 | | /// <returns>A new instance of <see cref="TextAnalytics.CategorizedEntityCollection"/> for mocking purposes.</re |
| | 218 | | public static CategorizedEntityCollection CategorizedEntityCollection(IList<CategorizedEntity> entities, IList<T |
| | 219 | | { |
| 0 | 220 | | warnings ??= new List<TextAnalyticsWarning>(); |
| 0 | 221 | | return new CategorizedEntityCollection(entities, warnings); |
| | 222 | | } |
| | 223 | |
|
| | 224 | | /// <summary> |
| | 225 | | /// Initializes a new instance of <see cref="TextAnalytics.RecognizeEntitiesResult"/> for mocking purposes. |
| | 226 | | /// </summary> |
| | 227 | | /// <param name="id">Sets the <see cref="TextAnalyticsResult.Id"/> property.</param> |
| | 228 | | /// <param name="statistics">Sets the <see cref="TextAnalyticsResult.Statistics"/> property.</param> |
| | 229 | | /// <param name="entities">Sets the collection of <see cref="TextAnalytics.CategorizedEntity"/>.</param> |
| | 230 | | /// <returns>A new instance of <see cref="TextAnalytics.RecognizeEntitiesResult"/> for mocking purposes.</return |
| | 231 | | public static RecognizeEntitiesResult RecognizeEntitiesResult(string id, TextDocumentStatistics statistics, Cate |
| | 232 | | { |
| 16 | 233 | | return new RecognizeEntitiesResult(id, statistics, entities); |
| | 234 | | } |
| | 235 | |
|
| | 236 | | /// <summary> |
| | 237 | | /// Initializes a new instance of <see cref="TextAnalytics.RecognizeEntitiesResult"/> for mocking purposes. |
| | 238 | | /// </summary> |
| | 239 | | /// <param name="id">Sets the <see cref="TextAnalyticsResult.Id"/> property.</param> |
| | 240 | | /// <param name="error">Sets the <see cref="TextAnalyticsResult.Error"/> property.</param> |
| | 241 | | /// <returns>A new instance of <see cref="TextAnalytics.RecognizeEntitiesResult"/> for mocking purposes.</return |
| | 242 | | public static RecognizeEntitiesResult RecognizeEntitiesResult(string id, TextAnalyticsError error) |
| | 243 | | { |
| 0 | 244 | | return new RecognizeEntitiesResult(id, error); |
| | 245 | | } |
| | 246 | |
|
| | 247 | | /// <summary> |
| | 248 | | /// Initializes a new instance of <see cref="TextAnalytics.RecognizeEntitiesResultCollection"/> for mocking purp |
| | 249 | | /// </summary> |
| | 250 | | /// <param name="list">Sets the collection of <see cref="TextAnalytics.RecognizeEntitiesResult"/>.</param> |
| | 251 | | /// <param name="statistics">Sets the <see cref="RecognizeEntitiesResultCollection.Statistics"/> property.</para |
| | 252 | | /// <param name="modelVersion">Sets the <see cref="RecognizeEntitiesResultCollection.ModelVersion"/> property.</ |
| | 253 | | /// <returns>A new instance of <see cref="TextAnalytics.RecognizeEntitiesResultCollection"/> for mocking purpose |
| | 254 | | public static RecognizeEntitiesResultCollection RecognizeEntitiesResultCollection(IEnumerable<RecognizeEntitiesR |
| | 255 | | { |
| 0 | 256 | | return new RecognizeEntitiesResultCollection(list.ToList(), statistics, modelVersion); |
| | 257 | | } |
| | 258 | |
|
| | 259 | | #endregion Recognize Entities |
| | 260 | |
|
| | 261 | | #region Extract KeyPhrase |
| | 262 | | /// <summary> |
| | 263 | | /// Initializes a new instance of <see cref="TextAnalytics.ExtractKeyPhrasesResult"/> for mocking purposes. |
| | 264 | | /// </summary> |
| | 265 | | /// <param name="id">Sets the <see cref="TextAnalyticsResult.Id"/> property.</param> |
| | 266 | | /// <param name="statistics">Sets the <see cref="TextAnalyticsResult.Statistics"/> property.</param> |
| | 267 | | /// <param name="keyPhrases">Sets the <see cref="ExtractKeyPhrasesResult.KeyPhrases"/> property.</param> |
| | 268 | | /// <returns>A new instance of <see cref="TextAnalytics.ExtractKeyPhrasesResult"/> for mocking purposes.</return |
| | 269 | | public static ExtractKeyPhrasesResult ExtractKeyPhrasesResult(string id, TextDocumentStatistics statistics, KeyP |
| | 270 | | { |
| 0 | 271 | | return new ExtractKeyPhrasesResult(id, statistics, keyPhrases); |
| | 272 | | } |
| | 273 | |
|
| | 274 | | /// <summary> |
| | 275 | | /// Initializes a new instance of <see cref="TextAnalytics.KeyPhraseCollection"/> for mocking purposes. |
| | 276 | | /// </summary> |
| | 277 | | /// <param name="keyPhrases">Sets the collection of <see cref="string"/> key phrases.</param> |
| | 278 | | /// <param name="warnings">Sets the <see cref="KeyPhraseCollection.Warnings"/> property.</param> |
| | 279 | | /// <returns>A new instance of <see cref="TextAnalytics.KeyPhraseCollection"/> for mocking purposes.</returns> |
| | 280 | | public static KeyPhraseCollection KeyPhraseCollection(IList<string> keyPhrases, IList<TextAnalyticsWarning> warn |
| | 281 | | { |
| 0 | 282 | | warnings ??= new List<TextAnalyticsWarning>(); |
| 0 | 283 | | return new KeyPhraseCollection(keyPhrases, warnings); |
| | 284 | | } |
| | 285 | |
|
| | 286 | | /// <summary> |
| | 287 | | /// Initializes a new instance of <see cref="TextAnalytics.ExtractKeyPhrasesResult"/> for mocking purposes. |
| | 288 | | /// </summary> |
| | 289 | | /// <param name="id">Sets the <see cref="TextAnalyticsResult.Id"/> property.</param> |
| | 290 | | /// <param name="error">Sets the <see cref="TextAnalyticsResult.Error"/> property.</param> |
| | 291 | | /// <returns>A new instance of <see cref="TextAnalytics.ExtractKeyPhrasesResult"/> for mocking purposes.</return |
| | 292 | | public static ExtractKeyPhrasesResult ExtractKeyPhrasesResult(string id, TextAnalyticsError error) |
| | 293 | | { |
| 0 | 294 | | return new ExtractKeyPhrasesResult(id, error); |
| | 295 | | } |
| | 296 | |
|
| | 297 | | /// <summary> |
| | 298 | | /// Initializes a new instance of <see cref="TextAnalytics.ExtractKeyPhrasesResultCollection"/> for mocking purp |
| | 299 | | /// </summary> |
| | 300 | | /// <param name="list">Sets the collection of <see cref="TextAnalytics.ExtractKeyPhrasesResult"/>.</param> |
| | 301 | | /// <param name="statistics">Sets the <see cref="ExtractKeyPhrasesResultCollection.Statistics"/> property.</para |
| | 302 | | /// <param name="modelVersion">Sets the <see cref="ExtractKeyPhrasesResultCollection.ModelVersion"/> property.</ |
| | 303 | | /// <returns>A new instance of <see cref="TextAnalytics.ExtractKeyPhrasesResultCollection"/> for mocking purpose |
| | 304 | | public static ExtractKeyPhrasesResultCollection ExtractKeyPhrasesResultCollection(IEnumerable<ExtractKeyPhrasesR |
| | 305 | | { |
| 0 | 306 | | return new ExtractKeyPhrasesResultCollection(list.ToList(), statistics, modelVersion); |
| | 307 | | } |
| | 308 | |
|
| | 309 | | #endregion Extract KeyPhrase |
| | 310 | |
|
| | 311 | | #region Linked Entities |
| | 312 | | /// <summary> |
| | 313 | | /// Initializes a new instance of <see cref="TextAnalytics.LinkedEntity"/> for mocking purposes. |
| | 314 | | /// </summary> |
| | 315 | | /// <param name="name">Sets the <see cref="LinkedEntity.Name"/> property.</param> |
| | 316 | | /// <param name="dataSourceEntityId">Sets the <see cref="LinkedEntity.DataSourceEntityId"/> property.</param> |
| | 317 | | /// <param name="language">Sets the <see cref="LinkedEntity.Language"/> property.</param> |
| | 318 | | /// <param name="dataSource">Sets the <see cref="LinkedEntity.DataSource"/> property.</param> |
| | 319 | | /// <param name="url">Sets the <see cref="LinkedEntity.Url"/> property.</param> |
| | 320 | | /// <param name="matches">Sets the <see cref="LinkedEntity.Matches"/> property.</param> |
| | 321 | | /// <returns>A new instance of <see cref="TextAnalytics.LinkedEntity"/> for mocking purposes.</returns> |
| | 322 | | public static LinkedEntity LinkedEntity(string name, string dataSourceEntityId, string language, string dataSour |
| | 323 | | { |
| 0 | 324 | | return new LinkedEntity(name, dataSourceEntityId, language, dataSource, url, matches); |
| | 325 | | } |
| | 326 | |
|
| | 327 | | /// <summary> |
| | 328 | | /// Initializes a new instance of <see cref="TextAnalytics.LinkedEntityMatch"/> for mocking purposes. |
| | 329 | | /// </summary> |
| | 330 | | /// <param name="text">Sets the <see cref="LinkedEntityMatch.Text"/> property.</param> |
| | 331 | | /// <param name="score">Sets the <see cref="LinkedEntityMatch.ConfidenceScore"/> property.</param> |
| | 332 | | /// <returns>A new instance of <see cref="TextAnalytics.LinkedEntityMatch"/> for mocking purposes.</returns> |
| | 333 | | public static LinkedEntityMatch LinkedEntityMatch(string text, double score) |
| | 334 | | { |
| 0 | 335 | | return new LinkedEntityMatch(text, score); |
| | 336 | | } |
| | 337 | |
|
| | 338 | | /// <summary> |
| | 339 | | /// Initializes a new instance of <see cref="TextAnalytics.LinkedEntityCollection"/> for mocking purposes. |
| | 340 | | /// </summary> |
| | 341 | | /// <param name="entities">Sets the collection of <see cref="TextAnalytics.LinkedEntity"/>.</param> |
| | 342 | | /// <param name="warnings">Sets the <see cref="LinkedEntityCollection.Warnings"/> property.</param> |
| | 343 | | /// <returns>A new instance of <see cref="TextAnalytics.LinkedEntityCollection"/> for mocking purposes.</returns |
| | 344 | | public static LinkedEntityCollection LinkedEntityCollection(IList<LinkedEntity> entities, IList<TextAnalyticsWar |
| | 345 | | { |
| 0 | 346 | | warnings ??= new List<TextAnalyticsWarning>(); |
| 0 | 347 | | return new LinkedEntityCollection(entities, warnings); |
| | 348 | | } |
| | 349 | |
|
| | 350 | | /// <summary> |
| | 351 | | /// Initializes a new instance of <see cref="TextAnalytics.RecognizeLinkedEntitiesResult"/> for mocking purposes |
| | 352 | | /// </summary> |
| | 353 | | /// <param name="id">Sets the <see cref="TextAnalyticsResult.Id"/> property.</param> |
| | 354 | | /// <param name="statistics">Sets the <see cref="TextAnalyticsResult.Statistics"/> property.</param> |
| | 355 | | /// <param name="linkedEntities">Sets the collection of <see cref="TextAnalytics.LinkedEntity"/>.</param> |
| | 356 | | /// <returns>A new instance of <see cref="TextAnalytics.RecognizeLinkedEntitiesResult"/> for mocking purposes.</ |
| | 357 | | public static RecognizeLinkedEntitiesResult RecognizeLinkedEntitiesResult(string id, TextDocumentStatistics stat |
| | 358 | | { |
| 0 | 359 | | return new RecognizeLinkedEntitiesResult(id, statistics, linkedEntities); |
| | 360 | | } |
| | 361 | |
|
| | 362 | | /// <summary> |
| | 363 | | /// Initializes a new instance of <see cref="TextAnalytics.RecognizeLinkedEntitiesResult"/> for mocking purposes |
| | 364 | | /// </summary> |
| | 365 | | /// <param name="id">Sets the <see cref="TextAnalyticsResult.Id"/> property.</param> |
| | 366 | | /// <param name="error">Sets the <see cref="TextAnalyticsResult.Error"/> property.</param> |
| | 367 | | /// <returns>A new instance of <see cref="TextAnalytics.RecognizeLinkedEntitiesResult"/> for mocking purposes.</ |
| | 368 | | public static RecognizeLinkedEntitiesResult RecognizeLinkedEntitiesResult(string id, TextAnalyticsError error) |
| | 369 | | { |
| 0 | 370 | | return new RecognizeLinkedEntitiesResult(id, error); |
| | 371 | | } |
| | 372 | |
|
| | 373 | | /// <summary> |
| | 374 | | /// Initializes a new instance of <see cref="TextAnalytics.RecognizeLinkedEntitiesResultCollection"/> for mockin |
| | 375 | | /// </summary> |
| | 376 | | /// <param name="list">Sets the collection of <see cref="TextAnalytics.RecognizeLinkedEntitiesResult"/>.</param> |
| | 377 | | /// <param name="statistics">Sets the <see cref="RecognizeLinkedEntitiesResultCollection.Statistics"/> property. |
| | 378 | | /// <param name="modelVersion">Sets the <see cref="RecognizeLinkedEntitiesResultCollection.ModelVersion"/> prope |
| | 379 | | /// <returns>A new instance of <see cref="TextAnalytics.RecognizeLinkedEntitiesResultCollection"/> for mocking p |
| | 380 | | public static RecognizeLinkedEntitiesResultCollection RecognizeLinkedEntitiesResultCollection(IEnumerable<Recogn |
| | 381 | | { |
| 0 | 382 | | return new RecognizeLinkedEntitiesResultCollection(list.ToList(), statistics, modelVersion); |
| | 383 | | } |
| | 384 | |
|
| | 385 | | #endregion Linked Entities |
| | 386 | | } |
| | 387 | | } |