Skip to content

Commit

Permalink
adding analyze and health APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
deyaaeldeen committed Nov 6, 2020
1 parent b92c535 commit cdec7a2
Show file tree
Hide file tree
Showing 25 changed files with 4,237 additions and 414 deletions.
3 changes: 1 addition & 2 deletions sdk/textanalytics/ai-text-analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Release History

## 5.1.0-beta.3 (Unreleased)

## 5.2.0-beta.1 (Unreleased)

## 5.1.0-beta.2 (2020-10-06)

Expand Down
4 changes: 3 additions & 1 deletion sdk/textanalytics/ai-text-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"sdk-type": "client",
"author": "Microsoft Corporation",
"description": "An isomorphic client library for the Azure Text Analytics service.",
"version": "5.1.0-beta.3",
"version": "5.2.0-beta.1",
"keywords": [
"node",
"azure",
Expand Down Expand Up @@ -78,6 +78,8 @@
"dependencies": {
"@azure/core-auth": "^1.1.3",
"@azure/core-http": "^1.2.0",
"@azure/core-lro": "^1.0.2",
"@azure/core-paging": "^1.1.1",
"@azure/core-tracing": "1.0.0-preview.9",
"@azure/logger": "^1.0.0",
"@opentelemetry/api": "^0.10.2",
Expand Down
188 changes: 185 additions & 3 deletions sdk/textanalytics/ai-text-analytics/review/ai-text-analytics.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,50 @@
import { AzureKeyCredential } from '@azure/core-auth';
import { KeyCredential } from '@azure/core-auth';
import { OperationOptions } from '@azure/core-http';
import { PagedAsyncIterableIterator } from '@azure/core-paging';
import { PipelineOptions } from '@azure/core-http';
import { PollerLike } from '@azure/core-lro';
import { PollOperationState } from '@azure/core-lro';
import { TokenCredential } from '@azure/core-auth';

// @public
export interface AnalyzeEntitiesResult extends RecognizeCategorizedEntitiesSuccessResult {
// (undocumented)
type: "Entities";
}

// @public
export interface AnalyzeErrorResult extends TextAnalyticsErrorResult {
// (undocumented)
type: "Error";
}

// @public
export interface AnalyzeJobOptions extends TextAnalyticsOperationOptions {
}

// @public (undocumented)
export interface AnalyzeKeyPhrasesResult extends ExtractKeyPhrasesSuccessResult {
// (undocumented)
type: "KeyPhrases";
}

// @public (undocumented)
export interface AnalyzePiiEntitiesResult extends RecognizePiiEntitiesSuccessResult {
// (undocumented)
type: "PiiEntities";
}

// @public
export type AnalyzePollerLike = PollerLike<BeginAnalyzeOperationState, PaginatedAnalyzeResults>;

// @public
export type AnalyzeResult = AnalyzeEntitiesResult | AnalyzePiiEntitiesResult | AnalyzeKeyPhrasesResult | AnalyzeErrorResult;

// @public
export interface AnalyzeResultsArray extends Array<AnalyzeResult> {
}

// @public
export type AnalyzeSentimentErrorResult = TextAnalyticsErrorResult;

Expand Down Expand Up @@ -52,6 +93,28 @@ export interface AspectSentiment {

export { AzureKeyCredential }

// @public
export type BeginAnalyzeHealthcareOperationState = PollOperationState<PaginatedHealthcareEntities>;

// @public
export interface BeginAnalyzeHealthcareOptions {
// (undocumented)
health?: HealthcareJobOptions;
// (undocumented)
polling?: PollingOptions;
}

// @public
export type BeginAnalyzeOperationState = PollOperationState<PaginatedAnalyzeResults>;

// @public
export interface BeginAnalyzeOptions {
// (undocumented)
analyze?: AnalyzeJobOptions;
// (undocumented)
polling?: PollingOptions;
}

// @public
export interface CategorizedEntity extends Entity {
}
Expand Down Expand Up @@ -95,6 +158,17 @@ export interface DetectLanguageSuccessResult extends TextAnalyticsSuccessResult
// @public
export type DocumentSentimentLabel = "positive" | "neutral" | "negative" | "mixed";

// @public (undocumented)
export type EntitiesTask = {
parameters?: EntitiesTaskParameters;
};

// @public (undocumented)
export interface EntitiesTaskParameters {
// (undocumented)
modelVersion?: string;
}

// @public
export interface Entity {
category: string;
Expand All @@ -108,7 +182,7 @@ export interface Entity {
export type ErrorCode = ErrorCodeValue | InnerErrorCodeValue;

// @public
export type ErrorCodeValue = "InvalidRequest" | "InvalidArgument" | "InternalServerError" | "ServiceUnavailable";
export type ErrorCodeValue = "InvalidRequest" | "InvalidArgument" | "InternalServerError" | "ServiceUnavailable" | "NotFound";

// @public
export type ExtractKeyPhrasesErrorResult = TextAnalyticsErrorResult;
Expand All @@ -131,7 +205,72 @@ export interface ExtractKeyPhrasesSuccessResult extends TextAnalyticsSuccessResu
}

// @public
export type InnerErrorCodeValue = "InvalidParameterValue" | "InvalidRequestBodyFormat" | "EmptyRequest" | "MissingInputRecords" | "InvalidDocument" | "ModelVersionIncorrect" | "InvalidDocumentBatch" | "UnsupportedLanguageCode" | "InvalidCountryHint";
export interface HealthcareEntitiesArray extends Array<HealthcareResult> {
}

// @public (undocumented)
export type HealthcareEntity = Entity & {
isNegated: boolean;
links?: HealthcareEntityLink[];
};

// @public (undocumented)
export interface HealthcareEntityLink {
dataSource: string;
id: string;
}

// @public
export type HealthcareErrorResult = TextAnalyticsErrorResult;

// @public
export interface HealthcareJobOptions extends TextAnalyticsOperationOptions {
}

// @public (undocumented)
export interface HealthcareRelation {
bidirectional: boolean;
relationType: string;
source: string;
target: string;
}

// @public
export type HealthcareResult = HealthcareSuccessResult | HealthcareErrorResult;

// @public
export interface HealthcareSuccessResult extends TextAnalyticsSuccessResult {
entities: HealthcareEntity[];
relations: HealthcareRelation[];
}

// @public
export type HealthPollerLike = PollerLike<BeginAnalyzeHealthcareOperationState, PaginatedHealthcareEntities>;

// @public
export type InnerErrorCodeValue = "InvalidParameterValue" | "InvalidRequestBodyFormat" | "EmptyRequest" | "MissingInputRecords" | "InvalidDocument" | "ModelVersionIncorrect" | "InvalidDocumentBatch" | "UnsupportedLanguageCode" | "InvalidCountryHint" | string;

// @public (undocumented)
export interface JobManifestTasks {
// (undocumented)
entityRecognitionPiiTasks?: PiiTask[];
// (undocumented)
entityRecognitionTasks?: EntitiesTask[];
// (undocumented)
keyPhraseExtractionTasks?: KeyPhrasesTask[];
}

// @public (undocumented)
export interface KeyPhrasesTask {
// (undocumented)
parameters?: KeyPhrasesTaskParameters;
}

// @public (undocumented)
export interface KeyPhrasesTaskParameters {
// (undocumented)
modelVersion?: string;
}

// @public
export interface LinkedEntity {
Expand Down Expand Up @@ -161,6 +300,23 @@ export interface MinedOpinion {
export interface OpinionSentiment extends SentenceOpinion {
}

// @public
export type PagedAsyncIterableAnalyzeResults = PagedAsyncIterableIterator<AnalyzeResult, AnalyzeResultsArray>;

// @public
export type PagedAsyncIterableHealthEntities = PagedAsyncIterableIterator<HealthcareResult, HealthcareEntitiesArray>;

// @public
export interface PaginatedAnalyzeResults extends PagedAsyncIterableAnalyzeResults {
statistics?: TextDocumentBatchStatistics;
}

// @public
export interface PaginatedHealthcareEntities extends PagedAsyncIterableHealthEntities {
modelVersion: string;
statistics?: TextDocumentBatchStatistics;
}

// @public
export interface PiiEntity extends Entity {
}
Expand All @@ -170,6 +326,28 @@ export enum PiiEntityDomainType {
PROTECTED_HEALTH_INFORMATION = "PHI"
}

// @public (undocumented)
export type PiiTask = {
parameters?: PiiTaskParameters;
};

// @public (undocumented)
export interface PiiTaskParameters {
// (undocumented)
domain?: PiiTaskParametersDomain;
// (undocumented)
modelVersion?: string;
}

// @public
export type PiiTaskParametersDomain = "phi" | "none" | string;

// @public
export interface PollingOptions {
resumeFrom?: string;
updateIntervalInMs?: number;
}

// @public
export type RecognizeCategorizedEntitiesErrorResult = TextAnalyticsErrorResult;

Expand Down Expand Up @@ -269,6 +447,10 @@ export class TextAnalyticsClient {
constructor(endpointUrl: string, credential: TokenCredential | KeyCredential, options?: TextAnalyticsClientOptions);
analyzeSentiment(documents: string[], language?: string, options?: AnalyzeSentimentOptions): Promise<AnalyzeSentimentResultArray>;
analyzeSentiment(documents: TextDocumentInput[], options?: AnalyzeSentimentOptions): Promise<AnalyzeSentimentResultArray>;
beginAnalyze(documents: string[], tasks: JobManifestTasks, language?: string, options?: BeginAnalyzeOptions): Promise<AnalyzePollerLike>;
beginAnalyze(documents: TextDocumentInput[], tasks: JobManifestTasks, options?: BeginAnalyzeOptions): Promise<AnalyzePollerLike>;
beginAnalyzeHealthcare(documents: string[], language?: string, options?: BeginAnalyzeHealthcareOptions): Promise<HealthPollerLike>;
beginAnalyzeHealthcare(documents: TextDocumentInput[], options?: BeginAnalyzeHealthcareOptions): Promise<HealthPollerLike>;
defaultCountryHint: string;
defaultLanguage: string;
detectLanguage(documents: string[], countryHint?: string, options?: DetectLanguageOptions): Promise<DetectLanguageResultArray>;
Expand Down Expand Up @@ -351,7 +533,7 @@ export interface TextDocumentStatistics {
export type TokenSentimentValue = "positive" | "mixed" | "negative";

// @public
export type WarningCode = "LongWordsInDocument" | "DocumentTruncated";
export type WarningCode = "LongWordsInDocument" | "DocumentTruncated" | string;


// (No @packageDocumentation comment for this package)
Expand Down
69 changes: 69 additions & 0 deletions sdk/textanalytics/ai-text-analytics/src/analyzeResult.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { PagedAsyncIterableIterator } from "@azure/core-paging";
import { ExtractKeyPhrasesSuccessResult } from "./extractKeyPhrasesResult";
import { TextDocumentBatchStatistics } from "./generated/models";
import { RecognizeCategorizedEntitiesSuccessResult } from "./recognizeCategorizedEntitiesResult";
import { RecognizePiiEntitiesSuccessResult } from "./recognizePiiEntitiesResult";
import { TextAnalyticsErrorResult } from "./textAnalyticsResult";

/**
* The results of a successful analyze entities job on a single document.
*/
export interface AnalyzeEntitiesResult extends RecognizeCategorizedEntitiesSuccessResult {
type: "Entities";
}

export interface AnalyzePiiEntitiesResult extends RecognizePiiEntitiesSuccessResult {
type: "PiiEntities";
}

export interface AnalyzeKeyPhrasesResult extends ExtractKeyPhrasesSuccessResult {
type: "KeyPhrases";
}

/**
* An error result from the analyze operation on a single document.
*/
export interface AnalyzeErrorResult extends TextAnalyticsErrorResult {
type: "Error";
}

/**
* The results of a successful analyze job for a single document.
*/
export type AnalyzeResult =
| AnalyzeEntitiesResult
| AnalyzePiiEntitiesResult
| AnalyzeKeyPhrasesResult
| AnalyzeErrorResult;

/**
* Array of {@link AnalyzeResult}
*/
export interface AnalyzeResultsArray extends Array<AnalyzeResult> {}

/**
* The results of an analyze job represented as a paginated iterator that can
* either iterate over the results on a document-by-document basis or, by
* byPage(), can iterate over pages of documents.
*/
export type PagedAsyncIterableAnalyzeResults = PagedAsyncIterableIterator<
AnalyzeResult,
AnalyzeResultsArray
>;

/**
* The results of an analyze job represented as a paginated iterator that can
* either iterate over the results on a document-by-document basis or, by
* byPage(), can iterate over pages of documents.
*/
export interface PaginatedAnalyzeResults extends PagedAsyncIterableAnalyzeResults {
/**
* 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;
}
2 changes: 1 addition & 1 deletion sdk/textanalytics/ai-text-analytics/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export const SDK_VERSION: string = "5.1.0-beta.3";
export const SDK_VERSION: string = "5.2.0-beta.1";
Loading

0 comments on commit cdec7a2

Please sign in to comment.