Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export type AnalyzeActionsPollerLike = PollerLike<AnalyzeActionsOperationState,
// @public
export interface AnalyzeActionsResult {
analyzeSentimentResults: AnalyzeSentimentActionResult[];
customClassifyDocumentMultiCategories?: CustomClassifyDocumentMultiCategoriesActionResult[];
customClassifyDocumentSingleCategory?: CustomClassifyDocumentSingleCategoryActionResult[];
customRecognizeEntities?: CustomRecognizeEntitiesActionResult[];
customClassifyDocumentMultiCategoriesResults: CustomClassifyDocumentMultiCategoriesActionResult[];
customClassifyDocumentSingleCategoryResults: CustomClassifyDocumentSingleCategoryActionResult[];
customRecognizeEntitiesResults: CustomRecognizeEntitiesActionResult[];
extractKeyPhrasesResults: ExtractKeyPhrasesActionResult[];
extractSummaryResults: ExtractSummaryActionResult[];
recognizeEntitiesResults: RecognizeCategorizedEntitiesActionResult[];
Expand Down Expand Up @@ -789,9 +789,9 @@ export interface TextAnalyticsActionErrorResult {
// @public
export interface TextAnalyticsActions {
analyzeSentimentActions?: AnalyzeSentimentAction[];
customClassifyDocumentMultiCategories?: CustomClassifyDocumentMultiCategoriesAction[];
customClassifyDocumentSingleCategory?: CustomClassifyDocumentSingleCategoryAction[];
customRecognizeEntities?: CustomRecognizeEntitiesAction[];
customClassifyDocumentMultiCategoriesActions?: CustomClassifyDocumentMultiCategoriesAction[];
customClassifyDocumentSingleCategoryActions?: CustomClassifyDocumentSingleCategoryAction[];
customRecognizeEntitiesActions?: CustomRecognizeEntitiesAction[];
extractKeyPhrasesActions?: ExtractKeyPhrasesAction[];
extractSummaryActions?: ExtractSummaryAction[];
recognizeEntitiesActions?: RecognizeCategorizedEntitiesAction[];
Expand Down Expand Up @@ -899,7 +899,6 @@ export type TokenSentimentValue = "positive" | "mixed" | "negative";
// @public
export type WarningCode = string;


// (No @packageDocumentation comment for this package)

```
12 changes: 6 additions & 6 deletions sdk/textanalytics/ai-text-analytics/src/analyzeActionsResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ export interface AnalyzeActionsResult {
/**
* Array of the results for each recognize custom entities action.
*/
customRecognizeEntities?: CustomRecognizeEntitiesActionResult[];
customRecognizeEntitiesResults: CustomRecognizeEntitiesActionResult[];
/**
* Array of the results for each custom classify document single category action.
*/
customClassifyDocumentSingleCategory?: CustomClassifyDocumentSingleCategoryActionResult[];
customClassifyDocumentSingleCategoryResults: CustomClassifyDocumentSingleCategoryActionResult[];
/**
* Array of the results for each custom classify document multi categories action.
*/
customClassifyDocumentMultiCategories?: CustomClassifyDocumentMultiCategoriesActionResult[];
customClassifyDocumentMultiCategoriesResults: CustomClassifyDocumentMultiCategoriesActionResult[];
}

/**
Expand Down Expand Up @@ -637,19 +637,19 @@ export function createAnalyzeActionsResult(
response.tasks.extractiveSummarizationTasks ?? [],
extractSummarySentencesActionErrors
),
customRecognizeEntities: makeActionResult(
customRecognizeEntitiesResults: makeActionResult(
documents,
makeCustomRecognizeEntitiesResultArray,
response.tasks.customEntityRecognitionTasks ?? [],
customRecognizeEntitiesActionErrors
),
customClassifyDocumentSingleCategory: makeActionResult(
customClassifyDocumentSingleCategoryResults: makeActionResult(
documents,
makeCustomClassifyDocumentSingleCategoryResultArray,
response.tasks.customSingleClassificationTasks ?? [],
customClassifyDocumentSingleCategoryActionErrors
),
customClassifyDocumentMultiCategories: makeActionResult(
customClassifyDocumentMultiCategoriesResults: makeActionResult(
documents,
makeCustomClassifyDocumentMultiCategoriesResultArray,
response.tasks.customMultiClassificationTasks ?? [],
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions sdk/textanalytics/ai-text-analytics/src/textAnalyticsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,15 +410,15 @@ export interface TextAnalyticsActions {
/**
* A collection of descriptions of custom entity recognition actions. However, currently, the service can accept up to one action only for `customRecognizeEntities`.
*/
customRecognizeEntities?: CustomRecognizeEntitiesAction[];
customRecognizeEntitiesActions?: CustomRecognizeEntitiesAction[];
/**
* A collection of descriptions of custom single classification actions. However, currently, the service can accept up to one action only for `customClassifyDocumentSingleCategory`.
*/
customClassifyDocumentSingleCategory?: CustomClassifyDocumentSingleCategoryAction[];
customClassifyDocumentSingleCategoryActions?: CustomClassifyDocumentSingleCategoryAction[];
/**
* A collection of descriptions of custom multi classification actions. However, currently, the service can accept up to one action only for `customClassifyDocumentMultiCategories`.
*/
customClassifyDocumentMultiCategories?: CustomClassifyDocumentMultiCategoriesAction[];
customClassifyDocumentMultiCategoriesActions?: CustomClassifyDocumentMultiCategoriesAction[];
}
/**
* Client class for interacting with Azure Text Analytics.
Expand Down Expand Up @@ -1204,13 +1204,13 @@ function compileAnalyzeInput(actions: TextAnalyticsActions): GeneratedActions {
extractiveSummarizationTasks: actions.extractSummaryActions?.map(
compose(setStrEncodingParam, compose(setSentenceCount, compose(setOrderBy, addParamsToTask)))
),
customEntityRecognitionTasks: actions.customRecognizeEntities?.map(
customEntityRecognitionTasks: actions.customRecognizeEntitiesActions?.map(
compose(setStrEncodingParam, addParamsToTask)
),
customSingleClassificationTasks: actions.customClassifyDocumentSingleCategory?.map(
customSingleClassificationTasks: actions.customClassifyDocumentSingleCategoryActions?.map(
addParamsToTask
),
customMultiClassificationTasks: actions.customClassifyDocumentMultiCategories?.map(
customMultiClassificationTasks: actions.customClassifyDocumentMultiCategoriesActions?.map(
addParamsToTask
)
};
Expand Down
3 changes: 2 additions & 1 deletion sdk/textanalytics/ai-text-analytics/swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ generate-metadata: false
license-header: MICROSOFT_MIT_NO_VERSION
output-folder: ../
source-code-folder-path: ./src/generated
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/5efb2eca2fc3d94f27015f5d3176786c7497f946/specification/cognitiveservices/data-plane/TextAnalytics/preview/v3.2-preview.2/TextAnalytics.json
# input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/5efb2eca2fc3d94f27015f5d3176786c7497f946/specification/cognitiveservices/data-plane/TextAnalytics/preview/v3.2-preview.2/TextAnalytics.json
input-file: https://raw.githubusercontent.com/deyaaeldeen/azure-rest-api-specs/textanalytics/v3.2-preview.2-patched/specification/cognitiveservices/data-plane/TextAnalytics/preview/v3.2-preview.2/TextAnalytics.json
add-credentials: false
package-version: 5.2.0-beta.2
v3: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,164 @@ matrix([["APIKey", "AAD"]] as const, async (authMethod: AuthMethod) => {
});

describe("#analyze", function() {
it("single custom entity recognition action", async function() {
const docs = [
{
id: "1",
language: "en",
text:
"A recent report by the Government Accountability Office (GAO) found that the dramatic increase in oil and natural gas development on federal lands over the past six years has stretched the staff of the BLM to a point that it has been unable to meet its environmental protection responsibilities."
}
];

const poller = await client.beginAnalyzeActions(
docs,
{
customRecognizeEntitiesActions: [
{
projectName: "88ee0f78-fbca-444d-98e2-7c4c8631e494",
deploymentName: "88ee0f78-fbca-444d-98e2-7c4c8631e494"
}
]
},
{
updateIntervalInMs: pollingInterval
}
);
const results = await poller.pollUntilDone();
for await (const page of results) {
const entitiesResult = page.customRecognizeEntitiesResults;
if (entitiesResult.length === 1) {
const action = entitiesResult[0];
if (!action.error) {
for (const result of action.results) {
if (!result.error) {
assert.ok(result.id);
assert.ok(result.entities);
for (const entity of result.entities) {
assert.ok(entity.category, "entity category not found");
assert.ok(entity.confidenceScore, "confidence score not found");
assert.ok(entity.length, "length not found");
assert.ok(entity.offset, "offset not found");
assert.ok(entity.text, "text not found");
}
} else {
assert.fail("did not expect document errors but got one.");
}
}
}
} else {
assert.fail("expected an array of entities results but did not get one.");
}
}
});

it("single custom document single category classification action", async function() {
const docs = [
{
id: "1",
language: "en",
text:
"A recent report by the Government Accountability Office (GAO) found that the dramatic increase in oil and natural gas development on federal lands over the past six years has stretched the staff of the BLM to a point that it has been unable to meet its environmental protection responsibilities."
}
];

const poller = await client.beginAnalyzeActions(
docs,
{
customClassifyDocumentSingleCategoryActions: [
{
projectName: "659c1851-be0b-4142-b12a-087da9785926",
deploymentName: "659c1851-be0b-4142-b12a-087da9785926"
}
]
},
{
updateIntervalInMs: pollingInterval
}
);
const results = await poller.pollUntilDone();
for await (const page of results) {
const classificationResult = page.customClassifyDocumentSingleCategoryResults;
if (classificationResult.length === 1) {
const action = classificationResult[0];
if (!action.error) {
for (const result of action.results) {
if (!result.error) {
assert.ok(result.id);
assert.ok(result.classification);
assert.ok(result.classification.category);
assert.ok(result.classification.confidenceScore);
} else {
assert.fail("did not expect document errors but got one.");
}
}
}
} else {
assert.fail(
`expected an array of single category classification results but got: ${JSON.stringify(
classificationResult
)}`
);
}
}
});

it("single custom document multiple category classification action", async function() {
const docs = [
{
id: "1",
language: "en",
text:
"A recent report by the Government Accountability Office (GAO) found that the dramatic increase in oil and natural gas development on federal lands over the past six years has stretched the staff of the BLM to a point that it has been unable to meet its environmental protection responsibilities."
}
];

const poller = await client.beginAnalyzeActions(
docs,
{
customClassifyDocumentMultiCategoriesActions: [
{
projectName: "7cdace98-537b-494a-b69a-c19754718025",
deploymentName: "7cdace98-537b-494a-b69a-c19754718025"
}
]
},
{
updateIntervalInMs: pollingInterval
}
);
const results = await poller.pollUntilDone();
for await (const page of results) {
const classificationResult = page.customClassifyDocumentMultiCategoriesResults;
if (classificationResult.length === 1) {
const action = classificationResult[0];
if (!action.error) {
for (const result of action.results) {
if (!result.error) {
assert.ok(result.id);
assert.ok(result.classifications);
for (const classification of result.classifications) {
assert.ok(classification.category);
assert.ok(classification.confidenceScore);
}
} else {
assert.fail(
`did not expect document errors but got: ${JSON.stringify(
classificationResult
)}`
);
}
}
}
} else {
assert.fail(
"expected an array of multi category classification results but did not get one."
);
}
}
});

it("single extract summary action", async function() {
// Source: https://news.microsoft.com/innovation-stories/cloud-pc-windows-365/
const windows365ArticlePart1 = `
Expand Down