diff --git a/lib/services/cognitiveServicesTextAnalytics/LICENSE.txt b/lib/services/cognitiveServicesTextAnalytics/LICENSE.txt index a70e8cf660..8f3d856145 100644 --- a/lib/services/cognitiveServicesTextAnalytics/LICENSE.txt +++ b/lib/services/cognitiveServicesTextAnalytics/LICENSE.txt @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2018 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +The MIT License (MIT) + +Copyright (c) 2019 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/detectedLanguage.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/detectedLanguage.js index df9ce1f960..027eae2fa2 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/detectedLanguage.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/detectedLanguage.js @@ -16,12 +16,12 @@ class DetectedLanguage { /** * Create a DetectedLanguage. - * @member {string} [name] Long name of a detected language (e.g. English, + * @property {string} [name] Long name of a detected language (e.g. English, * French). - * @member {string} [iso6391Name] A two letter representation of the detected - * language according to the ISO 639-1 standard (e.g. en, fr). - * @member {number} [score] A confidence score between 0 and 1. Scores close - * to 1 indicate 100% certainty that the identified language is true. + * @property {string} [iso6391Name] A two letter representation of the + * detected language according to the ISO 639-1 standard (e.g. en, fr). + * @property {number} [score] A confidence score between 0 and 1. Scores + * close to 1 indicate 100% certainty that the identified language is true. */ constructor() { } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/documentStatistics.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/documentStatistics.js new file mode 100644 index 0000000000..cdc055e16d --- /dev/null +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/documentStatistics.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Class representing a DocumentStatistics. + */ +class DocumentStatistics { + /** + * Create a DocumentStatistics. + * @property {number} [charactersCount] Number of text elements recognized in + * the document. + * @property {number} [transactionsCount] Number of transactions for the + * document. + */ + constructor() { + } + + /** + * Defines the metadata of DocumentStatistics + * + * @returns {object} metadata of DocumentStatistics + * + */ + mapper() { + return { + required: false, + serializedName: 'DocumentStatistics', + type: { + name: 'Composite', + className: 'DocumentStatistics', + modelProperties: { + charactersCount: { + required: false, + serializedName: 'charactersCount', + type: { + name: 'Number' + } + }, + transactionsCount: { + required: false, + serializedName: 'transactionsCount', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = DocumentStatistics; diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/entitiesBatchResult.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/entitiesBatchResult.js index b5bf090720..9eda0ddf47 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/entitiesBatchResult.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/entitiesBatchResult.js @@ -16,8 +16,21 @@ class EntitiesBatchResult { /** * Create a EntitiesBatchResult. - * @member {array} [documents] - * @member {array} [errors] + * @property {array} [documents] Response by document + * @property {array} [errors] Errors and Warnings by document + * @property {object} [statistics] (Optional) if showStats=true was specified + * in the request this field will contain information about the request + * payload. + * @property {number} [statistics.documentsCount] Number of documents + * submitted in the request. + * @property {number} [statistics.validDocumentsCount] Number of valid + * documents. This excludes empty, over-size limit or non-supported languages + * documents. + * @property {number} [statistics.erroneousDocumentsCount] Number of invalid + * documents. This includes empty, over-size limit or non-supported languages + * documents. + * @property {number} [statistics.transactionsCount] Number of transactions + * for the request. */ constructor() { } @@ -67,6 +80,15 @@ class EntitiesBatchResult { } } } + }, + statistics: { + required: false, + readOnly: true, + serializedName: 'statistics', + type: { + name: 'Composite', + className: 'RequestStatistics' + } } } } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/entitiesBatchResultItem.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/entitiesBatchResultItem.js index d4b263e5fa..ada8580dff 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/entitiesBatchResultItem.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/entitiesBatchResultItem.js @@ -16,8 +16,15 @@ class EntitiesBatchResultItem { /** * Create a EntitiesBatchResultItem. - * @member {string} [id] Unique document identifier. - * @member {array} [entities] Recognized entities in the document. + * @property {string} [id] Unique, non-empty document identifier. + * @property {array} [entities] Recognized entities in the document. + * @property {object} [statistics] (Optional) if showStats=true was specified + * in the request this field will contain information about the document + * payload. + * @property {number} [statistics.charactersCount] Number of text elements + * recognized in the document. + * @property {number} [statistics.transactionsCount] Number of transactions + * for the document. */ constructor() { } @@ -38,7 +45,6 @@ class EntitiesBatchResultItem { modelProperties: { id: { required: false, - readOnly: true, serializedName: 'id', type: { name: 'String' @@ -59,6 +65,14 @@ class EntitiesBatchResultItem { } } } + }, + statistics: { + required: false, + serializedName: 'statistics', + type: { + name: 'Composite', + className: 'DocumentStatistics' + } } } } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/entityRecord.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/entityRecord.js index a507b9ce81..9529521121 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/entityRecord.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/entityRecord.js @@ -16,18 +16,20 @@ class EntityRecord { /** * Create a EntityRecord. - * @member {string} [name] Entity formal name. - * @member {array} [matches] List of instances this entity appears in the + * @property {string} [name] Entity formal name. + * @property {array} [matches] List of instances this entity appears in the * text. - * @member {string} [wikipediaLanguage] Wikipedia language for which the + * @property {string} [wikipediaLanguage] Wikipedia language for which the * WikipediaId and WikipediaUrl refers to. - * @member {string} [wikipediaId] Wikipedia unique identifier of the + * @property {string} [wikipediaId] Wikipedia unique identifier of the * recognized entity. - * @member {string} [wikipediaUrl] URL for the entity's English Wikipedia - * page. - * @member {string} [bingId] Bing unique identifier of the recognized entity. - * Use in conjunction with the Bing Entity Search API to fetch additional - * relevant information. + * @property {string} [wikipediaUrl] URL for the entity's Wikipedia page. + * @property {string} [bingId] Bing unique identifier of the recognized + * entity. Use in conjunction with the Bing Entity Search API to fetch + * additional relevant information. + * @property {string} [type] Entity type from Named Entity Recognition model + * @property {string} [subType] Entity sub type from Named Entity Recognition + * model */ constructor() { } @@ -55,7 +57,6 @@ class EntityRecord { }, matches: { required: false, - readOnly: true, serializedName: 'matches', type: { name: 'Sequence', @@ -97,6 +98,20 @@ class EntityRecord { type: { name: 'String' } + }, + type: { + required: false, + serializedName: 'type', + type: { + name: 'String' + } + }, + subType: { + required: false, + serializedName: 'subType', + type: { + name: 'String' + } } } } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/errorRecord.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/errorRecord.js index 76ce40e432..c90f2dace4 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/errorRecord.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/errorRecord.js @@ -16,9 +16,9 @@ class ErrorRecord { /** * Create a ErrorRecord. - * @member {string} [id] Input document unique identifier the error refers + * @property {string} [id] Input document unique identifier the error refers * to. - * @member {string} [message] Error message. + * @property {string} [message] Error message. */ constructor() { } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/errorResponse.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/errorResponse.js index 5353ce8c22..fb2b551115 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/errorResponse.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/errorResponse.js @@ -16,13 +16,13 @@ class ErrorResponse { /** * Create a ErrorResponse. - * @member {string} [code] - * @member {string} [message] - * @member {string} [target] - * @member {object} [innerError] - * @member {string} [innerError.code] - * @member {string} [innerError.message] - * @member {object} [innerError.innerError] + * @property {string} [code] + * @property {string} [message] + * @property {string} [target] + * @property {object} [innerError] + * @property {string} [innerError.code] + * @property {string} [innerError.message] + * @property {object} [innerError.innerError] */ constructor() { } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/index.d.ts b/lib/services/cognitiveServicesTextAnalytics/lib/models/index.d.ts index 456c113be1..4a3012071f 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/index.d.ts +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/index.d.ts @@ -1,105 +1,172 @@ /* * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Licensed under the MIT License. See License.txt in the project root for license information. * * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ import * as moment from "moment"; - -/** - * @class - * Initializes a new instance of the MultiLanguageInput class. - * @constructor - * @member {string} [language] This is the 2 letter ISO 639-1 representation of - * a language. For example, use "en" for English; "es" for Spanish etc., - * @member {string} [id] Unique, non-empty document identifier. - * @member {string} [text] - */ export interface MultiLanguageInput { + /** + * This is the 2 letter ISO 639-1 representation of a language. For example, use "en" for + * English; "es" for Spanish etc., + */ language?: string; + /** + * Unique, non-empty document identifier. + */ id?: string; text?: string; } -/** - * @class - * Initializes a new instance of the MultiLanguageBatchInput class. - * @constructor - * @member {array} [documents] - */ export interface MultiLanguageBatchInput { documents?: MultiLanguageInput[]; } -/** - * @class - * Initializes a new instance of the KeyPhraseBatchResultItem class. - * @constructor - * @member {array} [keyPhrases] A list of representative words or phrases. The - * number of key phrases returned is proportional to the number of words in the - * input document. - * @member {string} [id] Unique document identifier. - */ -export interface KeyPhraseBatchResultItem { - readonly keyPhrases?: string[]; - readonly id?: string; +export interface MatchRecord { + /** + * (optional) If a well-known item with Wikipedia link is recognized, a decimal number denoting + * the confidence level of the Wikipedia info will be returned. + */ + wikipediaScore?: number; + /** + * (optional) If an entity type is recognized, a decimal number denoting the confidence level of + * the entity type will be returned. + */ + entityTypeScore?: number; + /** + * Entity text as appears in the request. + */ + text?: string; + /** + * Start position (in Unicode characters) for the entity match text. + */ + offset?: number; + /** + * Length (in Unicode characters) for the entity match text. + */ + length?: number; +} + +export interface EntityRecord { + /** + * Entity formal name. + */ + name?: string; + /** + * List of instances this entity appears in the text. + */ + matches?: MatchRecord[]; + /** + * Wikipedia language for which the WikipediaId and WikipediaUrl refers to. + */ + wikipediaLanguage?: string; + /** + * Wikipedia unique identifier of the recognized entity. + */ + wikipediaId?: string; + /** + * URL for the entity's Wikipedia page. + */ + readonly wikipediaUrl?: string; + /** + * Bing unique identifier of the recognized entity. Use in conjunction with the Bing Entity + * Search API to fetch additional relevant information. + */ + bingId?: string; + /** + * Entity type from Named Entity Recognition model + */ + type?: string; + /** + * Entity sub type from Named Entity Recognition model + */ + subType?: string; +} + +export interface DocumentStatistics { + /** + * Number of text elements recognized in the document. + */ + charactersCount?: number; + /** + * Number of transactions for the document. + */ + transactionsCount?: number; +} + +export interface EntitiesBatchResultItem { + /** + * Unique, non-empty document identifier. + */ + id?: string; + /** + * Recognized entities in the document. + */ + readonly entities?: EntityRecord[]; + /** + * (Optional) if showStats=true was specified in the request this field will contain information + * about the document payload. + */ + statistics?: DocumentStatistics; } -/** - * @class - * Initializes a new instance of the ErrorRecord class. - * @constructor - * @member {string} [id] Input document unique identifier the error refers to. - * @member {string} [message] Error message. - */ export interface ErrorRecord { + /** + * Input document unique identifier the error refers to. + */ id?: string; + /** + * Error message. + */ message?: string; } -/** - * @class - * Initializes a new instance of the KeyPhraseBatchResult class. - * @constructor - * @member {array} [documents] - * @member {array} [errors] - */ -export interface KeyPhraseBatchResult { - readonly documents?: KeyPhraseBatchResultItem[]; +export interface RequestStatistics { + /** + * Number of documents submitted in the request. + */ + documentsCount?: number; + /** + * Number of valid documents. This excludes empty, over-size limit or non-supported languages + * documents. + */ + validDocumentsCount?: number; + /** + * Number of invalid documents. This includes empty, over-size limit or non-supported languages + * documents. + */ + erroneousDocumentsCount?: number; + /** + * Number of transactions for the request. + */ + transactionsCount?: number; +} + +export interface EntitiesBatchResult { + /** + * Response by document + */ + readonly documents?: EntitiesBatchResultItem[]; + /** + * Errors and Warnings by document + */ readonly errors?: ErrorRecord[]; + /** + * (Optional) if showStats=true was specified in the request this field will contain information + * about the request payload. + */ + readonly statistics?: RequestStatistics; } -/** - * @class - * Initializes a new instance of the InternalError class. - * @constructor - * @member {string} [code] - * @member {string} [message] - * @member {object} [innerError] - */ export interface InternalError { code?: string; message?: string; innerError?: InternalError; } -/** - * @class - * Initializes a new instance of the ErrorResponse class. - * @constructor - * @member {string} [code] - * @member {string} [message] - * @member {string} [target] - * @member {object} [innerError] - * @member {string} [innerError.code] - * @member {string} [innerError.message] - * @member {object} [innerError.innerError] - */ export interface ErrorResponse { code?: string; message?: string; @@ -107,156 +174,131 @@ export interface ErrorResponse { innerError?: InternalError; } -/** - * @class - * Initializes a new instance of the Input class. - * @constructor - * @member {string} [id] Unique, non-empty document identifier. - * @member {string} [text] - */ -export interface Input { +export interface KeyPhraseBatchResultItem { + /** + * Unique, non-empty document identifier. + */ + id?: string; + /** + * A list of representative words or phrases. The number of key phrases returned is proportional + * to the number of words in the input document. + */ + readonly keyPhrases?: string[]; + /** + * (Optional) if showStats=true was specified in the request this field will contain information + * about the document payload. + */ + statistics?: DocumentStatistics; +} + +export interface KeyPhraseBatchResult { + /** + * Response by document + */ + readonly documents?: KeyPhraseBatchResultItem[]; + /** + * Errors and Warnings by document + */ + readonly errors?: ErrorRecord[]; + /** + * =(Optional) if showStats=true was specified in the request this field will contain information + * about the request payload. + */ + readonly statistics?: RequestStatistics; +} + +export interface LanguageInput { + countryHint?: string; + /** + * Unique, non-empty document identifier. + */ id?: string; text?: string; } -/** - * @class - * Initializes a new instance of the BatchInput class. - * @constructor - * @member {array} [documents] - */ -export interface BatchInput { - documents?: Input[]; +export interface LanguageBatchInput { + documents?: LanguageInput[]; } -/** - * @class - * Initializes a new instance of the DetectedLanguage class. - * @constructor - * @member {string} [name] Long name of a detected language (e.g. English, - * French). - * @member {string} [iso6391Name] A two letter representation of the detected - * language according to the ISO 639-1 standard (e.g. en, fr). - * @member {number} [score] A confidence score between 0 and 1. Scores close to - * 1 indicate 100% certainty that the identified language is true. - */ export interface DetectedLanguage { + /** + * Long name of a detected language (e.g. English, French). + */ name?: string; + /** + * A two letter representation of the detected language according to the ISO 639-1 standard (e.g. + * en, fr). + */ iso6391Name?: string; + /** + * A confidence score between 0 and 1. Scores close to 1 indicate 100% certainty that the + * identified language is true. + */ score?: number; } -/** - * @class - * Initializes a new instance of the LanguageBatchResultItem class. - * @constructor - * @member {string} [id] Unique document identifier. - * @member {array} [detectedLanguages] A list of extracted languages. - */ export interface LanguageBatchResultItem { - readonly id?: string; - readonly detectedLanguages?: DetectedLanguage[]; + /** + * Unique, non-empty document identifier. + */ + id?: string; + /** + * A list of extracted languages. + */ + detectedLanguages?: DetectedLanguage[]; + /** + * (Optional) if showStats=true was specified in the request this field will contain information + * about the document payload. + */ + statistics?: DocumentStatistics; } -/** - * @class - * Initializes a new instance of the LanguageBatchResult class. - * @constructor - * @member {array} [documents] - * @member {array} [errors] - */ export interface LanguageBatchResult { + /** + * Response by document + */ readonly documents?: LanguageBatchResultItem[]; + /** + * Errors and Warnings by document + */ readonly errors?: ErrorRecord[]; + /** + * (Optional) if showStats=true was specified in the request this field will contain information + * about the request payload. + */ + readonly statistics?: RequestStatistics; } -/** - * @class - * Initializes a new instance of the SentimentBatchResultItem class. - * @constructor - * @member {number} [score] A decimal number between 0 and 1 denoting the - * sentiment of the document. A score above 0.7 usually refers to a positive - * document while a score below 0.3 normally has a negative connotation. Mid - * values refer to neutral text. - * @member {string} [id] Unique document identifier. - */ export interface SentimentBatchResultItem { - readonly score?: number; - readonly id?: string; + /** + * Unique, non-empty document identifier. + */ + id?: string; + /** + * A decimal number between 0 and 1 denoting the sentiment of the document. A score above 0.7 + * usually refers to a positive document while a score below 0.3 normally has a negative + * connotation. Mid values refer to neutral text. + */ + score?: number; + /** + * (Optional) if showStats=true was specified in the request this field will contain information + * about the document payload. + */ + statistics?: DocumentStatistics; } -/** - * @class - * Initializes a new instance of the SentimentBatchResult class. - * @constructor - * @member {array} [documents] - * @member {array} [errors] - */ export interface SentimentBatchResult { + /** + * Response by document + */ readonly documents?: SentimentBatchResultItem[]; + /** + * Errors and Warnings by document + */ readonly errors?: ErrorRecord[]; -} - -/** - * @class - * Initializes a new instance of the MatchRecord class. - * @constructor - * @member {string} [text] Entity text as appears in the request. - * @member {number} [offset] Start position (in Unicode characters) for the - * entity match text. - * @member {number} [length] Length (in Unicode characters) for the entity - * match text. - */ -export interface MatchRecord { - text?: string; - offset?: number; - length?: number; -} - -/** - * @class - * Initializes a new instance of the EntityRecord class. - * @constructor - * @member {string} [name] Entity formal name. - * @member {array} [matches] List of instances this entity appears in the text. - * @member {string} [wikipediaLanguage] Wikipedia language for which the - * WikipediaId and WikipediaUrl refers to. - * @member {string} [wikipediaId] Wikipedia unique identifier of the recognized - * entity. - * @member {string} [wikipediaUrl] URL for the entity's English Wikipedia page. - * @member {string} [bingId] Bing unique identifier of the recognized entity. - * Use in conjunction with the Bing Entity Search API to fetch additional - * relevant information. - */ -export interface EntityRecord { - name?: string; - readonly matches?: MatchRecord[]; - wikipediaLanguage?: string; - wikipediaId?: string; - readonly wikipediaUrl?: string; - bingId?: string; -} - -/** - * @class - * Initializes a new instance of the EntitiesBatchResultItem class. - * @constructor - * @member {string} [id] Unique document identifier. - * @member {array} [entities] Recognized entities in the document. - */ -export interface EntitiesBatchResultItem { - readonly id?: string; - readonly entities?: EntityRecord[]; -} - -/** - * @class - * Initializes a new instance of the EntitiesBatchResult class. - * @constructor - * @member {array} [documents] - * @member {array} [errors] - */ -export interface EntitiesBatchResult { - readonly documents?: EntitiesBatchResultItem[]; - readonly errors?: ErrorRecord[]; + /** + * (Optional) if showStats=true was specified in the request this field will contain information + * about the request payload. + */ + readonly statistics?: RequestStatistics; } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/index.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/index.js index 13b2ce37c4..d03ec36b85 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/index.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/index.js @@ -16,19 +16,21 @@ exports.MultiLanguageInput = require('./multiLanguageInput'); exports.MultiLanguageBatchInput = require('./multiLanguageBatchInput'); -exports.KeyPhraseBatchResultItem = require('./keyPhraseBatchResultItem'); +exports.MatchRecord = require('./matchRecord'); +exports.EntityRecord = require('./entityRecord'); +exports.DocumentStatistics = require('./documentStatistics'); +exports.EntitiesBatchResultItem = require('./entitiesBatchResultItem'); exports.ErrorRecord = require('./errorRecord'); -exports.KeyPhraseBatchResult = require('./keyPhraseBatchResult'); +exports.RequestStatistics = require('./requestStatistics'); +exports.EntitiesBatchResult = require('./entitiesBatchResult'); exports.InternalError = require('./internalError'); exports.ErrorResponse = require('./errorResponse'); -exports.Input = require('./input'); -exports.BatchInput = require('./batchInput'); +exports.KeyPhraseBatchResultItem = require('./keyPhraseBatchResultItem'); +exports.KeyPhraseBatchResult = require('./keyPhraseBatchResult'); +exports.LanguageInput = require('./languageInput'); +exports.LanguageBatchInput = require('./languageBatchInput'); exports.DetectedLanguage = require('./detectedLanguage'); exports.LanguageBatchResultItem = require('./languageBatchResultItem'); exports.LanguageBatchResult = require('./languageBatchResult'); exports.SentimentBatchResultItem = require('./sentimentBatchResultItem'); exports.SentimentBatchResult = require('./sentimentBatchResult'); -exports.MatchRecord = require('./matchRecord'); -exports.EntityRecord = require('./entityRecord'); -exports.EntitiesBatchResultItem = require('./entitiesBatchResultItem'); -exports.EntitiesBatchResult = require('./entitiesBatchResult'); diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/internalError.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/internalError.js index 6174b5c278..53f9d1709f 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/internalError.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/internalError.js @@ -16,9 +16,9 @@ class InternalError { /** * Create a InternalError. - * @member {string} [code] - * @member {string} [message] - * @member {object} [innerError] + * @property {string} [code] + * @property {string} [message] + * @property {object} [innerError] */ constructor() { } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/keyPhraseBatchResult.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/keyPhraseBatchResult.js index be7cc9722c..d06eb52c7c 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/keyPhraseBatchResult.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/keyPhraseBatchResult.js @@ -16,8 +16,21 @@ class KeyPhraseBatchResult { /** * Create a KeyPhraseBatchResult. - * @member {array} [documents] - * @member {array} [errors] + * @property {array} [documents] Response by document + * @property {array} [errors] Errors and Warnings by document + * @property {object} [statistics] =(Optional) if showStats=true was + * specified in the request this field will contain information about the + * request payload. + * @property {number} [statistics.documentsCount] Number of documents + * submitted in the request. + * @property {number} [statistics.validDocumentsCount] Number of valid + * documents. This excludes empty, over-size limit or non-supported languages + * documents. + * @property {number} [statistics.erroneousDocumentsCount] Number of invalid + * documents. This includes empty, over-size limit or non-supported languages + * documents. + * @property {number} [statistics.transactionsCount] Number of transactions + * for the request. */ constructor() { } @@ -67,6 +80,15 @@ class KeyPhraseBatchResult { } } } + }, + statistics: { + required: false, + readOnly: true, + serializedName: 'statistics', + type: { + name: 'Composite', + className: 'RequestStatistics' + } } } } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/keyPhraseBatchResultItem.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/keyPhraseBatchResultItem.js index b00a412880..501acc1cff 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/keyPhraseBatchResultItem.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/keyPhraseBatchResultItem.js @@ -16,10 +16,17 @@ class KeyPhraseBatchResultItem { /** * Create a KeyPhraseBatchResultItem. - * @member {array} [keyPhrases] A list of representative words or phrases. + * @property {string} [id] Unique, non-empty document identifier. + * @property {array} [keyPhrases] A list of representative words or phrases. * The number of key phrases returned is proportional to the number of words * in the input document. - * @member {string} [id] Unique document identifier. + * @property {object} [statistics] (Optional) if showStats=true was specified + * in the request this field will contain information about the document + * payload. + * @property {number} [statistics.charactersCount] Number of text elements + * recognized in the document. + * @property {number} [statistics.transactionsCount] Number of transactions + * for the document. */ constructor() { } @@ -38,6 +45,13 @@ class KeyPhraseBatchResultItem { name: 'Composite', className: 'KeyPhraseBatchResultItem', modelProperties: { + id: { + required: false, + serializedName: 'id', + type: { + name: 'String' + } + }, keyPhrases: { required: false, readOnly: true, @@ -53,12 +67,12 @@ class KeyPhraseBatchResultItem { } } }, - id: { + statistics: { required: false, - readOnly: true, - serializedName: 'id', + serializedName: 'statistics', type: { - name: 'String' + name: 'Composite', + className: 'DocumentStatistics' } } } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/languageBatchInput.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/languageBatchInput.js new file mode 100644 index 0000000000..7c711d5cf4 --- /dev/null +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/languageBatchInput.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Class representing a LanguageBatchInput. + */ +class LanguageBatchInput { + /** + * Create a LanguageBatchInput. + * @property {array} [documents] + */ + constructor() { + } + + /** + * Defines the metadata of LanguageBatchInput + * + * @returns {object} metadata of LanguageBatchInput + * + */ + mapper() { + return { + required: false, + serializedName: 'LanguageBatchInput', + type: { + name: 'Composite', + className: 'LanguageBatchInput', + modelProperties: { + documents: { + required: false, + serializedName: 'documents', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'LanguageInputElementType', + type: { + name: 'Composite', + className: 'LanguageInput' + } + } + } + } + } + } + }; + } +} + +module.exports = LanguageBatchInput; diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/languageBatchResult.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/languageBatchResult.js index 3235702f2b..e2d3e8464e 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/languageBatchResult.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/languageBatchResult.js @@ -16,8 +16,21 @@ class LanguageBatchResult { /** * Create a LanguageBatchResult. - * @member {array} [documents] - * @member {array} [errors] + * @property {array} [documents] Response by document + * @property {array} [errors] Errors and Warnings by document + * @property {object} [statistics] (Optional) if showStats=true was specified + * in the request this field will contain information about the request + * payload. + * @property {number} [statistics.documentsCount] Number of documents + * submitted in the request. + * @property {number} [statistics.validDocumentsCount] Number of valid + * documents. This excludes empty, over-size limit or non-supported languages + * documents. + * @property {number} [statistics.erroneousDocumentsCount] Number of invalid + * documents. This includes empty, over-size limit or non-supported languages + * documents. + * @property {number} [statistics.transactionsCount] Number of transactions + * for the request. */ constructor() { } @@ -67,6 +80,15 @@ class LanguageBatchResult { } } } + }, + statistics: { + required: false, + readOnly: true, + serializedName: 'statistics', + type: { + name: 'Composite', + className: 'RequestStatistics' + } } } } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/languageBatchResultItem.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/languageBatchResultItem.js index 02bbf8ecdd..abca32f5bd 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/languageBatchResultItem.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/languageBatchResultItem.js @@ -16,8 +16,15 @@ class LanguageBatchResultItem { /** * Create a LanguageBatchResultItem. - * @member {string} [id] Unique document identifier. - * @member {array} [detectedLanguages] A list of extracted languages. + * @property {string} [id] Unique, non-empty document identifier. + * @property {array} [detectedLanguages] A list of extracted languages. + * @property {object} [statistics] (Optional) if showStats=true was specified + * in the request this field will contain information about the document + * payload. + * @property {number} [statistics.charactersCount] Number of text elements + * recognized in the document. + * @property {number} [statistics.transactionsCount] Number of transactions + * for the document. */ constructor() { } @@ -38,7 +45,6 @@ class LanguageBatchResultItem { modelProperties: { id: { required: false, - readOnly: true, serializedName: 'id', type: { name: 'String' @@ -46,7 +52,6 @@ class LanguageBatchResultItem { }, detectedLanguages: { required: false, - readOnly: true, serializedName: 'detectedLanguages', type: { name: 'Sequence', @@ -59,6 +64,14 @@ class LanguageBatchResultItem { } } } + }, + statistics: { + required: false, + serializedName: 'statistics', + type: { + name: 'Composite', + className: 'DocumentStatistics' + } } } } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/languageInput.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/languageInput.js new file mode 100644 index 0000000000..beb82a44aa --- /dev/null +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/languageInput.js @@ -0,0 +1,67 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Class representing a LanguageInput. + */ +class LanguageInput { + /** + * Create a LanguageInput. + * @property {string} [countryHint] + * @property {string} [id] Unique, non-empty document identifier. + * @property {string} [text] + */ + constructor() { + } + + /** + * Defines the metadata of LanguageInput + * + * @returns {object} metadata of LanguageInput + * + */ + mapper() { + return { + required: false, + serializedName: 'LanguageInput', + type: { + name: 'Composite', + className: 'LanguageInput', + modelProperties: { + countryHint: { + required: false, + serializedName: 'countryHint', + type: { + name: 'String' + } + }, + id: { + required: false, + serializedName: 'id', + type: { + name: 'String' + } + }, + text: { + required: false, + serializedName: 'text', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = LanguageInput; diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/matchRecord.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/matchRecord.js index d6ddc4a6c8..bf5045ab60 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/matchRecord.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/matchRecord.js @@ -16,10 +16,16 @@ class MatchRecord { /** * Create a MatchRecord. - * @member {string} [text] Entity text as appears in the request. - * @member {number} [offset] Start position (in Unicode characters) for the + * @property {number} [wikipediaScore] (optional) If a well-known item with + * Wikipedia link is recognized, a decimal number denoting the confidence + * level of the Wikipedia info will be returned. + * @property {number} [entityTypeScore] (optional) If an entity type is + * recognized, a decimal number denoting the confidence level of the entity + * type will be returned. + * @property {string} [text] Entity text as appears in the request. + * @property {number} [offset] Start position (in Unicode characters) for the * entity match text. - * @member {number} [length] Length (in Unicode characters) for the entity + * @property {number} [length] Length (in Unicode characters) for the entity * match text. */ constructor() { @@ -39,6 +45,20 @@ class MatchRecord { name: 'Composite', className: 'MatchRecord', modelProperties: { + wikipediaScore: { + required: false, + serializedName: 'wikipediaScore', + type: { + name: 'Number' + } + }, + entityTypeScore: { + required: false, + serializedName: 'entityTypeScore', + type: { + name: 'Number' + } + }, text: { required: false, serializedName: 'text', diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/multiLanguageBatchInput.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/multiLanguageBatchInput.js index 648daa4ea1..71f84914f3 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/multiLanguageBatchInput.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/multiLanguageBatchInput.js @@ -16,7 +16,7 @@ class MultiLanguageBatchInput { /** * Create a MultiLanguageBatchInput. - * @member {array} [documents] + * @property {array} [documents] */ constructor() { } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/multiLanguageInput.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/multiLanguageInput.js index 5501b9713a..f9e796d558 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/multiLanguageInput.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/multiLanguageInput.js @@ -16,10 +16,11 @@ class MultiLanguageInput { /** * Create a MultiLanguageInput. - * @member {string} [language] This is the 2 letter ISO 639-1 representation - * of a language. For example, use "en" for English; "es" for Spanish etc., - * @member {string} [id] Unique, non-empty document identifier. - * @member {string} [text] + * @property {string} [language] This is the 2 letter ISO 639-1 + * representation of a language. For example, use "en" for English; "es" for + * Spanish etc., + * @property {string} [id] Unique, non-empty document identifier. + * @property {string} [text] */ constructor() { } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/requestStatistics.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/requestStatistics.js new file mode 100644 index 0000000000..17952bfa62 --- /dev/null +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/requestStatistics.js @@ -0,0 +1,79 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Class representing a RequestStatistics. + */ +class RequestStatistics { + /** + * Create a RequestStatistics. + * @property {number} [documentsCount] Number of documents submitted in the + * request. + * @property {number} [validDocumentsCount] Number of valid documents. This + * excludes empty, over-size limit or non-supported languages documents. + * @property {number} [erroneousDocumentsCount] Number of invalid documents. + * This includes empty, over-size limit or non-supported languages documents. + * @property {number} [transactionsCount] Number of transactions for the + * request. + */ + constructor() { + } + + /** + * Defines the metadata of RequestStatistics + * + * @returns {object} metadata of RequestStatistics + * + */ + mapper() { + return { + required: false, + serializedName: 'RequestStatistics', + type: { + name: 'Composite', + className: 'RequestStatistics', + modelProperties: { + documentsCount: { + required: false, + serializedName: 'documentsCount', + type: { + name: 'Number' + } + }, + validDocumentsCount: { + required: false, + serializedName: 'validDocumentsCount', + type: { + name: 'Number' + } + }, + erroneousDocumentsCount: { + required: false, + serializedName: 'erroneousDocumentsCount', + type: { + name: 'Number' + } + }, + transactionsCount: { + required: false, + serializedName: 'transactionsCount', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = RequestStatistics; diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/sentimentBatchResult.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/sentimentBatchResult.js index 649570db4b..e9d19ad5e2 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/sentimentBatchResult.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/sentimentBatchResult.js @@ -16,8 +16,21 @@ class SentimentBatchResult { /** * Create a SentimentBatchResult. - * @member {array} [documents] - * @member {array} [errors] + * @property {array} [documents] Response by document + * @property {array} [errors] Errors and Warnings by document + * @property {object} [statistics] (Optional) if showStats=true was specified + * in the request this field will contain information about the request + * payload. + * @property {number} [statistics.documentsCount] Number of documents + * submitted in the request. + * @property {number} [statistics.validDocumentsCount] Number of valid + * documents. This excludes empty, over-size limit or non-supported languages + * documents. + * @property {number} [statistics.erroneousDocumentsCount] Number of invalid + * documents. This includes empty, over-size limit or non-supported languages + * documents. + * @property {number} [statistics.transactionsCount] Number of transactions + * for the request. */ constructor() { } @@ -67,6 +80,15 @@ class SentimentBatchResult { } } } + }, + statistics: { + required: false, + readOnly: true, + serializedName: 'statistics', + type: { + name: 'Composite', + className: 'RequestStatistics' + } } } } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/models/sentimentBatchResultItem.js b/lib/services/cognitiveServicesTextAnalytics/lib/models/sentimentBatchResultItem.js index d1c68dff82..bda737e249 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/models/sentimentBatchResultItem.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/models/sentimentBatchResultItem.js @@ -16,11 +16,18 @@ class SentimentBatchResultItem { /** * Create a SentimentBatchResultItem. - * @member {number} [score] A decimal number between 0 and 1 denoting the + * @property {string} [id] Unique, non-empty document identifier. + * @property {number} [score] A decimal number between 0 and 1 denoting the * sentiment of the document. A score above 0.7 usually refers to a positive * document while a score below 0.3 normally has a negative connotation. Mid * values refer to neutral text. - * @member {string} [id] Unique document identifier. + * @property {object} [statistics] (Optional) if showStats=true was specified + * in the request this field will contain information about the document + * payload. + * @property {number} [statistics.charactersCount] Number of text elements + * recognized in the document. + * @property {number} [statistics.transactionsCount] Number of transactions + * for the document. */ constructor() { } @@ -39,20 +46,26 @@ class SentimentBatchResultItem { name: 'Composite', className: 'SentimentBatchResultItem', modelProperties: { + id: { + required: false, + serializedName: 'id', + type: { + name: 'String' + } + }, score: { required: false, - readOnly: true, serializedName: 'score', type: { name: 'Number' } }, - id: { + statistics: { required: false, - readOnly: true, - serializedName: 'id', + serializedName: 'statistics', type: { - name: 'String' + name: 'Composite', + className: 'DocumentStatistics' } } } diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/textAnalyticsClient.d.ts b/lib/services/cognitiveServicesTextAnalytics/lib/textAnalyticsClient.d.ts index 02c23798ef..9f0f8f319d 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/textAnalyticsClient.d.ts +++ b/lib/services/cognitiveServicesTextAnalytics/lib/textAnalyticsClient.d.ts @@ -39,47 +39,49 @@ export default class TextAnalyticsClient extends ServiceClient { /** - * @summary The API returns a list of strings denoting the key talking points - * in the input text. + * @summary The API returns the detected language and a numeric score between 0 + * and 1. * - * See the Text - * Analytics Documentation for details about the languages that are - * supported by key phrase extraction. + * Scores close to 1 indicate 100% certainty that the identified language is + * true. A total of 120 languages are supported. + * + * @param {object} [options] Optional Parameters. * - * @param {object} input Collection of documents to analyze. Documents can now - * contain a language field to indicate the text language + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {array} [input.documents] + * @param {object} [options.languageBatchInput] Collection of documents to + * analyze. * - * @param {object} [options] Optional Parameters. + * @param {array} [options.languageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - keyPhrasesWithHttpOperationResponse(input: models.MultiLanguageBatchInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + detectLanguageWithHttpOperationResponse(options?: { showStats? : boolean, languageBatchInput? : models.LanguageBatchInput, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * @summary The API returns a list of strings denoting the key talking points - * in the input text. + * @summary The API returns the detected language and a numeric score between 0 + * and 1. * - * See the Text - * Analytics Documentation for details about the languages that are - * supported by key phrase extraction. + * Scores close to 1 indicate 100% certainty that the identified language is + * true. A total of 120 languages are supported. * - * @param {object} input Collection of documents to analyze. Documents can now - * contain a language field to indicate the text language + * @param {object} [options] Optional Parameters. * - * @param {array} [input.documents] + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {object} [options] Optional Parameters. + * @param {object} [options.languageBatchInput] Collection of documents to + * analyze. + * + * @param {array} [options.languageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -91,7 +93,7 @@ export default class TextAnalyticsClient extends ServiceClient { * * {Promise} A promise is returned. * - * @resolve {KeyPhraseBatchResult} - The deserialized result object. + * @resolve {LanguageBatchResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -99,54 +101,66 @@ export default class TextAnalyticsClient extends ServiceClient { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {KeyPhraseBatchResult} [result] - The deserialized result object if an error did not occur. - * See {@link KeyPhraseBatchResult} for more information. + * {LanguageBatchResult} [result] - The deserialized result object if an error did not occur. + * See {@link LanguageBatchResult} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - keyPhrases(input: models.MultiLanguageBatchInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - keyPhrases(input: models.MultiLanguageBatchInput, callback: ServiceCallback): void; - keyPhrases(input: models.MultiLanguageBatchInput, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + detectLanguage(options?: { showStats? : boolean, languageBatchInput? : models.LanguageBatchInput, customHeaders? : { [headerName: string]: string; } }): Promise; + detectLanguage(callback: ServiceCallback): void; + detectLanguage(options: { showStats? : boolean, languageBatchInput? : models.LanguageBatchInput, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * @summary The API returns the detected language and a numeric score between 0 - * and 1. + * @summary The API returns a list of recognized entities in a given document. * - * Scores close to 1 indicate 100% certainty that the identified language is - * true. A total of 120 languages are supported. + * To get even more information on each recognized entity we recommend using + * the Bing Entity Search API by querying for the recognized entities names. + * See the Supported + * languages in Text Analytics API for the list of enabled languages. * - * @param {object} input Collection of documents to analyze. + * @param {object} [options] Optional Parameters. * - * @param {array} [input.documents] + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {object} [options] Optional Parameters. + * @param {object} [options.multiLanguageBatchInput] Collection of documents to + * analyze. + * + * @param {array} [options.multiLanguageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - detectLanguageWithHttpOperationResponse(input: models.BatchInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + entitiesWithHttpOperationResponse(options?: { showStats? : boolean, multiLanguageBatchInput? : models.MultiLanguageBatchInput, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * @summary The API returns the detected language and a numeric score between 0 - * and 1. + * @summary The API returns a list of recognized entities in a given document. * - * Scores close to 1 indicate 100% certainty that the identified language is - * true. A total of 120 languages are supported. + * To get even more information on each recognized entity we recommend using + * the Bing Entity Search API by querying for the recognized entities names. + * See the Supported + * languages in Text Analytics API for the list of enabled languages. + * + * @param {object} [options] Optional Parameters. * - * @param {object} input Collection of documents to analyze. + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {array} [input.documents] + * @param {object} [options.multiLanguageBatchInput] Collection of documents to + * analyze. * - * @param {object} [options] Optional Parameters. + * @param {array} [options.multiLanguageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -158,7 +172,7 @@ export default class TextAnalyticsClient extends ServiceClient { * * {Promise} A promise is returned. * - * @resolve {LanguageBatchResult} - The deserialized result object. + * @resolve {EntitiesBatchResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -166,60 +180,68 @@ export default class TextAnalyticsClient extends ServiceClient { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {LanguageBatchResult} [result] - The deserialized result object if an error did not occur. - * See {@link LanguageBatchResult} for more information. + * {EntitiesBatchResult} [result] - The deserialized result object if an error did not occur. + * See {@link EntitiesBatchResult} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - detectLanguage(input: models.BatchInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - detectLanguage(input: models.BatchInput, callback: ServiceCallback): void; - detectLanguage(input: models.BatchInput, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + entities(options?: { showStats? : boolean, multiLanguageBatchInput? : models.MultiLanguageBatchInput, customHeaders? : { [headerName: string]: string; } }): Promise; + entities(callback: ServiceCallback): void; + entities(options: { showStats? : boolean, multiLanguageBatchInput? : models.MultiLanguageBatchInput, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * @summary The API returns a numeric score between 0 and 1. + * @summary The API returns a list of strings denoting the key talking points + * in the input text. * - * Scores close to 1 indicate positive sentiment, while scores close to 0 - * indicate negative sentiment. A score of 0.5 indicates the lack of sentiment - * (e.g. a factoid statement). See the Text * Analytics Documentation for details about the languages that are - * supported by sentiment analysis. + * supported by key phrase extraction. * - * @param {object} input Collection of documents to analyze. + * @param {object} [options] Optional Parameters. * - * @param {array} [input.documents] + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {object} [options] Optional Parameters. + * @param {object} [options.multiLanguageBatchInput] Collection of documents to + * analyze. Documents can now contain a language field to indicate the text + * language + * + * @param {array} [options.multiLanguageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - sentimentWithHttpOperationResponse(input: models.MultiLanguageBatchInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + keyPhrasesWithHttpOperationResponse(options?: { showStats? : boolean, multiLanguageBatchInput? : models.MultiLanguageBatchInput, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * @summary The API returns a numeric score between 0 and 1. + * @summary The API returns a list of strings denoting the key talking points + * in the input text. * - * Scores close to 1 indicate positive sentiment, while scores close to 0 - * indicate negative sentiment. A score of 0.5 indicates the lack of sentiment - * (e.g. a factoid statement). See the Text * Analytics Documentation for details about the languages that are - * supported by sentiment analysis. + * supported by key phrase extraction. + * + * @param {object} [options] Optional Parameters. * - * @param {object} input Collection of documents to analyze. + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {array} [input.documents] + * @param {object} [options.multiLanguageBatchInput] Collection of documents to + * analyze. Documents can now contain a language field to indicate the text + * language * - * @param {object} [options] Optional Parameters. + * @param {array} [options.multiLanguageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -231,7 +253,7 @@ export default class TextAnalyticsClient extends ServiceClient { * * {Promise} A promise is returned. * - * @resolve {SentimentBatchResult} - The deserialized result object. + * @resolve {KeyPhraseBatchResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -239,58 +261,68 @@ export default class TextAnalyticsClient extends ServiceClient { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {SentimentBatchResult} [result] - The deserialized result object if an error did not occur. - * See {@link SentimentBatchResult} for more information. + * {KeyPhraseBatchResult} [result] - The deserialized result object if an error did not occur. + * See {@link KeyPhraseBatchResult} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - sentiment(input: models.MultiLanguageBatchInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - sentiment(input: models.MultiLanguageBatchInput, callback: ServiceCallback): void; - sentiment(input: models.MultiLanguageBatchInput, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + keyPhrases(options?: { showStats? : boolean, multiLanguageBatchInput? : models.MultiLanguageBatchInput, customHeaders? : { [headerName: string]: string; } }): Promise; + keyPhrases(callback: ServiceCallback): void; + keyPhrases(options: { showStats? : boolean, multiLanguageBatchInput? : models.MultiLanguageBatchInput, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * @summary The API returns a list of recognized entities in a given document. + * @summary The API returns a numeric score between 0 and 1. * - * To get even more information on each recognized entity we recommend using - * the Bing Entity Search API by querying for the recognized entities names. - * See the Supported - * languages in Text Analytics API for the list of enabled languages. + * Scores close to 1 indicate positive sentiment, while scores close to 0 + * indicate negative sentiment. A score of 0.5 indicates the lack of sentiment + * (e.g. a factoid statement). See the Text + * Analytics Documentation for details about the languages that are + * supported by sentiment analysis. + * + * @param {object} [options] Optional Parameters. * - * @param {object} input Collection of documents to analyze. + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {array} [input.documents] + * @param {object} [options.multiLanguageBatchInput] Collection of documents to + * analyze. * - * @param {object} [options] Optional Parameters. + * @param {array} [options.multiLanguageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - entitiesWithHttpOperationResponse(input: models.MultiLanguageBatchInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + sentimentWithHttpOperationResponse(options?: { showStats? : boolean, multiLanguageBatchInput? : models.MultiLanguageBatchInput, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * @summary The API returns a list of recognized entities in a given document. + * @summary The API returns a numeric score between 0 and 1. * - * To get even more information on each recognized entity we recommend using - * the Bing Entity Search API by querying for the recognized entities names. - * See the Supported - * languages in Text Analytics API for the list of enabled languages. + * Scores close to 1 indicate positive sentiment, while scores close to 0 + * indicate negative sentiment. A score of 0.5 indicates the lack of sentiment + * (e.g. a factoid statement). See the Text + * Analytics Documentation for details about the languages that are + * supported by sentiment analysis. * - * @param {object} input Collection of documents to analyze. + * @param {object} [options] Optional Parameters. * - * @param {array} [input.documents] + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {object} [options] Optional Parameters. + * @param {object} [options.multiLanguageBatchInput] Collection of documents to + * analyze. + * + * @param {array} [options.multiLanguageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -302,7 +334,7 @@ export default class TextAnalyticsClient extends ServiceClient { * * {Promise} A promise is returned. * - * @resolve {EntitiesBatchResult} - The deserialized result object. + * @resolve {Object} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -310,16 +342,15 @@ export default class TextAnalyticsClient extends ServiceClient { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {EntitiesBatchResult} [result] - The deserialized result object if an error did not occur. - * See {@link EntitiesBatchResult} for more information. + * {Object} [result] - The deserialized result object if an error did not occur. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - entities(input: models.MultiLanguageBatchInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - entities(input: models.MultiLanguageBatchInput, callback: ServiceCallback): void; - entities(input: models.MultiLanguageBatchInput, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + sentiment(options?: { showStats? : boolean, multiLanguageBatchInput? : models.MultiLanguageBatchInput, customHeaders? : { [headerName: string]: string; } }): Promise; + sentiment(callback: ServiceCallback): void; + sentiment(options: { showStats? : boolean, multiLanguageBatchInput? : models.MultiLanguageBatchInput, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } export { TextAnalyticsClient, models as TextAnalyticsModels }; diff --git a/lib/services/cognitiveServicesTextAnalytics/lib/textAnalyticsClient.js b/lib/services/cognitiveServicesTextAnalytics/lib/textAnalyticsClient.js index fb9ec4899e..59bc8a2946 100644 --- a/lib/services/cognitiveServicesTextAnalytics/lib/textAnalyticsClient.js +++ b/lib/services/cognitiveServicesTextAnalytics/lib/textAnalyticsClient.js @@ -22,20 +22,21 @@ const models = require('./models'); /** - * @summary The API returns a list of strings denoting the key talking points - * in the input text. + * @summary The API returns the detected language and a numeric score between 0 + * and 1. * - * See the Text - * Analytics Documentation for details about the languages that are - * supported by key phrase extraction. + * Scores close to 1 indicate 100% certainty that the identified language is + * true. A total of 120 languages are supported. * - * @param {object} input Collection of documents to analyze. Documents can now - * contain a language field to indicate the text language + * @param {object} [options] Optional Parameters. * - * @param {array} [input.documents] + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {object} [options] Optional Parameters. + * @param {object} [options.languageBatchInput] Collection of documents to + * analyze. + * + * @param {array} [options.languageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -47,13 +48,13 @@ const models = require('./models'); * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link KeyPhraseBatchResult} for more information. + * See {@link LanguageBatchResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _keyPhrases(input, options, callback) { +function _detectLanguage(options, callback) { /* jshint validthis: true */ let client = this; if(!callback && typeof options === 'function') { @@ -63,13 +64,15 @@ function _keyPhrases(input, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let showStats = (options && options.showStats !== undefined) ? options.showStats : undefined; + let languageBatchInput = (options && options.languageBatchInput !== undefined) ? options.languageBatchInput : undefined; // Validate try { if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } - if (input === null || input === undefined) { - throw new Error('input cannot be null or undefined.'); + if (showStats !== null && showStats !== undefined && typeof showStats !== 'boolean') { + throw new Error('showStats must be of type boolean.'); } } catch (error) { return callback(error); @@ -77,8 +80,15 @@ function _keyPhrases(input, options, callback) { // Construct URL let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'keyPhrases'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'languages'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + let queryParameters = []; + if (showStats !== null && showStats !== undefined) { + queryParameters.push('showStats=' + encodeURIComponent(showStats.toString())); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -98,14 +108,14 @@ function _keyPhrases(input, options, callback) { let requestContent = null; let requestModel = null; try { - if (input !== null && input !== undefined) { - let requestModelMapper = new client.models['MultiLanguageBatchInput']().mapper(); - requestModel = client.serialize(requestModelMapper, input, 'input'); + if (languageBatchInput !== null && languageBatchInput !== undefined) { + let requestModelMapper = new client.models['LanguageBatchInput']().mapper(); + requestModel = client.serialize(requestModelMapper, languageBatchInput, 'languageBatchInput'); requestContent = JSON.stringify(requestModel); } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(input, null, 2)}.`); + `payload - ${JSON.stringify(languageBatchInput, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; @@ -151,7 +161,7 @@ function _keyPhrases(input, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['KeyPhraseBatchResult']().mapper(); + let resultMapper = new client.models['LanguageBatchResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -167,17 +177,23 @@ function _keyPhrases(input, options, callback) { } /** - * @summary The API returns the detected language and a numeric score between 0 - * and 1. + * @summary The API returns a list of recognized entities in a given document. * - * Scores close to 1 indicate 100% certainty that the identified language is - * true. A total of 120 languages are supported. + * To get even more information on each recognized entity we recommend using + * the Bing Entity Search API by querying for the recognized entities names. + * See the Supported + * languages in Text Analytics API for the list of enabled languages. * - * @param {object} input Collection of documents to analyze. + * @param {object} [options] Optional Parameters. * - * @param {array} [input.documents] + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {object} [options] Optional Parameters. + * @param {object} [options.multiLanguageBatchInput] Collection of documents to + * analyze. + * + * @param {array} [options.multiLanguageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -189,13 +205,13 @@ function _keyPhrases(input, options, callback) { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link LanguageBatchResult} for more information. + * See {@link EntitiesBatchResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _detectLanguage(input, options, callback) { +function _entities(options, callback) { /* jshint validthis: true */ let client = this; if(!callback && typeof options === 'function') { @@ -205,13 +221,15 @@ function _detectLanguage(input, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let showStats = (options && options.showStats !== undefined) ? options.showStats : undefined; + let multiLanguageBatchInput = (options && options.multiLanguageBatchInput !== undefined) ? options.multiLanguageBatchInput : undefined; // Validate try { if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } - if (input === null || input === undefined) { - throw new Error('input cannot be null or undefined.'); + if (showStats !== null && showStats !== undefined && typeof showStats !== 'boolean') { + throw new Error('showStats must be of type boolean.'); } } catch (error) { return callback(error); @@ -219,8 +237,15 @@ function _detectLanguage(input, options, callback) { // Construct URL let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'languages'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'entities'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + let queryParameters = []; + if (showStats !== null && showStats !== undefined) { + queryParameters.push('showStats=' + encodeURIComponent(showStats.toString())); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -240,14 +265,14 @@ function _detectLanguage(input, options, callback) { let requestContent = null; let requestModel = null; try { - if (input !== null && input !== undefined) { - let requestModelMapper = new client.models['BatchInput']().mapper(); - requestModel = client.serialize(requestModelMapper, input, 'input'); + if (multiLanguageBatchInput !== null && multiLanguageBatchInput !== undefined) { + let requestModelMapper = new client.models['MultiLanguageBatchInput']().mapper(); + requestModel = client.serialize(requestModelMapper, multiLanguageBatchInput, 'multiLanguageBatchInput'); requestContent = JSON.stringify(requestModel); } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(input, null, 2)}.`); + `payload - ${JSON.stringify(multiLanguageBatchInput, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; @@ -293,7 +318,7 @@ function _detectLanguage(input, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['LanguageBatchResult']().mapper(); + let resultMapper = new client.models['EntitiesBatchResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -309,20 +334,24 @@ function _detectLanguage(input, options, callback) { } /** - * @summary The API returns a numeric score between 0 and 1. + * @summary The API returns a list of strings denoting the key talking points + * in the input text. * - * Scores close to 1 indicate positive sentiment, while scores close to 0 - * indicate negative sentiment. A score of 0.5 indicates the lack of sentiment - * (e.g. a factoid statement). See the Text * Analytics Documentation for details about the languages that are - * supported by sentiment analysis. + * supported by key phrase extraction. + * + * @param {object} [options] Optional Parameters. * - * @param {object} input Collection of documents to analyze. + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {array} [input.documents] + * @param {object} [options.multiLanguageBatchInput] Collection of documents to + * analyze. Documents can now contain a language field to indicate the text + * language * - * @param {object} [options] Optional Parameters. + * @param {array} [options.multiLanguageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -334,13 +363,13 @@ function _detectLanguage(input, options, callback) { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link SentimentBatchResult} for more information. + * See {@link KeyPhraseBatchResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _sentiment(input, options, callback) { +function _keyPhrases(options, callback) { /* jshint validthis: true */ let client = this; if(!callback && typeof options === 'function') { @@ -350,13 +379,15 @@ function _sentiment(input, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let showStats = (options && options.showStats !== undefined) ? options.showStats : undefined; + let multiLanguageBatchInput = (options && options.multiLanguageBatchInput !== undefined) ? options.multiLanguageBatchInput : undefined; // Validate try { if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } - if (input === null || input === undefined) { - throw new Error('input cannot be null or undefined.'); + if (showStats !== null && showStats !== undefined && typeof showStats !== 'boolean') { + throw new Error('showStats must be of type boolean.'); } } catch (error) { return callback(error); @@ -364,8 +395,15 @@ function _sentiment(input, options, callback) { // Construct URL let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'sentiment'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'keyPhrases'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + let queryParameters = []; + if (showStats !== null && showStats !== undefined) { + queryParameters.push('showStats=' + encodeURIComponent(showStats.toString())); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -385,14 +423,14 @@ function _sentiment(input, options, callback) { let requestContent = null; let requestModel = null; try { - if (input !== null && input !== undefined) { + if (multiLanguageBatchInput !== null && multiLanguageBatchInput !== undefined) { let requestModelMapper = new client.models['MultiLanguageBatchInput']().mapper(); - requestModel = client.serialize(requestModelMapper, input, 'input'); + requestModel = client.serialize(requestModelMapper, multiLanguageBatchInput, 'multiLanguageBatchInput'); requestContent = JSON.stringify(requestModel); } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(input, null, 2)}.`); + `payload - ${JSON.stringify(multiLanguageBatchInput, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; @@ -438,7 +476,7 @@ function _sentiment(input, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['SentimentBatchResult']().mapper(); + let resultMapper = new client.models['KeyPhraseBatchResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -454,19 +492,24 @@ function _sentiment(input, options, callback) { } /** - * @summary The API returns a list of recognized entities in a given document. + * @summary The API returns a numeric score between 0 and 1. * - * To get even more information on each recognized entity we recommend using - * the Bing Entity Search API by querying for the recognized entities names. - * See the Supported - * languages in Text Analytics API for the list of enabled languages. + * Scores close to 1 indicate positive sentiment, while scores close to 0 + * indicate negative sentiment. A score of 0.5 indicates the lack of sentiment + * (e.g. a factoid statement). See the Text + * Analytics Documentation for details about the languages that are + * supported by sentiment analysis. * - * @param {object} input Collection of documents to analyze. + * @param {object} [options] Optional Parameters. * - * @param {array} [input.documents] + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {object} [options] Optional Parameters. + * @param {object} [options.multiLanguageBatchInput] Collection of documents to + * analyze. + * + * @param {array} [options.multiLanguageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -478,13 +521,12 @@ function _sentiment(input, options, callback) { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link EntitiesBatchResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _entities(input, options, callback) { +function _sentiment(options, callback) { /* jshint validthis: true */ let client = this; if(!callback && typeof options === 'function') { @@ -494,13 +536,15 @@ function _entities(input, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let showStats = (options && options.showStats !== undefined) ? options.showStats : undefined; + let multiLanguageBatchInput = (options && options.multiLanguageBatchInput !== undefined) ? options.multiLanguageBatchInput : undefined; // Validate try { if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } - if (input === null || input === undefined) { - throw new Error('input cannot be null or undefined.'); + if (showStats !== null && showStats !== undefined && typeof showStats !== 'boolean') { + throw new Error('showStats must be of type boolean.'); } } catch (error) { return callback(error); @@ -508,8 +552,15 @@ function _entities(input, options, callback) { // Construct URL let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'entities'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'sentiment'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + let queryParameters = []; + if (showStats !== null && showStats !== undefined) { + queryParameters.push('showStats=' + encodeURIComponent(showStats.toString())); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -529,14 +580,14 @@ function _entities(input, options, callback) { let requestContent = null; let requestModel = null; try { - if (input !== null && input !== undefined) { + if (multiLanguageBatchInput !== null && multiLanguageBatchInput !== undefined) { let requestModelMapper = new client.models['MultiLanguageBatchInput']().mapper(); - requestModel = client.serialize(requestModelMapper, input, 'input'); + requestModel = client.serialize(requestModelMapper, multiLanguageBatchInput, 'multiLanguageBatchInput'); requestContent = JSON.stringify(requestModel); } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(input, null, 2)}.`); + `payload - ${JSON.stringify(multiLanguageBatchInput, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; @@ -546,7 +597,7 @@ function _entities(input, options, callback) { return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 200) { + if (statusCode !== 200 && statusCode !== 500) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -561,10 +612,6 @@ function _entities(input, options, callback) { error.code = internalError ? internalError.code : parsedErrorResponse.code; error.message = internalError ? internalError.message : parsedErrorResponse.message; } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['ErrorResponse']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + `- "${responseBody}" for the default response.`; @@ -582,7 +629,7 @@ function _entities(input, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['EntitiesBatchResult']().mapper(); + let resultMapper = new client.models['SentimentBatchResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -592,6 +639,23 @@ function _entities(input, options, callback) { return callback(deserializationError); } } + // Deserialize Response + if (statusCode === 500) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } return callback(null, result, httpRequest, response); }); @@ -621,50 +685,51 @@ class TextAnalyticsClient extends ServiceClient { super(credentials, options); - this.baseUri = '{Endpoint}/text/analytics/v2.0'; + this.baseUri = '{Endpoint}/text/analytics/v2.1'; this.credentials = credentials; this.endpoint = endpoint; let packageInfo = this.getPackageJsonInfo(__dirname); this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); this.models = models; - this._keyPhrases = _keyPhrases; this._detectLanguage = _detectLanguage; - this._sentiment = _sentiment; this._entities = _entities; + this._keyPhrases = _keyPhrases; + this._sentiment = _sentiment; msRest.addSerializationMixin(this); } /** - * @summary The API returns a list of strings denoting the key talking points - * in the input text. + * @summary The API returns the detected language and a numeric score between 0 + * and 1. * - * See the Text - * Analytics Documentation for details about the languages that are - * supported by key phrase extraction. + * Scores close to 1 indicate 100% certainty that the identified language is + * true. A total of 120 languages are supported. * - * @param {object} input Collection of documents to analyze. Documents can now - * contain a language field to indicate the text language + * @param {object} [options] Optional Parameters. * - * @param {array} [input.documents] + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {object} [options] Optional Parameters. + * @param {object} [options.languageBatchInput] Collection of documents to + * analyze. + * + * @param {array} [options.languageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - keyPhrasesWithHttpOperationResponse(input, options) { + detectLanguageWithHttpOperationResponse(options) { let client = this; let self = this; return new Promise((resolve, reject) => { - self._keyPhrases(input, options, (err, result, request, response) => { + self._detectLanguage(options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -675,20 +740,21 @@ class TextAnalyticsClient extends ServiceClient { } /** - * @summary The API returns a list of strings denoting the key talking points - * in the input text. + * @summary The API returns the detected language and a numeric score between 0 + * and 1. * - * See the Text - * Analytics Documentation for details about the languages that are - * supported by key phrase extraction. + * Scores close to 1 indicate 100% certainty that the identified language is + * true. A total of 120 languages are supported. * - * @param {object} input Collection of documents to analyze. Documents can now - * contain a language field to indicate the text language + * @param {object} [options] Optional Parameters. * - * @param {array} [input.documents] + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {object} [options] Optional Parameters. + * @param {object} [options.languageBatchInput] Collection of documents to + * analyze. + * + * @param {array} [options.languageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -700,7 +766,7 @@ class TextAnalyticsClient extends ServiceClient { * * {Promise} A promise is returned * - * @resolve {KeyPhraseBatchResult} - The deserialized result object. + * @resolve {LanguageBatchResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -709,13 +775,13 @@ class TextAnalyticsClient extends ServiceClient { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link KeyPhraseBatchResult} for more information. + * See {@link LanguageBatchResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - keyPhrases(input, options, optionalCallback) { + detectLanguage(options, optionalCallback) { let client = this; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -724,44 +790,50 @@ class TextAnalyticsClient extends ServiceClient { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._keyPhrases(input, options, (err, result, request, response) => { + self._detectLanguage(options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._keyPhrases(input, options, optionalCallback); + return self._detectLanguage(options, optionalCallback); } } /** - * @summary The API returns the detected language and a numeric score between 0 - * and 1. + * @summary The API returns a list of recognized entities in a given document. * - * Scores close to 1 indicate 100% certainty that the identified language is - * true. A total of 120 languages are supported. + * To get even more information on each recognized entity we recommend using + * the Bing Entity Search API by querying for the recognized entities names. + * See the Supported + * languages in Text Analytics API for the list of enabled languages. + * + * @param {object} [options] Optional Parameters. * - * @param {object} input Collection of documents to analyze. + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {array} [input.documents] + * @param {object} [options.multiLanguageBatchInput] Collection of documents to + * analyze. * - * @param {object} [options] Optional Parameters. + * @param {array} [options.multiLanguageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - detectLanguageWithHttpOperationResponse(input, options) { + entitiesWithHttpOperationResponse(options) { let client = this; let self = this; return new Promise((resolve, reject) => { - self._detectLanguage(input, options, (err, result, request, response) => { + self._entities(options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -772,17 +844,23 @@ class TextAnalyticsClient extends ServiceClient { } /** - * @summary The API returns the detected language and a numeric score between 0 - * and 1. + * @summary The API returns a list of recognized entities in a given document. * - * Scores close to 1 indicate 100% certainty that the identified language is - * true. A total of 120 languages are supported. + * To get even more information on each recognized entity we recommend using + * the Bing Entity Search API by querying for the recognized entities names. + * See the Supported + * languages in Text Analytics API for the list of enabled languages. * - * @param {object} input Collection of documents to analyze. + * @param {object} [options] Optional Parameters. * - * @param {array} [input.documents] + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {object} [options] Optional Parameters. + * @param {object} [options.multiLanguageBatchInput] Collection of documents to + * analyze. + * + * @param {array} [options.multiLanguageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -794,7 +872,7 @@ class TextAnalyticsClient extends ServiceClient { * * {Promise} A promise is returned * - * @resolve {LanguageBatchResult} - The deserialized result object. + * @resolve {EntitiesBatchResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -803,13 +881,13 @@ class TextAnalyticsClient extends ServiceClient { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link LanguageBatchResult} for more information. + * See {@link EntitiesBatchResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - detectLanguage(input, options, optionalCallback) { + entities(options, optionalCallback) { let client = this; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -818,47 +896,51 @@ class TextAnalyticsClient extends ServiceClient { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._detectLanguage(input, options, (err, result, request, response) => { + self._entities(options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._detectLanguage(input, options, optionalCallback); + return self._entities(options, optionalCallback); } } /** - * @summary The API returns a numeric score between 0 and 1. + * @summary The API returns a list of strings denoting the key talking points + * in the input text. * - * Scores close to 1 indicate positive sentiment, while scores close to 0 - * indicate negative sentiment. A score of 0.5 indicates the lack of sentiment - * (e.g. a factoid statement). See the Text * Analytics Documentation for details about the languages that are - * supported by sentiment analysis. + * supported by key phrase extraction. + * + * @param {object} [options] Optional Parameters. * - * @param {object} input Collection of documents to analyze. + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {array} [input.documents] + * @param {object} [options.multiLanguageBatchInput] Collection of documents to + * analyze. Documents can now contain a language field to indicate the text + * language * - * @param {object} [options] Optional Parameters. + * @param {array} [options.multiLanguageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - sentimentWithHttpOperationResponse(input, options) { + keyPhrasesWithHttpOperationResponse(options) { let client = this; let self = this; return new Promise((resolve, reject) => { - self._sentiment(input, options, (err, result, request, response) => { + self._keyPhrases(options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -869,20 +951,24 @@ class TextAnalyticsClient extends ServiceClient { } /** - * @summary The API returns a numeric score between 0 and 1. + * @summary The API returns a list of strings denoting the key talking points + * in the input text. * - * Scores close to 1 indicate positive sentiment, while scores close to 0 - * indicate negative sentiment. A score of 0.5 indicates the lack of sentiment - * (e.g. a factoid statement). See the Text * Analytics Documentation for details about the languages that are - * supported by sentiment analysis. + * supported by key phrase extraction. * - * @param {object} input Collection of documents to analyze. + * @param {object} [options] Optional Parameters. * - * @param {array} [input.documents] + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {object} [options] Optional Parameters. + * @param {object} [options.multiLanguageBatchInput] Collection of documents to + * analyze. Documents can now contain a language field to indicate the text + * language + * + * @param {array} [options.multiLanguageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -894,7 +980,7 @@ class TextAnalyticsClient extends ServiceClient { * * {Promise} A promise is returned * - * @resolve {SentimentBatchResult} - The deserialized result object. + * @resolve {KeyPhraseBatchResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -903,13 +989,13 @@ class TextAnalyticsClient extends ServiceClient { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link SentimentBatchResult} for more information. + * See {@link KeyPhraseBatchResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - sentiment(input, options, optionalCallback) { + keyPhrases(options, optionalCallback) { let client = this; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -918,46 +1004,51 @@ class TextAnalyticsClient extends ServiceClient { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._sentiment(input, options, (err, result, request, response) => { + self._keyPhrases(options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._sentiment(input, options, optionalCallback); + return self._keyPhrases(options, optionalCallback); } } /** - * @summary The API returns a list of recognized entities in a given document. + * @summary The API returns a numeric score between 0 and 1. * - * To get even more information on each recognized entity we recommend using - * the Bing Entity Search API by querying for the recognized entities names. - * See the Supported - * languages in Text Analytics API for the list of enabled languages. + * Scores close to 1 indicate positive sentiment, while scores close to 0 + * indicate negative sentiment. A score of 0.5 indicates the lack of sentiment + * (e.g. a factoid statement). See the Text + * Analytics Documentation for details about the languages that are + * supported by sentiment analysis. * - * @param {object} input Collection of documents to analyze. + * @param {object} [options] Optional Parameters. * - * @param {array} [input.documents] + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {object} [options] Optional Parameters. + * @param {object} [options.multiLanguageBatchInput] Collection of documents to + * analyze. + * + * @param {array} [options.multiLanguageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - entitiesWithHttpOperationResponse(input, options) { + sentimentWithHttpOperationResponse(options) { let client = this; let self = this; return new Promise((resolve, reject) => { - self._entities(input, options, (err, result, request, response) => { + self._sentiment(options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -968,19 +1059,24 @@ class TextAnalyticsClient extends ServiceClient { } /** - * @summary The API returns a list of recognized entities in a given document. + * @summary The API returns a numeric score between 0 and 1. * - * To get even more information on each recognized entity we recommend using - * the Bing Entity Search API by querying for the recognized entities names. - * See the Supported - * languages in Text Analytics API for the list of enabled languages. + * Scores close to 1 indicate positive sentiment, while scores close to 0 + * indicate negative sentiment. A score of 0.5 indicates the lack of sentiment + * (e.g. a factoid statement). See the Text + * Analytics Documentation for details about the languages that are + * supported by sentiment analysis. * - * @param {object} input Collection of documents to analyze. + * @param {object} [options] Optional Parameters. * - * @param {array} [input.documents] + * @param {boolean} [options.showStats] (optional) if set to true, response + * will contain input and document level statistics. * - * @param {object} [options] Optional Parameters. + * @param {object} [options.multiLanguageBatchInput] Collection of documents to + * analyze. + * + * @param {array} [options.multiLanguageBatchInput.documents] * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -992,7 +1088,7 @@ class TextAnalyticsClient extends ServiceClient { * * {Promise} A promise is returned * - * @resolve {EntitiesBatchResult} - The deserialized result object. + * @resolve {Object} - The deserialized result object. * * @reject {Error} - The error object. * @@ -1001,13 +1097,12 @@ class TextAnalyticsClient extends ServiceClient { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link EntitiesBatchResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - entities(input, options, optionalCallback) { + sentiment(options, optionalCallback) { let client = this; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1016,14 +1111,14 @@ class TextAnalyticsClient extends ServiceClient { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._entities(input, options, (err, result, request, response) => { + self._sentiment(options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._entities(input, options, optionalCallback); + return self._sentiment(options, optionalCallback); } } diff --git a/lib/services/cognitiveServicesTextAnalytics/package.json b/lib/services/cognitiveServicesTextAnalytics/package.json index a7cb9b7569..b5d6cde836 100644 --- a/lib/services/cognitiveServicesTextAnalytics/package.json +++ b/lib/services/cognitiveServicesTextAnalytics/package.json @@ -21,4 +21,4 @@ "bugs": { "url": "https://github.com/azure/azure-sdk-for-node/issues" } -} \ No newline at end of file +}