diff --git a/lib/services/textAnalytics/LICENSE.txt b/lib/services/textAnalytics/LICENSE.txt
index a70e8cf660..5431ba98b9 100644
--- a/lib/services/textAnalytics/LICENSE.txt
+++ b/lib/services/textAnalytics/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) 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.
diff --git a/lib/services/textAnalytics/lib/models/entitiesBatchResult.js b/lib/services/textAnalytics/lib/models/entitiesBatchResult.js
new file mode 100644
index 0000000000..9083c8028a
--- /dev/null
+++ b/lib/services/textAnalytics/lib/models/entitiesBatchResult.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';
+
+const models = require('./index');
+
+/**
+ * Class representing a EntitiesBatchResult.
+ */
+class EntitiesBatchResult {
+ /**
+ * Create a EntitiesBatchResult.
+ * @member {array} [documents]
+ * @member {array} [errors]
+ */
+ constructor() {
+ }
+
+ /**
+ * Defines the metadata of EntitiesBatchResult
+ *
+ * @returns {object} metadata of EntitiesBatchResult
+ *
+ */
+ mapper() {
+ return {
+ required: false,
+ serializedName: 'EntitiesBatchResult',
+ type: {
+ name: 'Composite',
+ className: 'EntitiesBatchResult',
+ modelProperties: {
+ documents: {
+ required: false,
+ readOnly: true,
+ serializedName: 'documents',
+ type: {
+ name: 'Sequence',
+ element: {
+ required: false,
+ serializedName: 'EntitiesBatchResultItemElementType',
+ type: {
+ name: 'Composite',
+ className: 'EntitiesBatchResultItem'
+ }
+ }
+ }
+ },
+ errors: {
+ required: false,
+ readOnly: true,
+ serializedName: 'errors',
+ type: {
+ name: 'Sequence',
+ element: {
+ required: false,
+ serializedName: 'ErrorRecordElementType',
+ type: {
+ name: 'Composite',
+ className: 'ErrorRecord'
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+ }
+}
+
+module.exports = EntitiesBatchResult;
diff --git a/lib/services/textAnalytics/lib/models/entitiesBatchResultItem.js b/lib/services/textAnalytics/lib/models/entitiesBatchResultItem.js
new file mode 100644
index 0000000000..eca4fb9129
--- /dev/null
+++ b/lib/services/textAnalytics/lib/models/entitiesBatchResultItem.js
@@ -0,0 +1,71 @@
+/*
+ * 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';
+
+const models = require('./index');
+
+/**
+ * Class representing a EntitiesBatchResultItem.
+ */
+class EntitiesBatchResultItem {
+ /**
+ * Create a EntitiesBatchResultItem.
+ * @member {string} [id] Unique document identifier.
+ * @member {array} [entities] Recognized entities in the document.
+ */
+ constructor() {
+ }
+
+ /**
+ * Defines the metadata of EntitiesBatchResultItem
+ *
+ * @returns {object} metadata of EntitiesBatchResultItem
+ *
+ */
+ mapper() {
+ return {
+ required: false,
+ serializedName: 'EntitiesBatchResultItem',
+ type: {
+ name: 'Composite',
+ className: 'EntitiesBatchResultItem',
+ modelProperties: {
+ id: {
+ required: false,
+ readOnly: true,
+ serializedName: 'id',
+ type: {
+ name: 'String'
+ }
+ },
+ entities: {
+ required: false,
+ readOnly: true,
+ serializedName: 'entities',
+ type: {
+ name: 'Sequence',
+ element: {
+ required: false,
+ serializedName: 'EntityRecordElementType',
+ type: {
+ name: 'Composite',
+ className: 'EntityRecord'
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+ }
+}
+
+module.exports = EntitiesBatchResultItem;
diff --git a/lib/services/textAnalytics/lib/models/entityRecord.js b/lib/services/textAnalytics/lib/models/entityRecord.js
new file mode 100644
index 0000000000..3401e5f86b
--- /dev/null
+++ b/lib/services/textAnalytics/lib/models/entityRecord.js
@@ -0,0 +1,109 @@
+/*
+ * 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';
+
+const models = require('./index');
+
+/**
+ * Class representing a EntityRecord.
+ */
+class EntityRecord {
+ /**
+ * Create a EntityRecord.
+ * @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.
+ */
+ constructor() {
+ }
+
+ /**
+ * Defines the metadata of EntityRecord
+ *
+ * @returns {object} metadata of EntityRecord
+ *
+ */
+ mapper() {
+ return {
+ required: false,
+ serializedName: 'EntityRecord',
+ type: {
+ name: 'Composite',
+ className: 'EntityRecord',
+ modelProperties: {
+ name: {
+ required: false,
+ serializedName: 'name',
+ type: {
+ name: 'String'
+ }
+ },
+ matches: {
+ required: false,
+ readOnly: true,
+ serializedName: 'matches',
+ type: {
+ name: 'Sequence',
+ element: {
+ required: false,
+ serializedName: 'MatchRecordElementType',
+ type: {
+ name: 'Composite',
+ className: 'MatchRecord'
+ }
+ }
+ }
+ },
+ wikipediaLanguage: {
+ required: false,
+ serializedName: 'wikipediaLanguage',
+ type: {
+ name: 'String'
+ }
+ },
+ wikipediaId: {
+ required: false,
+ serializedName: 'wikipediaId',
+ type: {
+ name: 'String'
+ }
+ },
+ wikipediaUrl: {
+ required: false,
+ readOnly: true,
+ serializedName: 'wikipediaUrl',
+ type: {
+ name: 'String'
+ }
+ },
+ bingId: {
+ required: false,
+ serializedName: 'bingId',
+ type: {
+ name: 'String'
+ }
+ }
+ }
+ }
+ };
+ }
+}
+
+module.exports = EntityRecord;
diff --git a/lib/services/textAnalytics/lib/models/index.d.ts b/lib/services/textAnalytics/lib/models/index.d.ts
index e457c7de0c..456c113be1 100644
--- a/lib/services/textAnalytics/lib/models/index.d.ts
+++ b/lib/services/textAnalytics/lib/models/index.d.ts
@@ -196,3 +196,67 @@ export interface SentimentBatchResult {
readonly documents?: SentimentBatchResultItem[];
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[];
+}
diff --git a/lib/services/textAnalytics/lib/models/index.js b/lib/services/textAnalytics/lib/models/index.js
index bdb6fbd225..13b2ce37c4 100644
--- a/lib/services/textAnalytics/lib/models/index.js
+++ b/lib/services/textAnalytics/lib/models/index.js
@@ -28,3 +28,7 @@ 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/textAnalytics/lib/models/matchRecord.js b/lib/services/textAnalytics/lib/models/matchRecord.js
new file mode 100644
index 0000000000..d6ddc4a6c8
--- /dev/null
+++ b/lib/services/textAnalytics/lib/models/matchRecord.js
@@ -0,0 +1,69 @@
+/*
+ * 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 MatchRecord.
+ */
+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
+ * entity match text.
+ * @member {number} [length] Length (in Unicode characters) for the entity
+ * match text.
+ */
+ constructor() {
+ }
+
+ /**
+ * Defines the metadata of MatchRecord
+ *
+ * @returns {object} metadata of MatchRecord
+ *
+ */
+ mapper() {
+ return {
+ required: false,
+ serializedName: 'MatchRecord',
+ type: {
+ name: 'Composite',
+ className: 'MatchRecord',
+ modelProperties: {
+ text: {
+ required: false,
+ serializedName: 'text',
+ type: {
+ name: 'String'
+ }
+ },
+ offset: {
+ required: false,
+ serializedName: 'offset',
+ type: {
+ name: 'Number'
+ }
+ },
+ length: {
+ required: false,
+ serializedName: 'length',
+ type: {
+ name: 'Number'
+ }
+ }
+ }
+ }
+ };
+ }
+}
+
+module.exports = MatchRecord;
diff --git a/lib/services/textAnalytics/lib/textAnalyticsAPIClient.d.ts b/lib/services/textAnalytics/lib/textAnalyticsAPIClient.d.ts
index 6982bae5da..ca8cf93ec7 100644
--- a/lib/services/textAnalytics/lib/textAnalyticsAPIClient.d.ts
+++ b/lib/services/textAnalytics/lib/textAnalyticsAPIClient.d.ts
@@ -42,8 +42,7 @@ export default class TextAnalyticsAPIClient extends ServiceClient {
* @summary The API returns a list of strings denoting the key talking points
* in the input text.
*
- * We employ techniques from Microsoft Office's sophisticated Natural Language
- * Processing toolkit. See the Text
* Analytics Documentation for details about the languages that are
* supported by key phrase extraction.
@@ -70,8 +69,7 @@ export default class TextAnalyticsAPIClient extends ServiceClient {
* @summary The API returns a list of strings denoting the key talking points
* in the input text.
*
- * We employ techniques from Microsoft Office's sophisticated Natural Language
- * Processing toolkit. See the Text
* Analytics Documentation for details about the languages that are
* supported by key phrase extraction.
@@ -184,10 +182,8 @@ export default class TextAnalyticsAPIClient extends ServiceClient {
* @summary The API returns a numeric score between 0 and 1.
*
* Scores close to 1 indicate positive sentiment, while scores close to 0
- * indicate negative sentiment. Sentiment score is generated using
- * classification techniques. The input features to the classifier include
- * n-grams, features generated from part-of-speech tags, and word embeddings.
- * See the Text
* Analytics Documentation for details about the languages that are
* supported by sentiment analysis.
@@ -213,10 +209,8 @@ export default class TextAnalyticsAPIClient extends ServiceClient {
* @summary The API returns a numeric score between 0 and 1.
*
* Scores close to 1 indicate positive sentiment, while scores close to 0
- * indicate negative sentiment. Sentiment score is generated using
- * classification techniques. The input features to the classifier include
- * n-grams, features generated from part-of-speech tags, and word embeddings.
- * See the Text
* Analytics Documentation for details about the languages that are
* supported by sentiment analysis.
@@ -255,6 +249,77 @@ export default class TextAnalyticsAPIClient extends ServiceClient {
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;
+
+
+ /**
+ * @summary The API returns a list of recognized entities in a given document.
+ *
+ * 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 {array} [input.documents]
+ *
+ * @param {object} [options] Optional Parameters.
+ *
+ * @param {object} [options.customHeaders] Headers that will be added to the
+ * request
+ *
+ * @returns {Promise} A promise is returned
+ *
+ * @resolve {HttpOperationResponse} - The deserialized result object.
+ *
+ * @reject {Error|ServiceError} - The error object.
+ */
+ entitiesWithHttpOperationResponse(input: models.MultiLanguageBatchInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>;
+
+ /**
+ * @summary The API returns a list of recognized entities in a given document.
+ *
+ * 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 {array} [input.documents]
+ *
+ * @param {object} [options] Optional Parameters.
+ *
+ * @param {object} [options.customHeaders] Headers that will be added to the
+ * request
+ *
+ * @param {ServiceCallback} [optionalCallback] - The optional callback.
+ *
+ * @returns {ServiceCallback|Promise} If a callback was passed as the last
+ * parameter then it returns the callback else returns a Promise.
+ *
+ * {Promise} A promise is returned.
+ *
+ * @resolve {EntitiesBatchResult} - The deserialized result object.
+ *
+ * @reject {Error|ServiceError} - The error object.
+ *
+ * {ServiceCallback} optionalCallback(err, result, request, response)
+ *
+ * {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.
+ *
+ * {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;
}
export { TextAnalyticsAPIClient, models as TextAnalyticsAPIModels };
diff --git a/lib/services/textAnalytics/lib/textAnalyticsAPIClient.js b/lib/services/textAnalytics/lib/textAnalyticsAPIClient.js
index 7b8522a134..9baccd6e92 100644
--- a/lib/services/textAnalytics/lib/textAnalyticsAPIClient.js
+++ b/lib/services/textAnalytics/lib/textAnalyticsAPIClient.js
@@ -25,8 +25,7 @@ const models = require('./models');
* @summary The API returns a list of strings denoting the key talking points
* in the input text.
*
- * We employ techniques from Microsoft Office's sophisticated Natural Language
- * Processing toolkit. See the Text
* Analytics Documentation for details about the languages that are
* supported by key phrase extraction.
@@ -325,10 +324,8 @@ function _detectLanguage(input, options, callback) {
* @summary The API returns a numeric score between 0 and 1.
*
* Scores close to 1 indicate positive sentiment, while scores close to 0
- * indicate negative sentiment. Sentiment score is generated using
- * classification techniques. The input features to the classifier include
- * n-grams, features generated from part-of-speech tags, and word embeddings.
- * See the Text
* Analytics Documentation for details about the languages that are
* supported by sentiment analysis.
@@ -474,6 +471,156 @@ function _sentiment(input, options, callback) {
});
}
+/**
+ * @summary The API returns a list of recognized entities in a given document.
+ *
+ * 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 {array} [input.documents]
+ *
+ * @param {object} [options] Optional Parameters.
+ *
+ * @param {object} [options.customHeaders] Headers that will be added to the
+ * request
+ *
+ * @param {function} callback - The callback.
+ *
+ * @returns {function} callback(err, result, request, response)
+ *
+ * {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) {
+ /* jshint validthis: true */
+ let client = this;
+ if(!callback && typeof options === 'function') {
+ callback = options;
+ options = null;
+ }
+ if (!callback) {
+ throw new Error('callback cannot be null.');
+ }
+ // Validate
+ try {
+ if (this.azureRegion) {
+ let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ];
+ let enumValue = this.azureRegion;
+ if (!allowedValues.some( function(item) { return item === enumValue; })) {
+ throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues);
+ }
+ } else {
+ throw new Error('this.azureRegion cannot be null or undefined.');
+ }
+ if (input === null || input === undefined) {
+ throw new Error('input cannot be null or undefined.');
+ }
+ } catch (error) {
+ return callback(error);
+ }
+
+ // Construct URL
+ let baseUrl = this.baseUri;
+ let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v2.0/entities';
+ requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion);
+
+ // Create HTTP transport objects
+ let httpRequest = new WebResource();
+ httpRequest.method = 'POST';
+ httpRequest.url = requestUrl;
+ httpRequest.headers = {};
+ // Set Headers
+ httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
+ if(options) {
+ for(let headerName in options['customHeaders']) {
+ if (options['customHeaders'].hasOwnProperty(headerName)) {
+ httpRequest.headers[headerName] = options['customHeaders'][headerName];
+ }
+ }
+ }
+ // Serialize Request
+ 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');
+ requestContent = JSON.stringify(requestModel);
+ }
+ } catch (error) {
+ let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
+ `payload - ${JSON.stringify(input, null, 2)}.`);
+ return callback(serializationError);
+ }
+ httpRequest.body = requestContent;
+ // Send Request
+ return client.pipeline(httpRequest, (err, response, responseBody) => {
+ if (err) {
+ return callback(err);
+ }
+ let statusCode = response.statusCode;
+ if (statusCode !== 200) {
+ let error = new Error(responseBody);
+ error.statusCode = response.statusCode;
+ error.request = msRest.stripRequest(httpRequest);
+ error.response = msRest.stripResponse(response);
+ if (responseBody === '') responseBody = null;
+ let parsedErrorResponse;
+ try {
+ parsedErrorResponse = JSON.parse(responseBody);
+ if (parsedErrorResponse) {
+ let internalError = null;
+ if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
+ 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.`;
+ return callback(error);
+ }
+ return callback(error);
+ }
+ // Create Result
+ let result = null;
+ if (responseBody === '') responseBody = null;
+ // Deserialize Response
+ if (statusCode === 200) {
+ let parsedResponse = null;
+ try {
+ parsedResponse = JSON.parse(responseBody);
+ result = JSON.parse(responseBody);
+ if (parsedResponse !== null && parsedResponse !== undefined) {
+ let resultMapper = new client.models['EntitiesBatchResult']().mapper();
+ result = client.deserialize(resultMapper, parsedResponse, 'result');
+ }
+ } catch (error) {
+ let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
+ deserializationError.request = msRest.stripRequest(httpRequest);
+ deserializationError.response = msRest.stripResponse(response);
+ return callback(deserializationError);
+ }
+ }
+
+ return callback(null, result, httpRequest, response);
+ });
+}
+
/** Class representing a TextAnalyticsAPIClient. */
class TextAnalyticsAPIClient extends ServiceClient {
/**
@@ -508,6 +655,7 @@ class TextAnalyticsAPIClient extends ServiceClient {
this._keyPhrases = _keyPhrases;
this._detectLanguage = _detectLanguage;
this._sentiment = _sentiment;
+ this._entities = _entities;
msRest.addSerializationMixin(this);
}
@@ -515,8 +663,7 @@ class TextAnalyticsAPIClient extends ServiceClient {
* @summary The API returns a list of strings denoting the key talking points
* in the input text.
*
- * We employ techniques from Microsoft Office's sophisticated Natural Language
- * Processing toolkit. See the Text
* Analytics Documentation for details about the languages that are
* supported by key phrase extraction.
@@ -555,8 +702,7 @@ class TextAnalyticsAPIClient extends ServiceClient {
* @summary The API returns a list of strings denoting the key talking points
* in the input text.
*
- * We employ techniques from Microsoft Office's sophisticated Natural Language
- * Processing toolkit. See the Text
* Analytics Documentation for details about the languages that are
* supported by key phrase extraction.
@@ -711,10 +857,8 @@ class TextAnalyticsAPIClient extends ServiceClient {
* @summary The API returns a numeric score between 0 and 1.
*
* Scores close to 1 indicate positive sentiment, while scores close to 0
- * indicate negative sentiment. Sentiment score is generated using
- * classification techniques. The input features to the classifier include
- * n-grams, features generated from part-of-speech tags, and word embeddings.
- * See the Text
* Analytics Documentation for details about the languages that are
* supported by sentiment analysis.
@@ -752,10 +896,8 @@ class TextAnalyticsAPIClient extends ServiceClient {
* @summary The API returns a numeric score between 0 and 1.
*
* Scores close to 1 indicate positive sentiment, while scores close to 0
- * indicate negative sentiment. Sentiment score is generated using
- * classification techniques. The input features to the classifier include
- * n-grams, features generated from part-of-speech tags, and word embeddings.
- * See the Text
* Analytics Documentation for details about the languages that are
* supported by sentiment analysis.
@@ -811,6 +953,104 @@ class TextAnalyticsAPIClient extends ServiceClient {
}
}
+ /**
+ * @summary The API returns a list of recognized entities in a given document.
+ *
+ * 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 {array} [input.documents]
+ *
+ * @param {object} [options] Optional Parameters.
+ *
+ * @param {object} [options.customHeaders] Headers that will be added to the
+ * request
+ *
+ * @returns {Promise} A promise is returned
+ *
+ * @resolve {HttpOperationResponse} - The deserialized result object.
+ *
+ * @reject {Error} - The error object.
+ */
+ entitiesWithHttpOperationResponse(input, options) {
+ let client = this;
+ let self = this;
+ return new Promise((resolve, reject) => {
+ self._entities(input, options, (err, result, request, response) => {
+ let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
+ httpOperationResponse.body = result;
+ if (err) { reject(err); }
+ else { resolve(httpOperationResponse); }
+ return;
+ });
+ });
+ }
+
+ /**
+ * @summary The API returns a list of recognized entities in a given document.
+ *
+ * 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 {array} [input.documents]
+ *
+ * @param {object} [options] Optional Parameters.
+ *
+ * @param {object} [options.customHeaders] Headers that will be added to the
+ * request
+ *
+ * @param {function} [optionalCallback] - The optional callback.
+ *
+ * @returns {function|Promise} If a callback was passed as the last parameter
+ * then it returns the callback else returns a Promise.
+ *
+ * {Promise} A promise is returned
+ *
+ * @resolve {EntitiesBatchResult} - The deserialized result object.
+ *
+ * @reject {Error} - The error object.
+ *
+ * {function} optionalCallback(err, result, request, response)
+ *
+ * {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) {
+ let client = this;
+ let self = this;
+ if (!optionalCallback && typeof options === 'function') {
+ optionalCallback = options;
+ options = null;
+ }
+ if (!optionalCallback) {
+ return new Promise((resolve, reject) => {
+ self._entities(input, options, (err, result, request, response) => {
+ if (err) { reject(err); }
+ else { resolve(result); }
+ return;
+ });
+ });
+ } else {
+ return self._entities(input, options, optionalCallback);
+ }
+ }
+
}
module.exports = TextAnalyticsAPIClient;
diff --git a/lib/services/textAnalytics/package.json b/lib/services/textAnalytics/package.json
index 76c3f71a10..a37d5a32de 100644
--- a/lib/services/textAnalytics/package.json
+++ b/lib/services/textAnalytics/package.json
@@ -4,12 +4,9 @@
"description": "TextAnalyticsAPIClient Library with typescript type definitions for node",
"version": "1.0.0",
"dependencies": {
- "ms-rest": "^2.3.3"
+ "ms-rest": "^2.3.2"
},
- "keywords": [
- "node",
- "azure"
- ],
+ "keywords": [ "node", "azure" ],
"license": "MIT",
"main": "./lib/textAnalyticsAPIClient.js",
"types": "./lib/textAnalyticsAPIClient.d.ts",