Skip to content

Commit

Permalink
Merge branch 'feature/text_analytics_v3.0' of https://github.com/Azur…
Browse files Browse the repository at this point in the history
…e/azure-sdk-for-python into fix_detect_language_errors

* 'feature/text_analytics_v3.0' of https://github.com/Azure/azure-sdk-for-python:
  [text analytics] score -> confidence_score in DetectedLanguage (Azure#11076)
  • Loading branch information
iscai-msft committed Apr 27, 2020
2 parents 99bf6f5 + a9a9a63 commit 11b77fd
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 17 deletions.
2 changes: 2 additions & 0 deletions sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion sdk/textanalytics/azure-ai-textanalytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand Down

0 comments on commit 11b77fd

Please sign in to comment.