Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ai-text-analytics] Various documentation-related changes #9333

Merged
merged 3 commits into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -5,7 +5,7 @@ import {
TextDocumentBatchStatistics,
DocumentError,
DocumentSentiment,
MultiLanguageInput
TextDocumentInput

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick question: renaming in the generated code would mean these changes would get lost with regeneration right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's renamed in the autorest swagger, so any subsequent regeneration will keep the internal rename.

} from "./generated/models";
import {
AnalyzeSentimentResult,
Expand Down Expand Up @@ -33,7 +33,7 @@ export interface AnalyzeSentimentResultArray extends Array<AnalyzeSentimentResul
}

export function makeAnalyzeSentimentResultArray(
input: MultiLanguageInput[],
input: TextDocumentInput[],
documents: DocumentSentiment[],
errors: DocumentError[],
modelVersion: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
TextDocumentBatchStatistics,
DocumentLanguage,
DocumentError,
LanguageInput
DetectLanguageInput
} from "./generated/models";
import {
DetectLanguageResult,
Expand Down Expand Up @@ -33,7 +33,7 @@ export interface DetectLanguageResultArray extends Array<DetectLanguageResult> {
}

export function makeDetectLanguageResultArray(
input: LanguageInput[],
input: DetectLanguageInput[],
documents: DocumentLanguage[],
errors: DocumentError[],
modelVersion: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
TextDocumentBatchStatistics,
DocumentError,
DocumentKeyPhrases,
MultiLanguageInput
TextDocumentInput
} from "./generated/models";
import {
ExtractKeyPhrasesResult,
Expand Down Expand Up @@ -33,7 +33,7 @@ export interface ExtractKeyPhrasesResultArray extends Array<ExtractKeyPhrasesRes
}

export function makeExtractKeyPhrasesResultArray(
input: MultiLanguageInput[],
input: TextDocumentInput[],
documents: DocumentKeyPhrases[],
errors: DocumentError[],
modelVersion: string,
Expand Down
42 changes: 26 additions & 16 deletions sdk/textanalytics/ai-text-analytics/src/generated/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import * as coreHttp from "@azure/core-http";

/**
* Contains an input document to be analyzed by the service.
* An object representing an individual text document to be analyzed by the Text Analytics service.
* The document contains a unique document ID, the full text of the document, and the language of
* the document's text.
*/
export interface MultiLanguageInput {
export interface TextDocumentInput {
/**
* A unique, non-empty document identifier.
*/
Expand All @@ -35,7 +37,7 @@ export interface MultiLanguageBatchInput {
/**
* The set of documents to process as part of this batch.
*/
documents: MultiLanguageInput[];
documents: TextDocumentInput[];
}

/**
Expand Down Expand Up @@ -108,7 +110,7 @@ export interface DocumentError {
}

/**
* An interface representing TextAnalyticsWarning.
* Represents a warning encountered while processing a document.
*/
export interface TextAnalyticsWarning {
/**
Expand All @@ -122,8 +124,8 @@ export interface TextAnalyticsWarning {
}

/**
* if showStats=true was specified in the request this field will contain information about the
* document payload.
* if includeStatistics=true was specified in the request this field will contain information about
* the document payload.
*/
export interface TextDocumentStatistics {
/**
Expand All @@ -147,7 +149,9 @@ export interface SentimentConfidenceScores {
}

/**
* An interface representing SentenceSentiment.
* The predicted sentiment for a given span of text. For more information regarding text sentiment,
* see
* https://docs.microsoft.com/en-us/azure/cognitive-services/Text-Analytics/how-tos/text-analytics-how-to-sentiment-analysis.
*/
export interface SentenceSentiment {
/**
Expand Down Expand Up @@ -194,8 +198,8 @@ export interface DocumentSentiment {
}

/**
* if showStats=true was specified in the request this field will contain information about the
* request payload.
* if includeStatistics=true was specified in the request this field will contain information about
* the request payload.
*/
export interface TextDocumentBatchStatistics {
/**
Expand Down Expand Up @@ -238,7 +242,9 @@ export interface SentimentResponse {
}

/**
* An interface representing Entity.
* A word or phrase identified as an entity that is categorized within a taxonomy of types. The set
* of categories recognized by the Text Analytics service is described at
* https://docs.microsoft.com/en-us/azure/cognitive-services/Text-Analytics/named-entity-types .
*/
export interface Entity {
/**
Expand Down Expand Up @@ -302,7 +308,8 @@ export interface EntitiesResult {
}

/**
* An interface representing Match.
* Details about the specific substring in a document that refers to a linked entity identified by
* the Text Analytics model.
*/
export interface Match {
/**
Expand All @@ -317,7 +324,8 @@ export interface Match {
}

/**
* An interface representing LinkedEntity.
* A word or phrase identified as a well-known entity within a database, including its formal
* (disambiguated) name and a link to the entity information within the source database.
*/
export interface LinkedEntity {
/**
Expand Down Expand Up @@ -432,9 +440,11 @@ export interface KeyPhraseResult {
}

/**
* An interface representing LanguageInput.
* An input to the language detection operation. This object specifies a unique document id, as
* well as the full text of a document and a hint indicating the document's country of origin to
* assist the text analytics predictive model in detecting the document's language.
*/
export interface LanguageInput {
export interface DetectLanguageInput {
/**
* Unique, non-empty document identifier.
*/
Expand All @@ -447,11 +457,11 @@ export interface LanguageInput {
* An interface representing LanguageBatchInput.
*/
export interface LanguageBatchInput {
documents: LanguageInput[];
documents: DetectLanguageInput[];
}

/**
* An interface representing DetectedLanguage.
* Information about the language of a document as identified by the Text Analytics service.
*/
export interface DetectedLanguage {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import * as coreHttp from "@azure/core-http";


export const MultiLanguageInput: coreHttp.CompositeMapper = {
serializedName: "MultiLanguageInput",
export const TextDocumentInput: coreHttp.CompositeMapper = {
serializedName: "TextDocumentInput",
type: {
name: "Composite",
className: "MultiLanguageInput",
className: "TextDocumentInput",
modelProperties: {
id: {
required: true,
Expand Down Expand Up @@ -53,7 +53,7 @@ export const MultiLanguageBatchInput: coreHttp.CompositeMapper = {
element: {
type: {
name: "Composite",
className: "MultiLanguageInput"
className: "TextDocumentInput"
}
}
}
Expand Down Expand Up @@ -896,11 +896,11 @@ export const KeyPhraseResult: coreHttp.CompositeMapper = {
}
};

export const LanguageInput: coreHttp.CompositeMapper = {
serializedName: "LanguageInput",
export const DetectLanguageInput: coreHttp.CompositeMapper = {
serializedName: "DetectLanguageInput",
type: {
name: "Composite",
className: "LanguageInput",
className: "DetectLanguageInput",
modelProperties: {
id: {
required: true,
Expand Down Expand Up @@ -940,7 +940,7 @@ export const LanguageBatchInput: coreHttp.CompositeMapper = {
element: {
type: {
name: "Composite",
className: "LanguageInput"
className: "DetectLanguageInput"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/textanalytics/ai-text-analytics/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export {
DetectedLanguage,
TextDocumentStatistics,
SentimentConfidenceScores,
MultiLanguageInput as TextDocumentInput,
LanguageInput as DetectLanguageInput,
TextDocumentInput,
DetectLanguageInput,
TextDocumentBatchStatistics,
Entity,
SentenceSentiment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
TextDocumentBatchStatistics,
DocumentError,
DocumentEntities,
MultiLanguageInput
TextDocumentInput
} from "./generated/models";
import {
RecognizeCategorizedEntitiesResult,
Expand Down Expand Up @@ -34,7 +34,7 @@ export interface RecognizeCategorizedEntitiesResultArray
}

export function makeRecognizeCategorizedEntitiesResultArray(
input: MultiLanguageInput[],
input: TextDocumentInput[],
documents: DocumentEntities[],
errors: DocumentError[],
modelVersion: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
TextDocumentBatchStatistics,
DocumentError,
DocumentLinkedEntities,
MultiLanguageInput
TextDocumentInput
} from "./generated/models";
import {
RecognizeLinkedEntitiesResult,
Expand Down Expand Up @@ -34,7 +34,7 @@ export interface RecognizeLinkedEntitiesResultArray
}

export function makeRecognizeLinkedEntitiesResultArray(
input: MultiLanguageInput[],
input: TextDocumentInput[],
documents: DocumentLinkedEntities[],
errors: DocumentError[],
modelVersion: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ import { TokenCredential, KeyCredential } from "@azure/core-auth";
import { SDK_VERSION } from "./constants";
import { GeneratedClient } from "./generated/generatedClient";
import { logger } from "./logger";
import {
LanguageInput as DetectLanguageInput,
MultiLanguageInput as TextDocumentInput
} from "./generated/models";
import { DetectLanguageInput, TextDocumentInput } from "./generated/models";
import {
DetectLanguageResultArray,
makeDetectLanguageResultArray
Expand Down
64 changes: 64 additions & 0 deletions sdk/textanalytics/ai-text-analytics/swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ directive:
if ($.name === "showStats") {
$["x-ms-client-name"] = "includeStatistics";
}
- from: swagger-document
where: $.definitions[*]
transform: >
if ($.description && $.description.includes("showStats")) {
$.description = $.description.replace("showStats", "includeStatistics");
}
```

### Rename {Document,Sentence}SentimentValue -> Label
Expand Down Expand Up @@ -227,3 +233,61 @@ directive:
delete $["targetRef"];
```

### Rename text input objects to avoid "export as"

```yaml
directive:
- from: swagger-document
where: $.definitions
transform: >
if (!$.TextDocumentInput) {
$.TextDocumentInput = $.MultiLanguageInput;
delete $.MultiLanguageInput;
}
- from: swagger-document
where: $.definitions.MultiLanguageBatchInput.properties.documents.items
transform: >
$["$ref"] = "#/definitions/TextDocumentInput";
- from: swagger-document
where: $.definitions
transform: >
if (!$.DetectLanguageInput) {
$.DetectLanguageInput = $.LanguageInput;
delete $.LanguageInput;
}
- from: swagger-document
where: $.definitions.LanguageBatchInput.properties.documents.items
transform: >
$["$ref"] = "#/definitions/DetectLanguageInput";
```

### Enhance documentation strings for some exported swagger types

```yaml
directive:
- from: swagger-document
where: $.definitions.TextAnalyticsWarning
transform: $.description = "Represents a warning encountered while processing a document."
- from: swagger-document
where: $.definitions.SentenceSentiment
transform: $.description = "The predicted sentiment for a given span of text. For more information regarding text sentiment, see https://docs.microsoft.com/en-us/azure/cognitive-services/Text-Analytics/how-tos/text-analytics-how-to-sentiment-analysis."
- from: swagger-document
where: $.definitions.Match
transform: $.description = "Details about the specific substring in a document that refers to a linked entity identified by the Text Analytics model."
- from: swagger-document
where: $.definitions.Entity
transform: $.description = "A word or phrase identified as an entity that is categorized within a taxonomy of types. The set of categories recognized by the Text Analytics service is described at https://docs.microsoft.com/en-us/azure/cognitive-services/Text-Analytics/named-entity-types ."
- from: swagger-document
where: $.definitions.LinkedEntity
transform: $.description = "A word or phrase identified as a well-known entity within a database, including its formal (disambiguated) name and a link to the entity information within the source database."
- from: swagger-document
where: $.definitions.DetectLanguageInput
transform: $.description = "An input to the language detection operation. This object specifies a unique document id, as well as the full text of a document and a hint indicating the document's country of origin to assist the text analytics predictive model in detecting the document's language."
- from: swagger-document
where: $.definitions.TextDocumentInput
transform: $.description = "An object representing an individual text document to be analyzed by the Text Analytics service. The document contains a unique document ID, the full text of the document, and the language of the document's text."
- from: swagger-document
where: $.definitions.DetectedLanguage
transform: $.description = "Information about the language of a document as identified by the Text Analytics service."
```

Loading