Skip to content

Commit

Permalink
[TA] Abstractive Summarization and Extractive Summarization beSpokeMe…
Browse files Browse the repository at this point in the history
…thod (Azure#33198)
  • Loading branch information
mssfang authored Feb 10, 2023
1 parent 4ca4fe4 commit 7617d81
Show file tree
Hide file tree
Showing 61 changed files with 5,101 additions and 375 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 @@ -3,6 +3,12 @@
## 5.3.0-beta.2 (Unreleased)

### Features Added
- Added the following methods for performing abstractive summarization and extractive summarization actions:
- `beginAbstractSummary(...)`
- `beginExtractSummary(...)`
- Added the following types for the newly added methods
- `AbstractSummaryOperationDetail`, `AbstractSummaryOptions`, `AbstractSummaryPagedFlux`, `AbstractSummaryPagedIterable`
- `ExtractSummaryOperationDetail`, `ExtractSummaryOptions`, `ExtractSummaryPagedFlux`, `ExtractSummaryPagedIterable`

### Breaking Changes

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
import com.azure.ai.textanalytics.models.TextDocumentInput;
import com.azure.ai.textanalytics.util.AnalyzeActionsResultPagedFlux;
import com.azure.ai.textanalytics.util.AnalyzeActionsResultPagedIterable;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
Expand Down Expand Up @@ -160,9 +159,12 @@
import static com.azure.ai.textanalytics.TextAnalyticsAsyncClient.COGNITIVE_TRACING_NAMESPACE_VALUE;
import static com.azure.ai.textanalytics.implementation.Utility.DEFAULT_POLL_INTERVAL;
import static com.azure.ai.textanalytics.implementation.Utility.enableSyncRestProxy;
import static com.azure.ai.textanalytics.implementation.Utility.getHttpResponseException;
import static com.azure.ai.textanalytics.implementation.Utility.getShowStatsContinuesToken;
import static com.azure.ai.textanalytics.implementation.Utility.getSkipContinuesToken;
import static com.azure.ai.textanalytics.implementation.Utility.getTopContinuesToken;
import static com.azure.ai.textanalytics.implementation.Utility.getUnsupportedServiceApiVersionMessage;
import static com.azure.ai.textanalytics.implementation.Utility.inputDocumentsValidation;
import static com.azure.ai.textanalytics.implementation.Utility.mapToHttpResponseExceptionIfExists;
import static com.azure.ai.textanalytics.implementation.Utility.parseNextLink;
import static com.azure.ai.textanalytics.implementation.Utility.parseOperationId;
import static com.azure.ai.textanalytics.implementation.Utility.throwIfTargetServiceVersionFound;
Expand Down Expand Up @@ -369,7 +371,7 @@ SyncPoller<AnalyzeActionsOperationDetail, AnalyzeActionsResultPagedIterable> beg
operationId -> getAnalyzeOperationPageIterable(
operationId, null, null, finalIncludeStatistics, finalContext)));
} catch (ErrorResponseException ex) {
throw LOGGER.logExceptionAsError((HttpResponseException) mapToHttpResponseExceptionIfExists(ex));
throw LOGGER.logExceptionAsError(getHttpResponseException(ex));
}
}

