Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TA] merge 2022-10-01-preview feature branch to main #27207

Merged
merged 15 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,9 @@
"verfasst",
"engelska",
"fhir",
"FHIR"
"FHIR",
"naam",
"aenter"
]
},
{
Expand Down
2 changes: 2 additions & 0 deletions scripts/devops_tasks/test_run_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@
"azure-ai-textanalytics": [
"sample_analyze_healthcare_entities_with_cancellation.py",
"sample_analyze_healthcare_entities_with_cancellation_async.py",
"sample_abstract_summary.py",
"sample_abstract_summary_async.py",
]
}

Expand Down
24 changes: 23 additions & 1 deletion sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
# Release History

## 5.2.2 (Unreleased)
## 5.3.0b1 (Unreleased)

### Features Added
- Added the Extractive Summarization feature and related models: `ExtractSummaryAction`, `ExtractSummaryResult`, and `SummarySentence`.
Access the feature through the `begin_analyze_actions` API.
- Added keyword arguments `fhir_version` and `document_type` to `begin_analyze_healthcare_entities` and `AnalyzeHealthcareEntitiesAction`.
- Added property `fhir_bundle` to `AnalyzeHealthcareEntitiesResult`.
- Added property `confidence_score` to `HealthcareRelation`.
- Added enum `HealthcareDocumentType`.
- Added property `resolutions` to `CategorizedEntity`.
- Added models and enums related to resolutions: `BaseResolution`, `ResolutionKind`, `AgeResolution`, `AreaResolution`,
`BooleanResolution`, `CurrencyResolution`, `DateTimeResolution`, `InformationResolution`, `LengthResolution`,
`NumberResolution`, `NumericRangeResolution`, `OrdinalResolution`, `SpeedResolution`, `TemperatureResolution`,
`TemporalSpanResolution`, `VolumeResolution`, `WeightResolution`, `AgeUnit`, `AreaUnit`, `TemporalModifier`,
`InformationUnit`, `LengthUnit`, `NumberKind`, `RangeKind`, `RelativeTo`, `SpeedUnit`, `TemperatureUnit`,
`VolumeUnit`, and `WeightUnit`.
- Added the Abstractive Summarization feature and related models: `AbstractSummaryAction`, `AbstractSummaryResult`, `AbstractiveSummary`,
`SummaryContext`, `PhraseControl`, and `PhraseControlStrategy`. Access the feature through the `begin_analyze_actions` API.
- Added automatic language detection to long-running operation APIs. Pass `auto` into the document `language` hint to use this feature.
- Added `autodetect_default_language` to long-running operation APIs. Pass as the default/fallback language for automatic language detection.
- Added property `detected_language` to `RecognizeEntitiesResult`, `RecognizePiiEntitiesResult`, `AnalyzeHealthcareEntitiesResult`,
`ExtractKeyPhrasesResult`, `RecognizeLinkedEntitiesResult`, `AnalyzeSentimentResult`, `RecognizeCustomEntitiesResult`,
`ClassifyDocumentResult`, `ExtractSummaryResult`, and `AbstractSummaryResult` to indicate the language detected by automatic language detection.
- Added property `script` to `DetectedLanguage` to indicate the script of the input document.
- Added the `dynamic_classification` client method to perform dynamic classification on documents without needing to train a model.

### Breaking Changes

Expand Down
25 changes: 21 additions & 4 deletions sdk/textanalytics/azure-ai-textanalytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ The Azure Cognitive Service for Language is a cloud-based service that provides
- Text Analytics for Health
- Custom Named Entity Recognition
- Custom Text Classification
- Extractive Text Summarization
- Abstractive Text Summarization
- Dynamic Classification

[Source code][source_code] | [Package (PyPI)][ta_pypi] | [API reference documentation][ta_ref_docs] | [Product documentation][language_product_documentation] | [Samples][ta_samples]

Expand Down Expand Up @@ -254,6 +257,9 @@ The following section provides several code snippets covering some of the most c
- [Custom Entity Recognition][recognize_custom_entities_sample]
- [Custom Single Label Classification][single_label_classify_sample]
- [Custom Multi Label Classification][multi_label_classify_sample]
- [Extractive Summarization][extract_summary_sample]
- [Abstractive Summarization][abstract_summary_sample]
- [Dynamic Classification][dynamic_classification_sample]

