-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Text Analytics] Add support for extract summary actions (#16304)
* [Text Analytics] Add support for extract summary actions * add a test case * update readme * edit * edit * edit * regenerate using latest swagger * edit * edit * address feedback * edit * edit
- Loading branch information
1 parent
35f86a6
commit f4730cf
Showing
17 changed files
with
737 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
/** | ||
* @internal | ||
*/ | ||
export const SDK_VERSION: string = "5.1.1"; | ||
export const SDK_VERSION: string = "5.2.0-beta.1"; |
74 changes: 74 additions & 0 deletions
74
sdk/textanalytics/ai-text-analytics/src/extractSummaryResult.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { | ||
makeTextAnalyticsSuccessResult, | ||
TextAnalyticsSuccessResult, | ||
TextAnalyticsErrorResult, | ||
makeTextAnalyticsErrorResult | ||
} from "./textAnalyticsResult"; | ||
import { | ||
TextAnalyticsError, | ||
ExtractedDocumentSummary, | ||
ExtractedSummarySentence as GeneratedSummarySentences | ||
} from "./generated/models"; | ||
|
||
/** | ||
* The result of the extract summary operation on a single document. | ||
*/ | ||
export type ExtractSummaryResult = ExtractSummarySuccessResult | ExtractSummaryErrorResult; | ||
|
||
/** | ||
* The result of the extract summary operation on a single document, | ||
* containing a collection of the summary identified in that document. | ||
*/ | ||
export interface ExtractSummarySuccessResult extends TextAnalyticsSuccessResult { | ||
/** | ||
* A list of sentences composing a summary of the input document. | ||
*/ | ||
sentences: SummarySentence[]; | ||
} | ||
|
||
/** | ||
* An extracted sentence as part of the summary of a document. | ||
*/ | ||
export interface SummarySentence { | ||
/** The extracted sentence text. */ | ||
text: string; | ||
/** A double value representing the relevance of the sentence within the summary. Higher values indicate higher importance. */ | ||
rankScore: number; | ||
/** The sentence offset from the start of the document, based on the value of the stringIndexType parameter. */ | ||
offset: number; | ||
/** The length of the sentence. */ | ||
length: number; | ||
} | ||
|
||
/** | ||
* An error result from the extract summary operation on a single document. | ||
*/ | ||
export type ExtractSummaryErrorResult = TextAnalyticsErrorResult; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export function makeExtractSummaryResult( | ||
result: ExtractedDocumentSummary | ||
): ExtractSummarySuccessResult { | ||
const { id, warnings, statistics, sentences } = result; | ||
return { | ||
...makeTextAnalyticsSuccessResult(id, warnings, statistics), | ||
sentences: sentences.map((sentence: GeneratedSummarySentences) => ({ | ||
...sentence | ||
})) | ||
}; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export function makeExtractSummaryErrorResult( | ||
id: string, | ||
error: TextAnalyticsError | ||
): ExtractSummaryErrorResult { | ||
return makeTextAnalyticsErrorResult(id, error); | ||
} |
47 changes: 47 additions & 0 deletions
47
sdk/textanalytics/ai-text-analytics/src/extractSummaryResultArray.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { | ||
TextDocumentBatchStatistics, | ||
TextDocumentInput, | ||
ExtractiveSummarizationResult | ||
} from "./generated/models"; | ||
import { | ||
ExtractSummaryResult, | ||
makeExtractSummaryResult, | ||
makeExtractSummaryErrorResult | ||
} from "./extractSummaryResult"; | ||
import { combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVersion } from "./textAnalyticsResult"; | ||
|
||
/** | ||
* Array of `ExtractSummaryResult` objects corresponding to a batch of input documents, and | ||
* annotated with information about the batch operation. | ||
*/ | ||
export interface ExtractSummaryResultArray extends Array<ExtractSummaryResult> { | ||
/** | ||
* Statistics about the input document batch and how it was processed | ||
* by the service. This property will have a value when includeStatistics is set to true | ||
* in the client call. | ||
*/ | ||
statistics?: TextDocumentBatchStatistics; | ||
/** | ||
* The version of the text analytics model used by this operation on this | ||
* batch of input documents. | ||
*/ | ||
modelVersion: string; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export function makeExtractSummaryResultArray( | ||
input: TextDocumentInput[], | ||
response: ExtractiveSummarizationResult | ||
): ExtractSummaryResultArray { | ||
return combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVersion( | ||
input, | ||
response, | ||
makeExtractSummaryResult, | ||
makeExtractSummaryErrorResult | ||
); | ||
} |
Oops, something went wrong.