Expand Down Expand Up @@ -937,9 +939,9 @@ PagedResponse<AnalyzeActionsResult> getPageSync(String continuationToken, UUID o
Integer skip, boolean showStats, Context context) {
if (continuationToken != null) {
final Map<String, Object> continuationTokenMap = parseNextLink(continuationToken);
top = (Integer) continuationTokenMap.getOrDefault("$top", null);
skip = (Integer) continuationTokenMap.getOrDefault("$skip", null);
showStats = (Boolean) continuationTokenMap.getOrDefault(showStats, false);
top = getTopContinuesToken(continuationTokenMap);
skip = getSkipContinuesToken(continuationTokenMap);
showStats = getShowStatsContinuesToken(continuationTokenMap);
}
return service != null
? toAnalyzeActionsResultPagedResponseLanguageApi(service.jobStatusWithResponse(
Expand All @@ -952,30 +954,17 @@ Mono<PagedResponse<AnalyzeActionsResult>> getPage(String continuationToken, UUID
Integer skip, boolean showStats, Context context) {
if (continuationToken != null) {
final Map<String, Object> continuationTokenMap = parseNextLink(continuationToken);
final Integer topValue = (Integer) continuationTokenMap.getOrDefault("$top", null);
final Integer skipValue = (Integer) continuationTokenMap.getOrDefault("$skip", null);
final Boolean showStatsValue = (Boolean) continuationTokenMap.getOrDefault(showStats, false);

if (service != null) {
return service.jobStatusWithResponseAsync(operationId, showStatsValue, topValue, skipValue,
context)
.map(this::toAnalyzeActionsResultPagedResponseLanguageApi)
.onErrorMap(Utility::mapToHttpResponseExceptionIfExists);
}
return legacyService.analyzeStatusWithResponseAsync(operationId.toString(), showStatsValue, topValue, skipValue,
context)
.map(this::toAnalyzeActionsResultPagedResponseLegacyApi)
.onErrorMap(Utility::mapToHttpResponseExceptionIfExists);
} else {
if (service != null) {
return service.jobStatusWithResponseAsync(operationId, showStats, top, skip, context)
.map(this::toAnalyzeActionsResultPagedResponseLanguageApi)
.onErrorMap(Utility::mapToHttpResponseExceptionIfExists);
}
return legacyService.analyzeStatusWithResponseAsync(operationId.toString(), showStats, top, skip, context)
.map(this::toAnalyzeActionsResultPagedResponseLegacyApi)
.onErrorMap(Utility::mapToHttpResponseExceptionIfExists);
top = getTopContinuesToken(continuationTokenMap);
skip = getSkipContinuesToken(continuationTokenMap);
showStats = getShowStatsContinuesToken(continuationTokenMap);
}
return service != null
? service.jobStatusWithResponseAsync(operationId, showStats, top, skip, context)
.map(this::toAnalyzeActionsResultPagedResponseLanguageApi)
.onErrorMap(Utility::mapToHttpResponseExceptionIfExists)
: legacyService.analyzeStatusWithResponseAsync(operationId.toString(), showStats, top, skip, context)
.map(this::toAnalyzeActionsResultPagedResponseLegacyApi)
.onErrorMap(Utility::mapToHttpResponseExceptionIfExists);
}

private PagedResponse<AnalyzeActionsResult> toAnalyzeActionsResultPagedResponseLegacyApi(Response<AnalyzeJobState> response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import com.azure.ai.textanalytics.util.AnalyzeHealthcareEntitiesPagedFlux;
import com.azure.ai.textanalytics.util.AnalyzeHealthcareEntitiesPagedIterable;
import com.azure.ai.textanalytics.util.AnalyzeHealthcareEntitiesResultCollection;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
Expand All @@ -66,7 +65,11 @@
import static com.azure.ai.textanalytics.TextAnalyticsAsyncClient.COGNITIVE_TRACING_NAMESPACE_VALUE;
import static com.azure.ai.textanalytics.implementation.Utility.DEFAULT_POLL_INTERVAL;
import static com.azure.ai.textanalytics.implementation.Utility.enableSyncRestProxy;
import static com.azure.ai.textanalytics.implementation.Utility.getHttpResponseException;
import static com.azure.ai.textanalytics.implementation.Utility.getNotNullContext;
import static com.azure.ai.textanalytics.implementation.Utility.getShowStatsContinuesToken;
import static com.azure.ai.textanalytics.implementation.Utility.getSkipContinuesToken;
import static com.azure.ai.textanalytics.implementation.Utility.getTopContinuesToken;
import static com.azure.ai.textanalytics.implementation.Utility.getUnsupportedServiceApiVersionMessage;
import static com.azure.ai.textanalytics.implementation.Utility.inputDocumentsValidation;
import static com.azure.ai.textanalytics.implementation.Utility.mapToHttpResponseExceptionIfExists;
Expand Down Expand Up @@ -248,7 +251,7 @@ class AnalyzeHealthcareEntityUtilClient {
finalIncludeStatistics, finalContext))
);
} catch (ErrorResponseException ex) {
throw LOGGER.logExceptionAsError((HttpResponseException) mapToHttpResponseExceptionIfExists(ex));
throw LOGGER.logExceptionAsError(getHttpResponseException(ex));
}
}