### Analyze sentiment

Expand Down Expand Up @@ -530,10 +536,12 @@ Note: Healthcare Entities Analysis is only available with API version v3.1 and n
- Linked Entity Recognition
- Key Phrase Extraction
- Sentiment Analysis
- Custom Entity Recognition
- Custom Single Label Classification
- Custom Multi Label Classification
- Healthcare Entities Analysis
- Custom Entity Recognition (API version 2022-05-01 and newer)
- Custom Single Label Classification (API version 2022-05-01 and newer)
- Custom Multi Label Classification (API version 2022-05-01 and newer)
- Healthcare Entities Analysis (API version 2022-05-01 and newer)
- Extractive Summarization (API version 2022-10-01-preview and newer)
- Abstractive Summarization (API version 2022-10-01-preview and newer)

```python
from azure.core.credentials import AzureKeyCredential
Expand Down Expand Up @@ -664,6 +672,9 @@ Common scenarios
- Custom Entity Recognition: [sample_recognize_custom_entities.py][recognize_custom_entities_sample] ([async_version][recognize_custom_entities_sample_async])
- Custom Single Label Classification: [sample_single_label_classify.py][single_label_classify_sample] ([async_version][single_label_classify_sample_async])
- Custom Multi Label Classification: [sample_multi_label_classify.py][multi_label_classify_sample] ([async_version][multi_label_classify_sample_async])
- Extractive text summarization: [sample_extract_summary.py][extract_summary_sample] ([async version][extract_summary_sample_async])
- Abstractive text summarization: [sample_abstract_summary.py][abstract_summary_sample] ([async version][abstract_summary_sample_async])
- Dynamic Classification: [sample_dynamic_classification.py][dynamic_classification_sample] ([async_version][dynamic_classification_sample_async])

Advanced scenarios

Expand Down Expand Up @@ -766,6 +777,12 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
[multi_label_classify_sample]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/textanalytics/azure-ai-textanalytics/samples/sample_multi_label_classify.py
[multi_label_classify_sample_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_multi_label_classify_async.py
[healthcare_action_sample]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_healthcare_action.py
[extract_summary_sample]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/textanalytics/azure-ai-textanalytics/samples/sample_extract_summary.py
[extract_summary_sample_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_extract_summary_async.py
[abstract_summary_sample]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/textanalytics/azure-ai-textanalytics/samples/sample_abstract_summary.py
[abstract_summary_sample_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_abstract_summary_async.py
[dynamic_classification_sample]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/textanalytics/azure-ai-textanalytics/samples/sample_dynamic_classification.py
[dynamic_classification_sample_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_dynamic_classification_async.py
[cla]: https://cla.microsoft.com
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,50 @@
ClassificationCategory,
AnalyzeHealthcareEntitiesAction,
TextAnalysisKind,
ExtractSummaryAction,
ExtractSummaryResult,
SummarySentence,
AbstractSummaryResult,
AbstractiveSummary,
SummaryContext,
PhraseControl,
AbstractSummaryAction,
DynamicClassificationResult,
)
from ._generated.models import (
HealthcareDocumentType,
BaseResolution,
ResolutionKind,
AgeResolution,
AreaResolution,
BooleanResolution,
CurrencyResolution,
DateTimeResolution,
InformationResolution,
LengthResolution,
NumberResolution,
NumericRangeResolution,
OrdinalResolution,
SpeedResolution,
TemperatureResolution,
TemporalSpanResolution,
VolumeResolution,
WeightResolution,
AgeUnit,
AreaUnit,
TemporalModifier,
InformationUnit,
LengthUnit,
NumberKind,
RangeKind,
RelativeTo,
SpeedUnit,
TemperatureUnit,
VolumeUnit,
WeightUnit,
PhraseControlStrategy,
ClassificationType,
)

from ._lro import AnalyzeHealthcareEntitiesLROPoller, AnalyzeActionsLROPoller, TextAnalysisLROPoller

__all__ = [
Expand Down Expand Up @@ -117,6 +159,47 @@
"AnalyzeHealthcareEntitiesAction",
"TextAnalysisLROPoller",
"TextAnalysisKind",
"ExtractSummaryAction",
"ExtractSummaryResult",
"SummarySentence",
"HealthcareDocumentType",
"BaseResolution",
"ResolutionKind",
"AgeResolution",
"AreaResolution",
"BooleanResolution",
"CurrencyResolution",
"DateTimeResolution",
"InformationResolution",
"LengthResolution",
"NumberResolution",
"NumericRangeResolution",
"OrdinalResolution",
"SpeedResolution",
"TemperatureResolution",
"TemporalSpanResolution",
"VolumeResolution",
"WeightResolution",
"AgeUnit",
"AreaUnit",
"TemporalModifier",
"InformationUnit",
"LengthUnit",
"NumberKind",
"RangeKind",
"RelativeTo",
"SpeedUnit",
"TemperatureUnit",
"VolumeUnit",
"WeightUnit",
"AbstractSummaryResult",
"AbstractiveSummary",
"SummaryContext",
"PhraseControlStrategy",
"PhraseControl",
"AbstractSummaryAction",
"ClassificationType",
"DynamicClassificationResult",
]

__version__ = VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class TextAnalyticsApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Cognitive Service for Language or Text Analytics API versions supported by this package"""

#: This is the default version and corresponds to the Cognitive Service for Language API.
V2022_10_01_PREVIEW = "2022-10-01-preview"
#: This version corresponds to the Cognitive Service for Language API.
V2022_05_01 = "2022-05-01"
#: This version corresponds to Text Analytics API.
V3_1 = "v3.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------

class DictMixin:
def __setitem__(self, key, item):
self.__dict__[key] = item

def __getitem__(self, key):
return self.__dict__[key]

def __repr__(self):
return str(self)

def __len__(self):
return len(self.keys())

def __delitem__(self, key):
self.__dict__[key] = None

def __eq__(self, other):
if isinstance(other, self.__class__):
return self.__dict__ == other.__dict__
return False

def __ne__(self, other):
return not self.__eq__(other)

def __contains__(self, key):
return key in self.__dict__

def __str__(self):
return str({k: v for k, v in self.__dict__.items() if not k.startswith("_")})

def has_key(self, k):
return k in self.__dict__

def update(self, *args, **kwargs):
return self.__dict__.update(*args, **kwargs)

def keys(self):
return [k for k in self.__dict__ if not k.startswith("_")]

def values(self):
return [v for k, v in self.__dict__.items() if not k.startswith("_")]

def items(self):
return [(k, v) for k, v in self.__dict__.items() if not k.startswith("_")]

def get(self, key, default=None):
if key in self.__dict__:
return self.__dict__[key]
return default
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def analyze_text(
api_version = self._get_api_version('analyze_text')
if api_version == '2022-05-01':
from .v2022_05_01.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == '2022-10-01-preview':
from .v2022_10_01_preview.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise ValueError("API version {} does not have operation 'analyze_text'".format(api_version))
mixin_instance = OperationClass()
Expand Down Expand Up @@ -142,6 +144,8 @@ def analyze_text_job_status(
api_version = self._get_api_version('analyze_text_job_status')
if api_version == '2022-05-01':
from .v2022_05_01.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == '2022-10-01-preview':
from .v2022_10_01_preview.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise ValueError("API version {} does not have operation 'analyze_text_job_status'".format(api_version))
mixin_instance = OperationClass()
Expand Down Expand Up @@ -222,6 +226,8 @@ def begin_analyze_text_cancel_job(
api_version = self._get_api_version('begin_analyze_text_cancel_job')
if api_version == '2022-05-01':
from .v2022_05_01.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == '2022-10-01-preview':
from .v2022_10_01_preview.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise ValueError("API version {} does not have operation 'begin_analyze_text_cancel_job'".format(api_version))
mixin_instance = OperationClass()
Expand Down Expand Up @@ -266,6 +272,8 @@ def begin_analyze_text_submit_job(
api_version = self._get_api_version('begin_analyze_text_submit_job')
if api_version == '2022-05-01':
from .v2022_05_01.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == '2022-10-01-preview':
from .v2022_10_01_preview.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise ValueError("API version {} does not have operation 'begin_analyze_text_submit_job'".format(api_version))
mixin_instance = OperationClass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(
profile=KnownProfiles.default, # type: KnownProfiles
**kwargs # type: Any
):
if api_version == '2022-05-01':
if api_version == '2022-05-01' or api_version == '2022-10-01-preview':
base_url = '{Endpoint}/language'
elif api_version == 'v3.0':
base_url = '{Endpoint}/text/analytics/v3.0'
Expand All @@ -99,12 +99,16 @@ def models(cls, api_version=DEFAULT_API_VERSION):
"""Module depends on the API version:

* 2022-05-01: :mod:`v2022_05_01.models<azure.ai.textanalytics.v2022_05_01.models>`
* 2022-10-01-preview: :mod:`v2022_10_01_preview.models<azure.ai.textanalytics.v2022_10_01_preview.models>`
* v3.0: :mod:`v3_0.models<azure.ai.textanalytics.v3_0.models>`
* v3.1: :mod:`v3_1.models<azure.ai.textanalytics.v3_1.models>`
"""
if api_version == '2022-05-01':
from .v2022_05_01 import models
return models
elif api_version == '2022-10-01-preview':
from .v2022_10_01_preview import models
return models
elif api_version == 'v3.0':
from .v3_0 import models
return models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ async def analyze_text(
api_version = self._get_api_version('analyze_text')
if api_version == '2022-05-01':
from ..v2022_05_01.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == '2022-10-01-preview':
from ..v2022_10_01_preview.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise ValueError("API version {} does not have operation 'analyze_text'".format(api_version))
mixin_instance = OperationClass()
Expand Down Expand Up @@ -134,6 +136,8 @@ async def analyze_text_job_status(
api_version = self._get_api_version('analyze_text_job_status')
if api_version == '2022-05-01':
from ..v2022_05_01.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == '2022-10-01-preview':
from ..v2022_10_01_preview.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise ValueError("API version {} does not have operation 'analyze_text_job_status'".format(api_version))
mixin_instance = OperationClass()
Expand Down Expand Up @@ -213,6 +217,8 @@ async def begin_analyze_text_cancel_job(
api_version = self._get_api_version('begin_analyze_text_cancel_job')
if api_version == '2022-05-01':
from ..v2022_05_01.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == '2022-10-01-preview':
from ..v2022_10_01_preview.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise ValueError("API version {} does not have operation 'begin_analyze_text_cancel_job'".format(api_version))
mixin_instance = OperationClass()
Expand Down Expand Up @@ -256,6 +262,8 @@ async def begin_analyze_text_submit_job(
api_version = self._get_api_version('begin_analyze_text_submit_job')
if api_version == '2022-05-01':
from ..v2022_05_01.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == '2022-10-01-preview':
from ..v2022_10_01_preview.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise ValueError("API version {} does not have operation 'begin_analyze_text_submit_job'".format(api_version))
mixin_instance = OperationClass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(
profile: KnownProfiles = KnownProfiles.default,
**kwargs # type: Any
) -> None:
if api_version == '2022-05-01':
if api_version == '2022-05-01' or api_version == '2022-10-01-preview':
base_url = '{Endpoint}/language'
elif api_version == 'v3.0':
base_url = '{Endpoint}/text/analytics/v3.0'
Expand All @@ -97,12 +97,16 @@ def models(cls, api_version=DEFAULT_API_VERSION):
"""Module depends on the API version:

* 2022-05-01: :mod:`v2022_05_01.models<azure.ai.textanalytics.v2022_05_01.models>`
* 2022-10-01-preview: :mod:`v2022_10_01_preview.models<azure.ai.textanalytics.v2022_10_01_preview.models>`
* v3.0: :mod:`v3_0.models<azure.ai.textanalytics.v3_0.models>`
* v3.1: :mod:`v3_1.models<azure.ai.textanalytics.v3_1.models>`
"""
if api_version == '2022-05-01':
from ..v2022_05_01 import models
return models
elif api_version == '2022-10-01-preview':
from ..v2022_10_01_preview import models
return models
elif api_version == 'v3.0':
from ..v3_0 import models
return models
Expand Down
Loading