Skip to content

Commit 8a15b5d

Browse files
[textanalytics] release prep + fixing docstrings and links (Azure#23315)
* release prep + fixing docstrings and links * revert change from previous PR where we created a type alias for the input types
1 parent 486e6db commit 8a15b5d

File tree

7 files changed

+126
-119
lines changed

7 files changed

+126
-119
lines changed

sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Release History
22

3-
## 5.2.0b3 (Unreleased)
4-
5-
### Features Added
6-
7-
### Breaking Changes
3+
## 5.2.0b3 (2022-03-08)
84

95
### Bugs Fixed
106
- `string_index_type` now correctly defaults to the Python default `UnicodeCodePoint` for `AnalyzeSentimentAction` and `RecognizeCustomEntitiesAction`.

sdk/textanalytics/azure-ai-textanalytics/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
692692
[cognitive_authentication_aad]: https://docs.microsoft.com/azure/cognitive-services/authentication#authenticate-with-azure-active-directory
693693
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials
694694
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential
695-
[service_limits]: https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/data-limits?tabs=version-3
695+
[service_limits]: https://aka.ms/azsdk/textanalytics/data-limits
696696
[azure-key-credential]: https://aka.ms/azsdk-python-core-azurekeycredential
697697
[document_error]: https://aka.ms/azsdk-python-textanalytics-documenterror
698698
[detect_language_result]: https://aka.ms/azsdk-python-textanalytics-detectlanguageresult
@@ -712,15 +712,15 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
712712
[recognize_linked_entities]: https://aka.ms/azsdk-python-textanalytics-recognizelinkedentities
713713
[extract_key_phrases]: https://aka.ms/azsdk-python-textanalytics-extractkeyphrases
714714
[detect_language]: https://aka.ms/azsdk-python-textanalytics-detectlanguage
715-
[language_detection]: https://docs.microsoft.com/azure/cognitive-services/Text-Analytics/how-tos/text-analytics-how-to-language-detection
716-
[language_and_regional_support]: https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support?tabs=language-detection
717-
[sentiment_analysis]: https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-sentiment-analysis
718-
[key_phrase_extraction]: https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-keyword-extraction
719-
[linked_entities_categories]: https://docs.microsoft.com/azure/cognitive-services/text-analytics/named-entity-types?tabs=general
720-
[linked_entity_recognition]: https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-entity-linking
721-
[pii_entity_categories]: https://docs.microsoft.com/azure/cognitive-services/text-analytics/named-entity-types?tabs=personal
722-
[named_entity_recognition]: https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-entity-linking
723-
[named_entity_categories]: https://docs.microsoft.com/azure/cognitive-services/text-analytics/named-entity-types?tabs=general
715+
[language_detection]: https://docs.microsoft.com/azure/cognitive-services/language-service/language-detection/overview
716+
[language_and_regional_support]: https://docs.microsoft.com/azure/cognitive-services/language-service/language-detection/language-support
717+
[sentiment_analysis]: https://docs.microsoft.com/azure/cognitive-services/language-service/sentiment-opinion-mining/overview
718+
[key_phrase_extraction]: https://docs.microsoft.com/azure/cognitive-services/language-service/key-phrase-extraction/overview
719+
[linked_entities_categories]: https://aka.ms/taner
720+
[linked_entity_recognition]: https://docs.microsoft.com/azure/cognitive-services/language-service/entity-linking/overview
721+
[pii_entity_categories]: https://aka.ms/tanerpii
722+
[named_entity_recognition]: https://docs.microsoft.com/azure/cognitive-services/language-service/named-entity-recognition/overview
723+
[named_entity_categories]: https://aka.ms/taner
724724
[azure_core_ref_docs]: https://aka.ms/azsdk-python-core-policies
725725
[azure_core]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/README.md
726726
[azure_identity]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_text_analytics_client.py

Lines changed: 48 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -69,35 +69,6 @@
6969
MultiCategoryClassifyResult,
7070
)
7171

72-
ActionInputTypes = List[
73-
Union[
74-
RecognizeEntitiesAction,
75-
RecognizeLinkedEntitiesAction,
76-
RecognizePiiEntitiesAction,
77-
ExtractKeyPhrasesAction,
78-
AnalyzeSentimentAction,
79-
ExtractSummaryAction,
80-
RecognizeCustomEntitiesAction,
81-
SingleCategoryClassifyAction,
82-
MultiCategoryClassifyAction,
83-
]
84-
]
85-
86-
ActionResultTypes = List[
87-
Union[
88-
RecognizeEntitiesResult,
89-
RecognizeLinkedEntitiesResult,
90-
RecognizePiiEntitiesResult,
91-
ExtractKeyPhrasesResult,
92-
AnalyzeSentimentResult,
93-
ExtractSummaryResult,
94-
RecognizeCustomEntitiesResult,
95-
SingleCategoryClassifyResult,
96-
MultiCategoryClassifyResult,
97-
DocumentError,
98-
]
99-
]
100-
10172
if TYPE_CHECKING:
10273
from azure.core.credentials import TokenCredential
10374