Expand All @@ -271,30 +274,17 @@ Mono<PagedResponse<AnalyzeHealthcareEntitiesResultCollection>> getPagedResult(St
try {
if (continuationToken != null) {
final Map<String, Object> continuationTokenMap = parseNextLink(continuationToken);
final Integer topValue = (Integer) continuationTokenMap.getOrDefault("$top", null);
final Integer skipValue = (Integer) continuationTokenMap.getOrDefault("$skip", null);
final Boolean showStatsValue = (Boolean) continuationTokenMap.getOrDefault(showStats, false);
if (service != null) {
return service.jobStatusWithResponseAsync(operationId, showStatsValue, topValue, skipValue,
context)
.map(this::toHealthcarePagedResponse)
.onErrorMap(Utility::mapToHttpResponseExceptionIfExists);
}

return legacyService.healthStatusWithResponseAsync(operationId, topValue, skipValue, showStatsValue,
context)
.map(this::toTextAnalyticsPagedResponse)
.onErrorMap(Utility::mapToHttpResponseExceptionIfExists);
} else {
if (service != null) {
return service.jobStatusWithResponseAsync(operationId, showStats, top, skip, context)
.map(this::toHealthcarePagedResponse)
.onErrorMap(Utility::mapToHttpResponseExceptionIfExists);
}
return legacyService.healthStatusWithResponseAsync(operationId, top, skip, showStats, context)
.map(this::toTextAnalyticsPagedResponse)
.onErrorMap(Utility::mapToHttpResponseExceptionIfExists);
top = getTopContinuesToken(continuationTokenMap);
skip = getSkipContinuesToken(continuationTokenMap);
showStats = getShowStatsContinuesToken(continuationTokenMap);
}
return service != null
? service.jobStatusWithResponseAsync(operationId, showStats, top, skip, context)
.map(this::toHealthcarePagedResponse)
.onErrorMap(Utility::mapToHttpResponseExceptionIfExists)
: legacyService.healthStatusWithResponseAsync(operationId, top, skip, showStats, context)
.map(this::toTextAnalyticsPagedResponse)
.onErrorMap(Utility::mapToHttpResponseExceptionIfExists);
} catch (RuntimeException ex) {
return monoError(LOGGER, ex);
}
Expand All @@ -304,9 +294,9 @@ PagedResponse<AnalyzeHealthcareEntitiesResultCollection> getPagedResultSync(Stri
UUID operationId, Integer top, Integer skip, boolean showStats, Context context) {
if (continuationToken != null) {
final Map<String, Object> continuationTokenMap = parseNextLink(continuationToken);
top = (Integer) continuationTokenMap.getOrDefault("$top", null);
skip = (Integer) continuationTokenMap.getOrDefault("$skip", null);
showStats = (Boolean) continuationTokenMap.getOrDefault(showStats, false);
top = getTopContinuesToken(continuationTokenMap);
skip = getSkipContinuesToken(continuationTokenMap);
showStats = getShowStatsContinuesToken(continuationTokenMap);
}
return service != null
? toHealthcarePagedResponse(service.jobStatusWithResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.azure.ai.textanalytics.models.AnalyzeSentimentOptions;
import com.azure.ai.textanalytics.models.TextDocumentInput;
import com.azure.ai.textanalytics.util.AnalyzeSentimentResultCollection;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
Expand All @@ -28,10 +27,10 @@
import static com.azure.ai.textanalytics.TextAnalyticsAsyncClient.COGNITIVE_TRACING_NAMESPACE_VALUE;
import static com.azure.ai.textanalytics.implementation.Utility.enableSyncRestProxy;
import static com.azure.ai.textanalytics.implementation.Utility.getDocumentCount;
import static com.azure.ai.textanalytics.implementation.Utility.getHttpResponseException;
import static com.azure.ai.textanalytics.implementation.Utility.getNotNullContext;
import static com.azure.ai.textanalytics.implementation.Utility.getUnsupportedServiceApiVersionMessage;
import static com.azure.ai.textanalytics.implementation.Utility.inputDocumentsValidation;
import static com.azure.ai.textanalytics.implementation.Utility.mapToHttpResponseExceptionIfExists;
import static com.azure.ai.textanalytics.implementation.Utility.throwIfTargetServiceVersionFound;
import static com.azure.ai.textanalytics.implementation.Utility.toAnalyzeSentimentResultCollectionResponseLanguageApi;
import static com.azure.ai.textanalytics.implementation.Utility.toAnalyzeSentimentResultCollectionResponseLegacyApi;
Expand Down Expand Up @@ -182,7 +181,7 @@ Response<AnalyzeSentimentResultCollection> getAnalyzedSentimentResponseSync(
StringIndexType.UTF16CODE_UNIT,
context));
} catch (ErrorResponseException ex) {
throw LOGGER.logExceptionAsError((HttpResponseException) mapToHttpResponseExceptionIfExists(ex));
throw LOGGER.logExceptionAsError(getHttpResponseException(ex));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.azure.ai.textanalytics.models.DetectLanguageResult;
import com.azure.ai.textanalytics.models.TextAnalyticsRequestOptions;
import com.azure.ai.textanalytics.util.DetectLanguageResultCollection;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
Expand All @@ -28,10 +27,10 @@
import static com.azure.ai.textanalytics.TextAnalyticsAsyncClient.COGNITIVE_TRACING_NAMESPACE_VALUE;
import static com.azure.ai.textanalytics.implementation.Utility.enableSyncRestProxy;
import static com.azure.ai.textanalytics.implementation.Utility.getDocumentCount;
import static com.azure.ai.textanalytics.implementation.Utility.getHttpResponseException;
import static com.azure.ai.textanalytics.implementation.Utility.getNotNullContext;
import static com.azure.ai.textanalytics.implementation.Utility.getUnsupportedServiceApiVersionMessage;
import static com.azure.ai.textanalytics.implementation.Utility.inputDocumentsValidation;
import static com.azure.ai.textanalytics.implementation.Utility.mapToHttpResponseExceptionIfExists;
import static com.azure.ai.textanalytics.implementation.Utility.throwIfTargetServiceVersionFound;
import static com.azure.ai.textanalytics.implementation.Utility.toDetectLanguageResultCollectionLanguageApi;
import static com.azure.ai.textanalytics.implementation.Utility.toDetectLanguageResultCollectionLegacyApi;
Expand Down Expand Up @@ -171,7 +170,7 @@ Response<DetectLanguageResultCollection> getDetectedLanguageResponseSync(
options.isServiceLogsDisabled(),
context));
} catch (ErrorResponseException ex) {
throw LOGGER.logExceptionAsError((HttpResponseException) mapToHttpResponseExceptionIfExists(ex));
throw LOGGER.logExceptionAsError(getHttpResponseException(ex));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.azure.ai.textanalytics.models.DynamicClassificationOptions;
import com.azure.ai.textanalytics.models.TextDocumentInput;
import com.azure.ai.textanalytics.util.DynamicClassifyDocumentResultCollection;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;
import com.azure.core.util.IterableStream;
Expand All @@ -26,10 +25,10 @@
import static com.azure.ai.textanalytics.TextAnalyticsAsyncClient.COGNITIVE_TRACING_NAMESPACE_VALUE;
import static com.azure.ai.textanalytics.implementation.Utility.enableSyncRestProxy;
import static com.azure.ai.textanalytics.implementation.Utility.getDocumentCount;
import static com.azure.ai.textanalytics.implementation.Utility.getHttpResponseException;
import static com.azure.ai.textanalytics.implementation.Utility.getNotNullContext;
import static com.azure.ai.textanalytics.implementation.Utility.getUnsupportedServiceApiVersionMessage;
import static com.azure.ai.textanalytics.implementation.Utility.inputDocumentsValidation;
import static com.azure.ai.textanalytics.implementation.Utility.mapToHttpResponseExceptionIfExists;
import static com.azure.ai.textanalytics.implementation.Utility.throwIfTargetServiceVersionFound;
import static com.azure.ai.textanalytics.implementation.Utility.toDynamicClassifyDocumentResultCollectionResponse;
import static com.azure.ai.textanalytics.implementation.Utility.toMultiLanguageInput;
Expand Down Expand Up @@ -125,7 +124,7 @@ Response<DynamicClassifyDocumentResultCollection> getResultCollectionResponseSyn
enableSyncRestProxy(getNotNullContext(context))
.addData(AZ_TRACING_NAMESPACE_KEY, COGNITIVE_TRACING_NAMESPACE_VALUE)));
} catch (ErrorResponseException ex) {
throw LOGGER.logExceptionAsError((HttpResponseException) mapToHttpResponseExceptionIfExists(ex));
throw LOGGER.logExceptionAsError(getHttpResponseException(ex));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.azure.ai.textanalytics.models.TextAnalyticsRequestOptions;
import com.azure.ai.textanalytics.models.TextDocumentInput;
import com.azure.ai.textanalytics.util.ExtractKeyPhrasesResultCollection;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
Expand All @@ -31,10 +30,10 @@
import static com.azure.ai.textanalytics.TextAnalyticsAsyncClient.COGNITIVE_TRACING_NAMESPACE_VALUE;
import static com.azure.ai.textanalytics.implementation.Utility.enableSyncRestProxy;
import static com.azure.ai.textanalytics.implementation.Utility.getDocumentCount;
import static com.azure.ai.textanalytics.implementation.Utility.getHttpResponseException;
import static com.azure.ai.textanalytics.implementation.Utility.getNotNullContext;
import static com.azure.ai.textanalytics.implementation.Utility.getUnsupportedServiceApiVersionMessage;
import static com.azure.ai.textanalytics.implementation.Utility.inputDocumentsValidation;
import static com.azure.ai.textanalytics.implementation.Utility.mapToHttpResponseExceptionIfExists;
import static com.azure.ai.textanalytics.implementation.Utility.throwIfTargetServiceVersionFound;
import static com.azure.ai.textanalytics.implementation.Utility.toMultiLanguageInput;
import static com.azure.ai.textanalytics.implementation.Utility.toResultCollectionResponseLanguageApi;
Expand Down Expand Up @@ -201,7 +200,7 @@ Response<ExtractKeyPhrasesResultCollection> getExtractedKeyPhrasesResponseSync(
options.isServiceLogsDisabled(),
context));
} catch (ErrorResponseException ex) {
throw LOGGER.logExceptionAsError((HttpResponseException) mapToHttpResponseExceptionIfExists(ex));
throw LOGGER.logExceptionAsError(getHttpResponseException(ex));
}
}

Expand Down
Loading

0 comments on commit 7617d81

Please sign in to comment.