From a9a9a63ca26f24aa29ae5cddee199f708cc5a93b Mon Sep 17 00:00:00 2001 From: iscai-msft <43154838+iscai-msft@users.noreply.github.com> Date: Mon, 27 Apr 2020 12:14:24 -0400 Subject: [PATCH] [text analytics] score -> confidence_score in DetectedLanguage (#11076) --- sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md | 2 ++ sdk/textanalytics/azure-ai-textanalytics/README.md | 2 +- .../azure/ai/textanalytics/_models.py | 2 +- .../sample_alternative_document_input_async.py | 2 +- .../samples/async_samples/sample_authentication_async.py | 4 ++-- .../samples/async_samples/sample_detect_language_async.py | 2 +- .../samples/sample_alternative_document_input.py | 2 +- .../azure-ai-textanalytics/samples/sample_authentication.py | 4 ++-- .../samples/sample_detect_language.py | 2 +- .../azure-ai-textanalytics/tests/test_detect_language.py | 4 ++-- .../tests/test_detect_language_async.py | 4 ++-- .../azure-ai-textanalytics/tests/test_text_analytics.py | 6 +++--- 12 files changed, 19 insertions(+), 17 deletions(-) diff --git a/sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md b/sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md index 5a584eb99a21..f774de88a97d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md +++ b/sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md @@ -2,6 +2,8 @@ ## 1.0.0b5 (Unreleased) +**Breaking changes** +- `score` attribute of `DetectedLanguage` has been renamed to `confidence_score` ## 1.0.0b4 (2020-04-07) diff --git a/sdk/textanalytics/azure-ai-textanalytics/README.md b/sdk/textanalytics/azure-ai-textanalytics/README.md index 499cef748ce6..b39795504fb3 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/README.md +++ b/sdk/textanalytics/azure-ai-textanalytics/README.md @@ -343,7 +343,7 @@ result = [doc for doc in response if not doc.is_error] for doc in result: print("Language detected: {}".format(doc.primary_language.name)) print("ISO6391 name: {}".format(doc.primary_language.iso6391_name)) - print("Confidence score: {}\n".format(doc.primary_language.score)) + print("Confidence score: {}\n".format(doc.primary_language.confidence_score)) ``` The returned response is a heterogeneous list of result and error objects: list[[DetectLanguageResult][detect_language_result], [DocumentError][document_error]] diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py index 417c66ea159f..13c62dbe9f11 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py @@ -86,7 +86,7 @@ def _from_generated(cls, language): ) def __repr__(self): - return "DetectedLanguage(name={}, iso6391_name={}, score={})" \ + return "DetectedLanguage(name={}, iso6391_name={}, confidence_score={})" \ .format(self.name, self.iso6391_name, self.confidence_score)[:1024] diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_alternative_document_input_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_alternative_document_input_async.py index b70ba4461f5a..ae9e1de740ed 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_alternative_document_input_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_alternative_document_input_async.py @@ -51,7 +51,7 @@ async def alternative_document_input(self): print("Document text: {}".format(documents[idx])) print("Language detected: {}".format(doc.primary_language.name)) print("ISO6391 name: {}".format(doc.primary_language.iso6391_name)) - print("Confidence score: {}\n".format(doc.primary_language.score)) + print("Confidence score: {}\n".format(doc.primary_language.confidence_score)) if doc.is_error: print(doc.id, doc.error) diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_authentication_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_authentication_async.py index fd924674df98..f0ac344c75de 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_authentication_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_authentication_async.py @@ -52,7 +52,7 @@ async def authentication_with_api_key_credential_async(self): result = await text_analytics_client.detect_language(doc) print("Language detected: {}".format(result[0].primary_language.name)) - print("Confidence score: {}".format(result[0].primary_language.score)) + print("Confidence score: {}".format(result[0].primary_language.confidence_score)) async def authentication_with_azure_active_directory_async(self): """DefaultAzureCredential will use the values from these environment @@ -74,7 +74,7 @@ async def authentication_with_azure_active_directory_async(self): result = await text_analytics_client.detect_language(doc) print("Language detected: {}".format(result[0].primary_language.name)) - print("Confidence score: {}".format(result[0].primary_language.score)) + print("Confidence score: {}".format(result[0].primary_language.confidence_score)) async def main(): diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_detect_language_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_detect_language_async.py index 979080570941..8ccf20c9c89f 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_detect_language_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_detect_language_async.py @@ -50,7 +50,7 @@ async def detect_language_async(self): print("Document text: {}".format(documents[idx])) print("Language detected: {}".format(doc.primary_language.name)) print("ISO6391 name: {}".format(doc.primary_language.iso6391_name)) - print("Confidence score: {}\n".format(doc.primary_language.score)) + print("Confidence score: {}\n".format(doc.primary_language.confidence_score)) if doc.is_error: print(doc.id, doc.error) # [END batch_detect_language_async] diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_alternative_document_input.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_alternative_document_input.py index 581d08d48c45..14dcc9706952 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_alternative_document_input.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_alternative_document_input.py @@ -51,7 +51,7 @@ def alternative_document_input(self): print("Document text: {}".format(documents[idx])) print("Language detected: {}".format(doc.primary_language.name)) print("ISO6391 name: {}".format(doc.primary_language.iso6391_name)) - print("Confidence score: {}\n".format(doc.primary_language.score)) + print("Confidence score: {}\n".format(doc.primary_language.confidence_score)) if doc.is_error: print(doc.id, doc.error) diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_authentication.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_authentication.py index 06dc30aed696..0348b40ee163 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_authentication.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_authentication.py @@ -50,7 +50,7 @@ def authentication_with_api_key_credential(self): result = text_analytics_client.detect_language(doc) print("Language detected: {}".format(result[0].primary_language.name)) - print("Confidence score: {}".format(result[0].primary_language.score)) + print("Confidence score: {}".format(result[0].primary_language.confidence_score)) def authentication_with_azure_active_directory(self): """DefaultAzureCredential will use the values from these environment @@ -71,7 +71,7 @@ def authentication_with_azure_active_directory(self): result = text_analytics_client.detect_language(doc) print("Language detected: {}".format(result[0].primary_language.name)) - print("Confidence score: {}".format(result[0].primary_language.score)) + print("Confidence score: {}".format(result[0].primary_language.confidence_score)) if __name__ == '__main__': diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_detect_language.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_detect_language.py index a1aee02c5dcf..f7ea2e00ea93 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_detect_language.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_detect_language.py @@ -49,7 +49,7 @@ def detect_language(self): print("Document text: {}".format(documents[idx])) print("Language detected: {}".format(doc.primary_language.name)) print("ISO6391 name: {}".format(doc.primary_language.iso6391_name)) - print("Confidence score: {}\n".format(doc.primary_language.score)) + print("Confidence score: {}\n".format(doc.primary_language.confidence_score)) if doc.is_error: print(doc.id, doc.error) # [END batch_detect_language] diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language.py index 38deedaf76e4..cb8dd8320714 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language.py @@ -53,7 +53,7 @@ def test_all_successful_passing_dict(self, client): for doc in response: self.assertIsNotNone(doc.id) self.assertIsNotNone(doc.statistics) - self.assertIsNotNone(doc.primary_language.score) + self.assertIsNotNone(doc.primary_language.confidence_score) @GlobalTextAnalyticsAccountPreparer() @TextAnalyticsClientPreparer() @@ -77,7 +77,7 @@ def test_all_successful_passing_text_document_input(self, client): self.assertEqual(response[3].primary_language.iso6391_name, "de") for doc in response: - self.assertIsNotNone(doc.primary_language.score) + self.assertIsNotNone(doc.primary_language.confidence_score) @GlobalTextAnalyticsAccountPreparer() @TextAnalyticsClientPreparer() diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language_async.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language_async.py index 8fc0946a8d6c..fce974e63502 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_detect_language_async.py @@ -66,7 +66,7 @@ async def test_all_successful_passing_dict(self, client): for doc in response: self.assertIsNotNone(doc.id) self.assertIsNotNone(doc.statistics) - self.assertIsNotNone(doc.primary_language.score) + self.assertIsNotNone(doc.primary_language.confidence_score) @GlobalTextAnalyticsAccountPreparer() @TextAnalyticsClientPreparer() @@ -90,7 +90,7 @@ async def test_all_successful_passing_text_document_input(self, client): self.assertEqual(response[3].primary_language.iso6391_name, "de") for doc in response: - self.assertIsNotNone(doc.primary_language.score) + self.assertIsNotNone(doc.primary_language.confidence_score) @GlobalTextAnalyticsAccountPreparer() @TextAnalyticsClientPreparer() diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_text_analytics.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_text_analytics.py index 1af141c7d535..87dc75c58476 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_text_analytics.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_text_analytics.py @@ -27,7 +27,7 @@ def test_detect_language(self, resource_group, location, text_analytics_account, self.assertEqual(response[0].primary_language.name, "English") def test_repr(self): - detected_language = _models.DetectedLanguage(name="English", iso6391_name="en", score=1.0) + detected_language = _models.DetectedLanguage(name="English", iso6391_name="en", confidence_score=1.0) categorized_entity = _models.CategorizedEntity(text="Bill Gates", category="Person", subcategory="Age", grapheme_offset=0, grapheme_length=8, confidence_score=0.899) @@ -108,7 +108,7 @@ def test_repr(self): transaction_count=4 ) - self.assertEqual("DetectedLanguage(name=English, iso6391_name=en, score=1.0)", repr(detected_language)) + self.assertEqual("DetectedLanguage(name=English, iso6391_name=en, confidence_score=1.0)", repr(detected_language)) self.assertEqual("CategorizedEntity(text=Bill Gates, category=Person, subcategory=Age, grapheme_offset=0, " "grapheme_length=8, confidence_score=0.899)", repr(categorized_entity)) @@ -119,7 +119,7 @@ def test_repr(self): "statistics=TextDocumentStatistics(grapheme_count=14, transaction_count=18), " "is_error=False)", repr(recognize_entities_result)) self.assertEqual("DetectLanguageResult(id=1, primary_language=DetectedLanguage(name=English, " - "iso6391_name=en, score=1.0), statistics=TextDocumentStatistics(grapheme_count=14, " + "iso6391_name=en, confidence_score=1.0), statistics=TextDocumentStatistics(grapheme_count=14, " "transaction_count=18), is_error=False)", repr(detect_language_result)) self.assertEqual("TextAnalyticsError(code=invalidRequest, message=The request is invalid, target=request)", repr(text_analytics_error))