@@ -106,20 +77,19 @@ class TextAnalyticsClient(TextAnalyticsClientBase):
10677
"""The Text Analytics API is a suite of text analytics web services built with best-in-class
10778
Microsoft machine learning algorithms. The API can be used to analyze unstructured text for
10879
tasks such as sentiment analysis, key phrase extraction, entities recognition,
109-
and language detection. No training data is needed to use this API - just bring your text data.
80+
and language detection, and more. No training data is needed to use this API - just bring your text data.
11081
This API uses advanced natural language processing techniques to deliver best in class predictions.
11182
11283
Further documentation can be found in
113-
https://docs.microsoft.com/azure/cognitive-services/text-analytics/overview
84+
https://docs.microsoft.com/azure/cognitive-services/language-service/overview
11485
11586
:param str endpoint: Supported Cognitive Services or Text Analytics resource
116-
endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com).
87+
endpoints (protocol and hostname, for example: 'https://<resource-name>.cognitiveservices.azure.com').
11788
:param credential: Credentials needed for the client to connect to Azure.
11889
This can be the an instance of AzureKeyCredential if using a
11990
cognitive services/text analytics API key or a token credential
12091
from :mod:`azure.identity`.
121-
:type credential: :class:`~azure.core.credentials.AzureKeyCredential` or
122-
:class:`~azure.core.credentials.TokenCredential`
92+
:type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential
12393
:keyword str default_country_hint: Sets the default country_hint to use for all operations.
12494
Defaults to "US". If you don't want to use a country hint, pass the string "none".
12595
:keyword str default_language: Sets the default language to use for all operations.
@@ -173,17 +143,15 @@ def detect_language(
173143
one. Scores close to one indicate 100% certainty that the identified
174144
language is true. See https://aka.ms/talangs for the list of enabled languages.
175145
176-
See https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/data-limits?tabs=version-3
177-
for document length limits, maximum batch size, and supported text encoding.
146+
See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
178147
179148
:param documents: The set of documents to process as part of this batch.
180149
If you wish to specify the ID and country_hint on a per-item basis you must
181150
use as input a list[:class:`~azure.ai.textanalytics.DetectLanguageInput`] or a list of
182151
dict representations of :class:`~azure.ai.textanalytics.DetectLanguageInput`, like
183152
`{"id": "1", "country_hint": "us", "text": "hello world"}`.
184153
:type documents:
185-
list[str] or list[~azure.ai.textanalytics.DetectLanguageInput] or
186-
list[dict[str, str]]
154+
list[str] or list[~azure.ai.textanalytics.DetectLanguageInput] or list[dict[str, str]]
187155
:keyword str country_hint: Country of origin hint for the entire batch. Accepts two
188156
letter country codes specified by ISO 3166-1 alpha-2. Per-document
189157
country hints will take precedence over whole batch hints. Defaults to
@@ -255,17 +223,15 @@ def recognize_entities(
255223
organizations, date/time, quantities, percentages, currencies, and more.
256224
For the list of supported entity types, check: https://aka.ms/taner
257225
258-
See https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/data-limits?tabs=version-3
259-
for document length limits, maximum batch size, and supported text encoding.
226+
See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
260227
261228
:param documents: The set of documents to process as part of this batch.
262229
If you wish to specify the ID and language on a per-item basis you must
263230
use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list
264231
of dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`,
265232
like `{"id": "1", "language": "en", "text": "hello world"}`.
266233
:type documents:
267-
list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or
268-
list[dict[str, str]]
234+
list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
269235
:keyword str language: The 2 letter ISO 639-1 representation of language for the
270236
entire batch. For example, use "en" for English; "es" for Spanish etc.
271237
If not set, uses "en" for English as default. Per-document language will
@@ -346,17 +312,15 @@ def recognize_pii_entities(
346312
"Bank Account", etc) in the document. For the list of supported entity types,
347313
check https://aka.ms/tanerpii
348314
349-
See https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/data-limits?tabs=version-3
350-
for document length limits, maximum batch size, and supported text encoding.
315+
See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
351316
352317
:param documents: The set of documents to process as part of this batch.
353318
If you wish to specify the ID and language on a per-item basis you must
354319
use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
355320
dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
356321
`{"id": "1", "language": "en", "text": "hello world"}`.
357322
:type documents:
358-
list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or
359-
list[dict[str, str]]
323+
list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
360324
:keyword str language: The 2 letter ISO 639-1 representation of language for the
361325
entire batch. For example, use "en" for English; "es" for Spanish etc.
362326
If not set, uses "en" for English as default. Per-document language will
@@ -460,17 +424,15 @@ def recognize_linked_entities(
460424
Roman god of war). Recognized entities are associated with URLs to a well-known
461425
knowledge base, like Wikipedia.
462426
463-
See https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/data-limits?tabs=version-3
464-
for document length limits, maximum batch size, and supported text encoding.
427+
See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
465428
466429
:param documents: The set of documents to process as part of this batch.
467430
If you wish to specify the ID and language on a per-item basis you must
468431
use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
469432
dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
470433
`{"id": "1", "language": "en", "text": "hello world"}`.
471434
:type documents:
472-
list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or
473-
list[dict[str, str]]
435+
list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
474436
:keyword str language: The 2 letter ISO 639-1 representation of language for the
475437
entire batch. For example, use "en" for English; "es" for Spanish etc.
476438
If not set, uses "en" for English as default. Per-document language will
@@ -575,8 +537,7 @@ def begin_analyze_healthcare_entities(
575537
dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
576538
`{"id": "1", "language": "en", "text": "hello world"}`.
577539
:type documents:
578-
list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or
579-
list[dict[str, str]]
540+
list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
580541
:keyword str model_version: This value indicates which model will
581542
be used for scoring, e.g. "latest", "2019-10-01". If a model-version
582543
is not specified, the API will default to the latest, non-preview version.
@@ -711,17 +672,15 @@ def extract_key_phrases(
711672
were wonderful staff", the API returns the main talking points: "food"
712673
and "wonderful staff"
713674
714-
See https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/data-limits?tabs=version-3
715-
for document length limits, maximum batch size, and supported text encoding.
675+
See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
716676
717677
:param documents: The set of documents to process as part of this batch.
718678
If you wish to specify the ID and language on a per-item basis you must
719679
use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
720680
dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
721681
`{"id": "1", "language": "en", "text": "hello world"}`.
722682
:type documents:
723-
list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or
724-
list[dict[str, str]]
683+
list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
725684
:keyword str language: The 2 letter ISO 639-1 representation of language for the
726685
entire batch. For example, use "en" for English; "es" for Spanish etc.
727686
If not set, uses "en" for English as default. Per-document language will
@@ -791,17 +750,15 @@ def analyze_sentiment(
791750
each sentiment class (Positive, Negative, and Neutral) for the document
792751
and each sentence within it.
793752
794-
See https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/data-limits?tabs=version-3
795-
for document length limits, maximum batch size, and supported text encoding.
753+
See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
796754
797755
:param documents: The set of documents to process as part of this batch.
798756
If you wish to specify the ID and language on a per-item basis you must
799757
use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
800758
dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
801759
`{"id": "1", "language": "en", "text": "hello world"}`.
802760
:type documents:
803-
list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or
804-
list[dict[str, str]]
761+
list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
805762
:keyword bool show_opinion_mining: Whether to mine the opinions of a sentence and conduct more
806763
granular analysis around the aspects of a product or service (also known as
807764
aspect-based sentiment analysis). If set to true, the returned
@@ -908,10 +865,37 @@ def _analyze_result_callback(
908865
def begin_analyze_actions(
909866
self,
910867
documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]],
911-
actions: ActionInputTypes,
868+
actions: List[
869+
Union[
870+
RecognizeEntitiesAction,
871+
RecognizeLinkedEntitiesAction,
872+
RecognizePiiEntitiesAction,
873+
ExtractKeyPhrasesAction,
874+
AnalyzeSentimentAction,
875+
ExtractSummaryAction,
876+
RecognizeCustomEntitiesAction,
877+
SingleCategoryClassifyAction,
878+
MultiCategoryClassifyAction,
879+
]
880+
],
912881
**kwargs: Any,
913882
) -> AnalyzeActionsLROPoller[
914-
ItemPaged[ActionResultTypes]
883+
ItemPaged[
884+
List[
885+
Union[
886+
RecognizeEntitiesResult,
887+
RecognizeLinkedEntitiesResult,
888+
RecognizePiiEntitiesResult,
889+
ExtractKeyPhrasesResult,
890+
AnalyzeSentimentResult,
891+
ExtractSummaryResult,
892+
RecognizeCustomEntitiesResult,
893+
SingleCategoryClassifyResult,
894+
MultiCategoryClassifyResult,
895+
DocumentError,
896+
]
897+
]
898+
]
915899
]:
916900
"""Start a long-running operation to perform a variety of text analysis actions over a batch of documents.
917901
@@ -928,8 +912,7 @@ def begin_analyze_actions(
928912
dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
929913
`{"id": "1", "language": "en", "text": "hello world"}`.
930914
:type documents:
931-
list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or
932-
list[dict[str, str]]
915+
list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
933916
:param actions: A heterogeneous list of actions to perform on the input documents.
934917
Each action object encapsulates the parameters used for the particular action type.
935918
The action results will be in the same order of the input actions.
@@ -963,7 +946,7 @@ def begin_analyze_actions(
963946
:class:`~azure.ai.textanalytics.AnalyzeSentimentResult` of "world".
964947
:rtype:
965948
~azure.ai.textanalytics.AnalyzeActionsLROPoller[~azure.core.paging.ItemPaged[
966-
list[RecognizeEntitiesResult or RecognizeLinkedEntitiesResult or RecognizePiiEntitiesResult,
949+
list[RecognizeEntitiesResult or RecognizeLinkedEntitiesResult or RecognizePiiEntitiesResult or
967950
ExtractKeyPhrasesResult or AnalyzeSentimentResult or ExtractSummaryAction or RecognizeCustomEntitiesResult
968951
or SingleCategoryClassifyResult or MultiCategoryClassifyResult or DocumentError]]]
969952
:raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError or NotImplementedError:

0 commit comments

Comments
 (0)