Skip to content

Commit

Permalink
[textanalytics] renames without 'batch' (Azure#18472)
Browse files Browse the repository at this point in the history
* remove batch naming

* renames for tests, samples, and docs
  • Loading branch information
kristapratico authored May 3, 2021
1 parent 8a5f878 commit f62cb98
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 199 deletions.
6 changes: 6 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,12 @@

## 5.1.0b7 (Unreleased)

**Breaking Changes**
- Renamed `begin_analyze_batch_actions` to `begin_analyze_actions`.
- Renamed `AnalyzeBatchActionsType` to `AnalyzeActionsType`.
- Renamed `AnalyzeBatchActionsResult` to `AnalyzeActionsResult`.
- Renamed `AnalyzeBatchActionsError` to `AnalyzeActionsError`.

**New Features**
- Added enums `EntityConditionality`, `EntityCertainty`, and `EntityAssociation`.
- Added `AnalyzeSentimentAction` as a supported action type for `begin_analyze_batch_actions`.
Expand Down
24 changes: 12 additions & 12 deletions sdk/textanalytics/azure-ai-textanalytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Text Analytics is a cloud-based service that provides advanced natural language
- Personally Identifiable Information (PII) Entity Recognition
- Language Detection
- Key Phrase Extraction
- Batch Analysis
- Multiple Analysis
- Healthcare Entities Analysis (Gated Preview)

[Source code][source_code] | [Package (PyPI)][ta_pypi] | [API reference documentation][ta_ref_docs]| [Product documentation][ta_product_documentation] | [Samples][ta_samples]
Expand Down Expand Up @@ -209,7 +209,7 @@ Long-running operations are operations which consist of an initial request sent
followed by polling the service at intervals to determine whether the operation has completed or failed, and if it has
succeeded, to get the result.

Methods that support Healthcare Analysis or batch operations over multiple Text Analytics APIs are modeled as long-running operations.
Methods that support Healthcare Analysis or multiple operations over multiple Text Analytics APIs are modeled as long-running operations.
The client exposes a `begin_<method-name>` method that returns an `LROPoller` or `AsyncLROPoller`. Callers should wait
for the operation to complete by calling `result()` on the poller object returned from the `begin_<method-name>` method.
Sample code snippets are provided to illustrate using long-running operations [below](#examples "Examples").
Expand All @@ -225,7 +225,7 @@ The following section provides several code snippets covering some of the most c
- [Extract Key Phrases](#extract-key-phrases "Extract key phrases")
- [Detect Language](#detect-language "Detect language")
- [Healthcare Entities Analysis](#healthcare-entities-analysis "Healthcare Entities Analysis")
- [Batch Analysis](#batch-analysis "Batch analysis")
- [Multiple Analysis](#multiple-analysis "Multiple analysis")

### Analyze sentiment

Expand Down Expand Up @@ -491,9 +491,9 @@ for idx, doc in enumerate(docs):

Note: The Healthcare Entities Analysis service is currently available only in the API v3.1 preview versions and is in gated preview. Since this is a gated preview, AAD is not supported. More information [here](https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-for-health?tabs=ner#request-access-to-the-public-preview).

### Batch Analysis
### Multiple Analysis

[Long-running operation](#long-running-operations) [`begin_analyze_batch_actions`][analyze_batch_actions] performs multiple analyses over one set of documents in a single request. Currently batching is supported using any combination of the following Text Analytics APIs in a single request:
[Long-running operation](#long-running-operations) [`begin_analyze_actions`][analyze_actions] performs multiple analyses over one set of documents in a single request. Currently it is supported using any combination of the following Text Analytics APIs in a single request:

- Entities Recognition
- PII Entities Recognition
Expand All @@ -519,7 +519,7 @@ text_analytics_client = TextAnalyticsClient(endpoint, credential)

documents = ["Microsoft was founded by Bill Gates and Paul Allen."]

poller = text_analytics_client.begin_analyze_batch_actions(
poller = text_analytics_client.begin_analyze_actions(
documents,
display_name="Sample Text Analysis",
actions=[
Expand All @@ -531,7 +531,7 @@ poller = text_analytics_client.begin_analyze_batch_actions(
]
)

# returns batch actions results in the same order as the inputted actions
# returns multiple actions results in the same order as the inputted actions
result = poller.result()

first_action_result = next(result)
Expand Down Expand Up @@ -604,7 +604,7 @@ for doc in docs:

The returned response is an object encapsulating multiple iterables, each representing results of individual analyses.

Note: Batch analysis is currently available only in the v3.1-preview API version.
Note: Multiple analysis is currently available only in the v3.1-preview API version.

## Optional Configuration

Expand Down Expand Up @@ -683,7 +683,7 @@ Common scenarios
- Extract key phrases: [sample_extract_key_phrases.py][extract_key_phrases_sample] ([async version][extract_key_phrases_sample_async])
- Detect language: [sample_detect_language.py][detect_language_sample] ([async version][detect_language_sample_async])
- Healthcare Entities Analysis: [sample_analyze_healthcare_entities.py][analyze_healthcare_entities_sample] ([async version][analyze_healthcare_entities_sample_async])
- Batch Analysis: [sample_analyze_batch_actions.py][analyze_sample] ([async version][analyze_sample_async])
- Multiple Analysis: [sample_analyze_actions.py][analyze_sample] ([async version][analyze_sample_async])

Advanced scenarios

Expand Down Expand Up @@ -739,7 +739,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
[detect_language_input]: https://aka.ms/azsdk-python-textanalytics-detectlanguageinput
[text_analytics_client]: https://aka.ms/azsdk-python-textanalytics-textanalyticsclient
[analyze_sentiment]: https://aka.ms/azsdk-python-textanalytics-analyzesentiment
[analyze_batch_actions]: https://aka.ms/azsdk/python/docs/ref/textanalytics#azure.ai.textanalytics.TextAnalyticsClient.begin_analyze_batch_actions
[analyze_actions]: https://aka.ms/azsdk/python/docs/ref/textanalytics#azure.ai.textanalytics.TextAnalyticsClient.begin_analyze_actions
[analyze_healthcare_entities]: https://aka.ms/azsdk/python/docs/ref/textanalytics#azure.ai.textanalytics.TextAnalyticsClient.begin_analyze_healthcare_entities
[recognize_entities]: https://aka.ms/azsdk-python-textanalytics-recognizeentities
[recognize_pii_entities]: https://aka.ms/azsdk-python-textanalytics-recognizepiientities
Expand Down Expand Up @@ -775,8 +775,8 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
[recognize_pii_entities_sample_async]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_recognize_pii_entities_async.py
[analyze_healthcare_entities_sample]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_healthcare_entities.py
[analyze_healthcare_entities_sample_async]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_healthcare_entities_async.py
[analyze_sample]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_batch_actions.py
[analyze_sample_async]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_batch_actions_async.py
[analyze_sample]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_actions.py
[analyze_sample_async]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_actions_async.py
[opinion_mining_sample]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_sentiment_with_opinion_mining.py
[opinion_mining_sample_async]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_sentiment_with_opinion_mining_async.py
[cla]: https://cla.microsoft.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
RecognizeLinkedEntitiesAction,
RecognizePiiEntitiesAction,
ExtractKeyPhrasesAction,
AnalyzeBatchActionsResult,
AnalyzeActionsResult,
RequestStatistics,
AnalyzeBatchActionsType,
AnalyzeBatchActionsError,
AnalyzeActionsType,
AnalyzeActionsError,
HealthcareEntityRelationRoleType,
HealthcareRelation,
HealthcareRelationRole,
Expand Down Expand Up @@ -93,10 +93,10 @@
'RecognizeLinkedEntitiesAction',
'RecognizePiiEntitiesAction',
'ExtractKeyPhrasesAction',
'AnalyzeBatchActionsResult',
'AnalyzeActionsResult',
'RequestStatistics',
'AnalyzeBatchActionsType',
"AnalyzeBatchActionsError",
'AnalyzeActionsType',
"AnalyzeActionsError",
"PiiEntityCategoryType",
"HealthcareEntityRelationType",
"HealthcareEntityRelationRoleType",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1356,8 +1356,8 @@ def __repr__(self):
.format(self.positive, self.neutral, self.negative)[:1024]


class AnalyzeBatchActionsType(str, Enum):
"""The type of batch action that was applied to the documents
class AnalyzeActionsType(str, Enum):
"""The type of action that was applied to the documents
"""
RECOGNIZE_ENTITIES = "recognize_entities" #: Entities Recognition action.
RECOGNIZE_PII_ENTITIES = "recognize_pii_entities" #: PII Entities Recognition action.
Expand All @@ -1366,17 +1366,17 @@ class AnalyzeBatchActionsType(str, Enum):
ANALYZE_SENTIMENT = "analyze_sentiment" #: Sentiment Analysis action.


class AnalyzeBatchActionsResult(DictMixin):
"""AnalyzeBatchActionsResult contains the results of a recognize entities action
on a list of documents. Returned by `begin_analyze_batch_actions`
class AnalyzeActionsResult(DictMixin):
"""AnalyzeActionsResult contains the results of a recognize entities action
on a list of documents. Returned by `begin_analyze_actions`
:ivar document_results: A list of objects containing results for all Entity Recognition actions
included in the analysis.
:vartype document_results: list[~azure.ai.textanalytics.RecognizeEntitiesResult]
:ivar bool is_error: Boolean check for error item when iterating over list of
actions. Always False for an instance of a AnalyzeBatchActionsResult.
:ivar action_type: The type of batch action this class is a result of.
:vartype action_type: str or ~azure.ai.textanalytics.AnalyzeBatchActionsType
actions. Always False for an instance of a AnalyzeActionsResult.
:ivar action_type: The type of action this class is a result of.
:vartype action_type: str or ~azure.ai.textanalytics.AnalyzeActionsType
:ivar ~datetime.datetime completed_on: Date and time (UTC) when the result completed
on the service.
:ivar statistics: Overall statistics for the action result.
Expand All @@ -1390,7 +1390,7 @@ def __init__(self, **kwargs):
self.statistics = kwargs.get("statistics")

def __repr__(self):
return "AnalyzeBatchActionsResult(document_results={}, is_error={}, action_type={}, completed_on={}, " \
return "AnalyzeActionsResult(document_results={}, is_error={}, action_type={}, completed_on={}, " \
"statistics={})".format(
repr(self.document_results),
self.is_error,
Expand All @@ -1399,8 +1399,9 @@ def __repr__(self):
repr(self.statistics)
)[:1024]

class AnalyzeBatchActionsError(DictMixin):
"""AnalyzeBatchActionsError is an error object which represents an an

class AnalyzeActionsError(DictMixin):
"""AnalyzeActionsError is an error object which represents an an
error response for an action.
:ivar error: The action result error.
Expand All @@ -1414,7 +1415,7 @@ def __init__(self, **kwargs):
self.is_error = True

def __repr__(self):
return "AnalyzeBatchActionsError(error={}, is_error={}".format(
return "AnalyzeActionsError(error={}, is_error={}".format(
repr(self.error), self.is_error
)

Expand All @@ -1428,8 +1429,8 @@ def _from_generated(cls, error):
class RecognizeEntitiesAction(DictMixin):
"""RecognizeEntitiesAction encapsulates the parameters for starting a long-running Entities Recognition operation.
If you just want to recognize entities in a list of documents, and not perform a batch
of long running actions on the input of documents, call method `recognize_entities` instead
If you just want to recognize entities in a list of documents, and not perform multiple
long running actions on the input of documents, call method `recognize_entities` instead
of interfacing with this model.
:keyword str model_version: The model version to use for the analysis.
Expand Down Expand Up @@ -1465,8 +1466,8 @@ class AnalyzeSentimentAction(DictMixin):
"""AnalyzeSentimentAction encapsulates the parameters for starting a long-running
Sentiment Analysis operation.
If you just want to analyze sentiment in a list of documents, and not perform a batch
of long running actions on the input of documents, call method `analyze_sentiment` instead
If you just want to analyze sentiment in a list of documents, and not perform multiple
long running actions on the input of documents, call method `analyze_sentiment` instead
of interfacing with this model.
:keyword str model_version: The model version to use for the analysis.
Expand Down Expand Up @@ -1517,8 +1518,8 @@ class RecognizePiiEntitiesAction(DictMixin):
"""RecognizePiiEntitiesAction encapsulates the parameters for starting a long-running PII
Entities Recognition operation.
If you just want to recognize pii entities in a list of documents, and not perform a batch
of long running actions on the input of documents, call method `recognize_pii_entities` instead
If you just want to recognize pii entities in a list of documents, and not perform multiple
long running actions on the input of documents, call method `recognize_pii_entities` instead
of interfacing with this model.
:keyword str model_version: The model version to use for the analysis.
Expand Down Expand Up @@ -1563,8 +1564,8 @@ class ExtractKeyPhrasesAction(DictMixin):
"""ExtractKeyPhrasesAction encapsulates the parameters for starting a long-running key phrase
extraction operation
If you just want to extract key phrases from a list of documents, and not perform a batch
of long running actions on the input of documents, call method `extract_key_phrases` instead
If you just want to extract key phrases from a list of documents, and not perform multiple
long running actions on the input of documents, call method `extract_key_phrases` instead
of interfacing with this model.
:keyword str model_version: The model version to use for the analysis.
Expand All @@ -1590,8 +1591,8 @@ class RecognizeLinkedEntitiesAction(DictMixin):
"""RecognizeEntitiesAction encapsulates the parameters for starting a long-running Linked Entities
Recognition operation.
If you just want to recognize linked entities in a list of documents, and not perform a batch
of long running actions on the input of documents, call method `recognize_linked_entities` instead
If you just want to recognize linked entities in a list of documents, and not perform multiple
long running actions on the input of documents, call method `recognize_linked_entities` instead
of interfacing with this model.
:keyword str model_version: The model version to use for the analysis.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
RecognizePiiEntitiesAction,
RecognizeLinkedEntitiesAction,
AnalyzeSentimentAction,
AnalyzeBatchActionsType,
AnalyzeActionsType,
)

def _validate_input(documents, hint, whole_input_hint):
Expand Down Expand Up @@ -71,14 +71,14 @@ def _validate_input(documents, hint, whole_input_hint):

def _determine_action_type(action):
if isinstance(action, RecognizeEntitiesAction):
return AnalyzeBatchActionsType.RECOGNIZE_ENTITIES
return AnalyzeActionsType.RECOGNIZE_ENTITIES
if isinstance(action, RecognizePiiEntitiesAction):
return AnalyzeBatchActionsType.RECOGNIZE_PII_ENTITIES
return AnalyzeActionsType.RECOGNIZE_PII_ENTITIES
if isinstance(action, RecognizeLinkedEntitiesAction):
return AnalyzeBatchActionsType.RECOGNIZE_LINKED_ENTITIES
return AnalyzeActionsType.RECOGNIZE_LINKED_ENTITIES
if isinstance(action, AnalyzeSentimentAction):
return AnalyzeBatchActionsType.ANALYZE_SENTIMENT
return AnalyzeBatchActionsType.EXTRACT_KEY_PHRASES
return AnalyzeActionsType.ANALYZE_SENTIMENT
return AnalyzeActionsType.EXTRACT_KEY_PHRASES

def _check_string_index_type_arg(string_index_type_arg, api_version, string_index_type_default="UnicodeCodePoint"):
string_index_type = None
Expand Down
Loading

0 comments on commit f62cb98

Please sign in to comment.