From 538c4c6499ae22ebebf39ae2ad4fb21df682592f Mon Sep 17 00:00:00 2001 From: Deyaaeldeen Almahallawi Date: Thu, 15 Sep 2022 18:00:07 -0700 Subject: [PATCH] add support for entity resolution and address feedback --- .../ai-language-text/CHANGELOG.md | 3 +- .../review/ai-language-text.api.md | 416 +++++++++++++++++- .../src/generated/models/index.ts | 1 + .../ai-language-text/src/index.ts | 47 ++ .../ai-language-text/src/models.ts | 3 +- .../ai-language-text/swagger/README.md | 4 +- 6 files changed, 470 insertions(+), 4 deletions(-) diff --git a/sdk/cognitivelanguage/ai-language-text/CHANGELOG.md b/sdk/cognitivelanguage/ai-language-text/CHANGELOG.md index 64da0341c302..1238acd88cdf 100644 --- a/sdk/cognitivelanguage/ai-language-text/CHANGELOG.md +++ b/sdk/cognitivelanguage/ai-language-text/CHANGELOG.md @@ -5,11 +5,12 @@ ### Features Added - Supports service version 2022-10-01-preview by default instead of 2022-05-01. -- Adds back support for extractive summarization and FHIR. +- Adds support for extractive summarization and FHIR. - Adds support for abstractive summarization. - Adds support for dynamic classification. - Adds support for script detection and automatic language detection. - Adds support for document types in healthcare analysis. +- Adds support for entity resolution in entity recognition. - Adds support for confidence scores in healthcare relations. ### Breaking Changes diff --git a/sdk/cognitivelanguage/ai-language-text/review/ai-language-text.api.md b/sdk/cognitivelanguage/ai-language-text/review/ai-language-text.api.md index 105dbb1a79d8..142b5d1c46a5 100644 --- a/sdk/cognitivelanguage/ai-language-text/review/ai-language-text.api.md +++ b/sdk/cognitivelanguage/ai-language-text/review/ai-language-text.api.md @@ -66,6 +66,15 @@ export interface ActionPrebuilt extends ActionCommon { modelVersion?: string; } +// @public +export interface AgeResolution extends BaseResolution, QuantityResolution { + resolutionKind: "AgeResolution"; + unit: AgeUnit; +} + +// @public +export type AgeUnit = string; + // @public export type AnalyzeActionName = keyof typeof AnalyzeActionNames; @@ -150,6 +159,15 @@ export type AnalyzeResult = { LanguageDetection: LanguageDetectionResult[]; }[ActionName]; +// @public +export interface AreaResolution extends BaseResolution, QuantityResolution { + resolutionKind: "AreaResolution"; + unit: AreaUnit; +} + +// @public +export type AreaUnit = string; + // @public export interface AssessmentSentiment { confidenceScores: TargetConfidenceScores; @@ -162,6 +180,14 @@ export interface AssessmentSentiment { export { AzureKeyCredential } +// @public +export interface BaseResolution { + resolutionKind: "AgeResolution" | "VolumeResolution" | "SpeedResolution" | "AreaResolution" | "LengthResolution" | "InformationResolution" | "TemperatureResolution" | "WeightResolution" | "CurrencyResolution" | "BooleanResolution" | "DateTimeResolution" | "NumberResolution" | "OrdinalResolution" | "TemporalSpanResolution" | "NumericRangeResolution"; +} + +// @public (undocumented) +export type BaseResolutionUnion = BaseResolution | AgeResolution | VolumeResolution | SpeedResolution | AreaResolution | LengthResolution | InformationResolution | TemperatureResolution | WeightResolution | CurrencyResolution | BooleanResolution | DateTimeResolution | NumberResolution | OrdinalResolution | TemporalSpanResolution | NumericRangeResolution; + // @public export interface BatchActionErrorResult extends BatchActionState { readonly error: TextAnalysisError; @@ -192,6 +218,13 @@ export interface BeginAnalyzeBatchOptions extends TextAnalysisOperationOptions { updateIntervalInMs?: number; } +// @public +export interface BooleanResolution extends BaseResolution { + resolutionKind: "BooleanResolution"; + // (undocumented) + value: boolean; +} + // @public export interface ClassificationCategory { category: string; @@ -201,6 +234,13 @@ export interface ClassificationCategory { // @public export type ClassificationType = string; +// @public +export interface CurrencyResolution extends BaseResolution, QuantityResolution { + iso4217?: string; + resolutionKind: "CurrencyResolution"; + unit: string; +} + // @public export interface CustomActionMetadata { readonly deploymentName: string; @@ -277,6 +317,18 @@ export interface CustomSingleLabelClassificationSuccessResult extends TextAnalys readonly classifications: ClassificationCategory[]; } +// @public +export interface DateTimeResolution extends BaseResolution { + dateTimeSubKind: DateTimeSubKind; + modifier?: TemporalModifier; + resolutionKind: "DateTimeResolution"; + timex: string; + value: string; +} + +// @public +export type DateTimeSubKind = string; + // @public export interface DetectedLanguage { confidenceScore: number; @@ -389,7 +441,12 @@ export type EntityRecognitionResult = EntityRecognitionSuccessResult | EntityRec // @public export interface EntityRecognitionSuccessResult extends TextAnalysisSuccessResult { - readonly entities: Entity[]; + readonly entities: EntityWithResolution[]; +} + +// @public +export interface EntityWithResolution extends Entity { + resolutions?: BaseResolutionUnion[]; } // @public @@ -486,6 +543,15 @@ export interface HealthcareSuccessResult extends TextAnalysisSuccessResult { readonly fhirBundle?: Record; } +// @public +export interface InformationResolution extends BaseResolution, QuantityResolution { + resolutionKind: "InformationResolution"; + unit: InformationUnit; +} + +// @public +export type InformationUnit = string; + // @public export interface KeyPhraseExtractionAction extends ActionPrebuilt { } @@ -509,12 +575,47 @@ export interface KeyPhraseExtractionSuccessResult extends TextAnalysisSuccessRes readonly keyPhrases: string[]; } +// @public +export enum KnownAgeUnit { + Day = "Day", + Month = "Month", + Unspecified = "Unspecified", + Week = "Week", + Year = "Year" +} + +// @public +export enum KnownAreaUnit { + Acre = "Acre", + SquareCentimeter = "SquareCentimeter", + SquareDecameter = "SquareDecameter", + SquareDecimeter = "SquareDecimeter", + SquareFoot = "SquareFoot", + SquareHectometer = "SquareHectometer", + SquareInch = "SquareInch", + SquareKilometer = "SquareKilometer", + SquareMeter = "SquareMeter", + SquareMile = "SquareMile", + SquareMillimeter = "SquareMillimeter", + SquareYard = "SquareYard", + Unspecified = "Unspecified" +} + // @public export enum KnownClassificationType { Multi = "Multi", Single = "Single" } +// @public +export enum KnownDateTimeSubKind { + Date = "Date", + DateTime = "DateTime", + Duration = "Duration", + Set = "Set", + Time = "Time" +} + // @public export enum KnownDocumentType { ClinicalTrial = "ClinicalTrial", @@ -561,6 +662,53 @@ export enum KnownFhirVersion { "4.0.1" = "4.0.1" } +// @public +export enum KnownHealthcareEntityCategory { + AdministrativeEvent = "AdministrativeEvent", + Age = "Age", + BodyStructure = "BodyStructure", + CareEnvironment = "CareEnvironment", + ConditionalQualifier = "ConditionalQualifier", + Date = "Date", + Diagnosis = "Diagnosis", + Direction = "Direction", + Dosage = "Dosage", + ExaminationName = "ExaminationName", + FamilyRelation = "FamilyRelation", + Frequency = "Frequency", + Gender = "Gender", + GeneOrProtein = "GeneOrProtein", + HealthcareProfession = "HealthcareProfession", + MeasurementUnit = "MeasurementUnit", + MeasurementValue = "MeasurementValue", + MedicationClass = "MedicationClass", + MedicationForm = "MedicationForm", + MedicationName = "MedicationName", + MedicationRoute = "MedicationRoute", + RelationalOperator = "RelationalOperator", + SymptomOrSign = "SymptomOrSign", + Time = "Time", + TreatmentName = "TreatmentName", + Variant = "Variant" +} + +// @public +export enum KnownInformationUnit { + Bit = "Bit", + Byte = "Byte", + Gigabit = "Gigabit", + Gigabyte = "Gigabyte", + Kilobit = "Kilobit", + Kilobyte = "Kilobyte", + Megabit = "Megabit", + Megabyte = "Megabyte", + Petabit = "Petabit", + Petabyte = "Petabyte", + Terabit = "Terabit", + Terabyte = "Terabyte", + Unspecified = "Unspecified" +} + // @public export enum KnownInnerErrorCode { AzureCognitiveSearchNotFound = "AzureCognitiveSearchNotFound", @@ -579,6 +727,37 @@ export enum KnownInnerErrorCode { UnsupportedLanguageCode = "UnsupportedLanguageCode" } +// @public +export enum KnownLengthUnit { + Centimeter = "Centimeter", + Decameter = "Decameter", + Decimeter = "Decimeter", + Foot = "Foot", + Hectometer = "Hectometer", + Inch = "Inch", + Kilometer = "Kilometer", + LightYear = "LightYear", + Meter = "Meter", + Micrometer = "Micrometer", + Mile = "Mile", + Millimeter = "Millimeter", + Nanometer = "Nanometer", + Picometer = "Picometer", + Pt = "Pt", + Unspecified = "Unspecified", + Yard = "Yard" +} + +// @public +export enum KnownNumberKind { + Decimal = "Decimal", + Fraction = "Fraction", + Integer = "Integer", + Percent = "Percent", + Power = "Power", + Unspecified = "Unspecified" +} + // @public export enum KnownPiiEntityCategory { ABARoutingNumber = "ABARoutingNumber", @@ -762,6 +941,20 @@ export enum KnownPiiEntityDomain { Phi = "phi" } +// @public +export enum KnownRangeKind { + Age = "Age", + Area = "Area", + Currency = "Currency", + Information = "Information", + Length = "Length", + Number = "Number", + Speed = "Speed", + Temperature = "Temperature", + Volume = "Volume", + Weight = "Weight" +} + // @public export enum KnownRelationType { Abbreviation = "Abbreviation", @@ -787,11 +980,55 @@ export enum KnownRelationType { ValueOfExamination = "ValueOfExamination" } +// @public +export enum KnownRelativeTo { + Current = "Current", + End = "End", + Start = "Start" +} + +// @public +export enum KnownResolutionKind { + AgeResolution = "AgeResolution", + AreaResolution = "AreaResolution", + BooleanResolution = "BooleanResolution", + CurrencyResolution = "CurrencyResolution", + DateTimeResolution = "DateTimeResolution", + InformationResolution = "InformationResolution", + LengthResolution = "LengthResolution", + NumberResolution = "NumberResolution", + NumericRangeResolution = "NumericRangeResolution", + OrdinalResolution = "OrdinalResolution", + SpeedResolution = "SpeedResolution", + TemperatureResolution = "TemperatureResolution", + TemporalSpanResolution = "TemporalSpanResolution", + VolumeResolution = "VolumeResolution", + WeightResolution = "WeightResolution" +} + // @public export enum KnownScriptKind { Latin = "Latin" } +// @public +export enum KnownSpeedUnit { + CentimetersPerMillisecond = "CentimetersPerMillisecond", + FootPerMinute = "FootPerMinute", + FootPerSecond = "FootPerSecond", + KilometersPerHour = "KilometersPerHour", + KilometersPerMillisecond = "KilometersPerMillisecond", + KilometersPerMinute = "KilometersPerMinute", + KilometersPerSecond = "KilometersPerSecond", + Knot = "Knot", + MetersPerMillisecond = "MetersPerMillisecond", + MetersPerSecond = "MetersPerSecond", + MilesPerHour = "MilesPerHour", + Unspecified = "Unspecified", + YardsPerMinute = "YardsPerMinute", + YardsPerSecond = "YardsPerSecond" +} + // @public export enum KnownStringIndexType { TextElementsV8 = "TextElements_v8", @@ -799,6 +1036,37 @@ export enum KnownStringIndexType { Utf16CodeUnit = "Utf16CodeUnit" } +// @public +export enum KnownTemperatureUnit { + Celsius = "Celsius", + Fahrenheit = "Fahrenheit", + Kelvin = "Kelvin", + Rankine = "Rankine", + Unspecified = "Unspecified" +} + +// @public +export enum KnownTemporalModifier { + After = "After", + AfterApprox = "AfterApprox", + AfterMid = "AfterMid", + AfterStart = "AfterStart", + Approx = "Approx", + Before = "Before", + BeforeApprox = "BeforeApprox", + BeforeEnd = "BeforeEnd", + BeforeStart = "BeforeStart", + End = "End", + Less = "Less", + Mid = "Mid", + More = "More", + ReferenceUndefined = "ReferenceUndefined", + Since = "Since", + SinceEnd = "SinceEnd", + Start = "Start", + Until = "Until" +} + // @public export const KnownTextAnalysisErrorCode: { InvalidRequest: KnownInnerErrorCode.InvalidRequest; @@ -832,6 +1100,58 @@ export const KnownTextAnalysisErrorCode: { Warning: KnownErrorCode.Warning; }; +// @public +export enum KnownVolumeUnit { + Barrel = "Barrel", + Bushel = "Bushel", + Centiliter = "Centiliter", + Cord = "Cord", + CubicCentimeter = "CubicCentimeter", + CubicFoot = "CubicFoot", + CubicInch = "CubicInch", + CubicMeter = "CubicMeter", + CubicMile = "CubicMile", + CubicMillimeter = "CubicMillimeter", + CubicYard = "CubicYard", + Cup = "Cup", + Decaliter = "Decaliter", + FluidDram = "FluidDram", + FluidOunce = "FluidOunce", + Gill = "Gill", + Hectoliter = "Hectoliter", + Hogshead = "Hogshead", + Liter = "Liter", + Milliliter = "Milliliter", + Minim = "Minim", + Peck = "Peck", + Pinch = "Pinch", + Pint = "Pint", + Quart = "Quart", + Tablespoon = "Tablespoon", + Teaspoon = "Teaspoon", + Unspecified = "Unspecified" +} + +// @public +export enum KnownWeightUnit { + Dram = "Dram", + Gallon = "Gallon", + Grain = "Grain", + Gram = "Gram", + Kilogram = "Kilogram", + LongTonBritish = "LongTonBritish", + MetricTon = "MetricTon", + Milligram = "Milligram", + Ounce = "Ounce", + PennyWeight = "PennyWeight", + Pound = "Pound", + ShortHundredWeightUS = "ShortHundredWeightUS", + ShortTonUS = "ShortTonUS", + Stone = "Stone", + Ton = "Ton", + Unspecified = "Unspecified" +} + // @public export interface LanguageDetectionAction extends ActionPrebuilt { } @@ -854,6 +1174,15 @@ export interface LanguageDetectionSuccessResult extends TextAnalysisSuccessResul readonly primaryLanguage: DetectedLanguage; } +// @public +export interface LengthResolution extends BaseResolution, QuantityResolution { + resolutionKind: "LengthResolution"; + unit: LengthUnit; +} + +// @public +export type LengthUnit = string; + // @public export interface LinkedEntity { bingEntitySearchApiId?: string; @@ -873,12 +1202,38 @@ export interface Match { text: string; } +// @public +export type NumberKind = string; + +// @public +export interface NumberResolution extends BaseResolution { + numberKind: NumberKind; + resolutionKind: "NumberResolution"; + value: string; +} + +// @public +export interface NumericRangeResolution extends BaseResolution { + maximum: number; + minimum: number; + rangeKind: RangeKind; + resolutionKind: "NumericRangeResolution"; +} + // @public export interface Opinion { readonly assessments: AssessmentSentiment[]; readonly target: TargetSentiment; } +// @public +export interface OrdinalResolution extends BaseResolution { + offset: string; + relativeTo: RelativeTo; + resolutionKind: "OrdinalResolution"; + value: string; +} + // @public export type PagedAnalyzeBatchResult = PagedAsyncIterableIterator; @@ -929,9 +1284,20 @@ export interface PollerLike, TResult> ext sendCancellationRequest: () => Promise; } +// @public +export interface QuantityResolution { + value: number; +} + +// @public +export type RangeKind = string; + // @public export type RelationType = string; +// @public +export type RelativeTo = string; + // @public export interface RestoreAnalyzeBatchPollerOptions extends TextAnalysisOperationOptions { updateIntervalInMs?: number; @@ -987,6 +1353,15 @@ export interface SentimentConfidenceScores { positive: number; } +// @public +export interface SpeedResolution extends BaseResolution, QuantityResolution { + resolutionKind: "SpeedResolution"; + unit: SpeedUnit; +} + +// @public +export type SpeedUnit = string; + // @public export type StringIndexType = string; @@ -1019,6 +1394,27 @@ export interface TargetSentiment { readonly text: string; } +// @public +export interface TemperatureResolution extends BaseResolution, QuantityResolution { + resolutionKind: "TemperatureResolution"; + unit: TemperatureUnit; +} + +// @public +export type TemperatureUnit = string; + +// @public +export type TemporalModifier = string; + +// @public +export interface TemporalSpanResolution extends BaseResolution { + begin?: string; + duration?: string; + end?: string; + modifier?: TemporalModifier; + resolutionKind: "TemporalSpanResolution"; +} + // @public export class TextAnalysisClient { constructor(endpointUrl: string, credential: KeyCredential, options?: TextAnalysisClientOptions); @@ -1090,7 +1486,25 @@ export interface TextDocumentStatistics { // @public export type TokenSentimentLabel = "positive" | "mixed" | "negative"; +// @public +export interface VolumeResolution extends BaseResolution, QuantityResolution { + resolutionKind: "VolumeResolution"; + unit: VolumeUnit; +} + +// @public +export type VolumeUnit = string; + // @public export type WarningCode = string; +// @public +export interface WeightResolution extends BaseResolution, QuantityResolution { + resolutionKind: "WeightResolution"; + unit: WeightUnit; +} + +// @public +export type WeightUnit = string; + ``` diff --git a/sdk/cognitivelanguage/ai-language-text/src/generated/models/index.ts b/sdk/cognitivelanguage/ai-language-text/src/generated/models/index.ts index ed5b187396d0..99968c7b9c50 100644 --- a/sdk/cognitivelanguage/ai-language-text/src/generated/models/index.ts +++ b/sdk/cognitivelanguage/ai-language-text/src/generated/models/index.ts @@ -878,6 +878,7 @@ export interface NumericRangeResolution extends BaseResolution { maximum: number; } +/** An entity with resolution. */ export interface EntityWithResolution extends Entity { /** The collection of entity resolution objects. */ resolutions?: BaseResolutionUnion[]; diff --git a/sdk/cognitivelanguage/ai-language-text/src/index.ts b/sdk/cognitivelanguage/ai-language-text/src/index.ts index 0fd7733824d5..afaa8758cd85 100644 --- a/sdk/cognitivelanguage/ai-language-text/src/index.ts +++ b/sdk/cognitivelanguage/ai-language-text/src/index.ts @@ -68,6 +68,38 @@ export { FhirVersion, DynamicClassificationAction, ExtractiveSummarizationOrderingCriteria, + EntityWithResolution, + BaseResolutionUnion, + BaseResolution, + AgeResolution, + VolumeResolution, + SpeedResolution, + AreaResolution, + LengthResolution, + InformationResolution, + TemperatureResolution, + WeightResolution, + CurrencyResolution, + BooleanResolution, + DateTimeResolution, + NumberResolution, + OrdinalResolution, + TemporalSpanResolution, + NumericRangeResolution, + AreaUnit, + DateTimeSubKind, + TemporalModifier, + InformationUnit, + LengthUnit, + NumberKind, + RangeKind, + RelativeTo, + SpeedUnit, + TemperatureUnit, + VolumeUnit, + WeightUnit, + QuantityResolution, + AgeUnit, /** orphan exports */ KnownPiiEntityDomain, KnownPiiEntityCategory, @@ -80,4 +112,19 @@ export { KnownRelationType, KnownScriptKind, KnownExtractiveSummarizationOrderingCriteria, + KnownAgeUnit, + KnownAreaUnit, + KnownDateTimeSubKind, + KnownInformationUnit, + KnownHealthcareEntityCategory, + KnownLengthUnit, + KnownNumberKind, + KnownRangeKind, + KnownSpeedUnit, + KnownTemperatureUnit, + KnownTemporalModifier, + KnownVolumeUnit, + KnownWeightUnit, + KnownRelativeTo, + KnownResolutionKind, } from "./generated/models"; diff --git a/sdk/cognitivelanguage/ai-language-text/src/models.ts b/sdk/cognitivelanguage/ai-language-text/src/models.ts index 9f57b188ffd5..795a98bc7075 100644 --- a/sdk/cognitivelanguage/ai-language-text/src/models.ts +++ b/sdk/cognitivelanguage/ai-language-text/src/models.ts @@ -17,6 +17,7 @@ import { EntityDataSource, EntityLinkingAction, EntityRecognitionAction, + EntityWithResolution, ExtractiveSummarizationAction, HealthcareAction, HealthcareAssertion, @@ -263,7 +264,7 @@ export interface EntityRecognitionSuccessResult extends TextAnalysisSuccessResul /** * The collection of entities identified in the input document. */ - readonly entities: Entity[]; + readonly entities: EntityWithResolution[]; } /** diff --git a/sdk/cognitivelanguage/ai-language-text/swagger/README.md b/sdk/cognitivelanguage/ai-language-text/swagger/README.md index 6e521a2f24e7..f73f193e44a4 100644 --- a/sdk/cognitivelanguage/ai-language-text/swagger/README.md +++ b/sdk/cognitivelanguage/ai-language-text/swagger/README.md @@ -12,7 +12,7 @@ generate-metadata: false license-header: MICROSOFT_MIT_NO_VERSION output-folder: ../ source-code-folder-path: ./src/generated -input-file: https://github.com/Azure/azure-rest-api-specs/blob/main/dev/cognitiveservices/data-plane/Language/analyzetext.json +input-file: https://github.com/Azure/azure-rest-api-specs/blob/82b2d614f620327203c3cc344d8302a832e15759/dev/cognitiveservices/data-plane/Language/analyzetext.json add-credentials: false package-version: 1.1.0-beta.1 v3: true @@ -369,6 +369,8 @@ directive: to: AbstractiveSummarizationAction - where-model: DocumentDetectedLanguage transform: $.description = "The auto-detected language of the input document."; + - where-model: EntityWithResolution + transform: $.description = "An entity with resolution."; ``` ## JS customizations