ibm-watson
Version:
Client library to use the IBM Watson Services
992 lines • 63.3 kB
TypeScript
/**
* (C) Copyright IBM Corp. 2017, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// <reference types="node" />
/// <reference types="node" />
import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
import { BaseService, UserOptions } from 'ibm-cloud-sdk-core';
/**
* Analyze various features of text content at scale. Provide text, raw HTML, or a public URL and IBM Watson Natural
* Language Understanding will give you results for the features you request. The service cleans HTML content before
* analysis by default, so the results can ignore most advertisements and other unwanted content.
*
* You can create [custom
* models](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing)
* with Watson Knowledge Studio to detect custom entities and relations in Natural Language Understanding.
*
* API Version: 1.0
* See: https://cloud.ibm.com/docs/natural-language-understanding
*/
declare class NaturalLanguageUnderstandingV1 extends BaseService {
static DEFAULT_SERVICE_URL: string;
static DEFAULT_SERVICE_NAME: string;
/** Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is
* `2022-04-07`.
*/
version: string;
/**
* Construct a NaturalLanguageUnderstandingV1 object.
*
* @param {Object} options - Options for the service.
* @param {string} options.version - Release date of the API version you want to use. Specify dates in YYYY-MM-DD
* format. The current version is `2022-04-07`.
* @param {string} [options.serviceUrl] - The base URL for the service
* @param {OutgoingHttpHeaders} [options.headers] - Default headers that shall be included with every request to the service.
* @param {string} [options.serviceName] - The name of the service to configure
* @param {Authenticator} [options.authenticator] - The Authenticator object used to authenticate requests to the service. Defaults to environment if not set
* @constructor
* @returns {NaturalLanguageUnderstandingV1}
*/
constructor(options: UserOptions);
/*************************
* analyze
************************/
/**
* Analyze text.
*
* Analyzes text, HTML, or a public webpage for the following features:
* - Categories
* - Classifications
* - Concepts
* - Emotion
* - Entities
* - Keywords
* - Metadata
* - Relations
* - Semantic roles
* - Sentiment
* - Syntax
*
* If a language for the input text is not specified with the `language` parameter, the service [automatically detects
* the
* language](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-detectable-languages).
*
* @param {Object} params - The parameters to send to the service.
* @param {Features} params.features - Specific features to analyze the document for.
* @param {string} [params.text] - The plain text to analyze. One of the `text`, `html`, or `url` parameters is
* required.
* @param {string} [params.html] - The HTML file to analyze. One of the `text`, `html`, or `url` parameters is
* required.
* @param {string} [params.url] - The webpage to analyze. One of the `text`, `html`, or `url` parameters is required.
* @param {boolean} [params.clean] - Set this to `false` to disable webpage cleaning. For more information about
* webpage cleaning, see [Analyzing
* webpages](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages).
* @param {string} [params.xpath] - An [XPath
* query](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages#xpath)
* to perform on `html` or `url` input. Results of the query will be appended to the cleaned webpage text before it is
* analyzed. To analyze only the results of the XPath query, set the `clean` parameter to `false`.
* @param {boolean} [params.fallbackToRaw] - Whether to use raw HTML content if text cleaning fails.
* @param {boolean} [params.returnAnalyzedText] - Whether or not to return the analyzed text.
* @param {string} [params.language] - ISO 639-1 code that specifies the language of your text. This overrides
* automatic language detection. Language support differs depending on the features you include in your analysis. For
* more information, see [Language
* support](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-language-support).
* @param {number} [params.limitTextCharacters] - Sets the maximum number of characters that are processed by the
* service.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.AnalysisResults>>}
*/
analyze(params: NaturalLanguageUnderstandingV1.AnalyzeParams): Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.AnalysisResults>>;
/*************************
* manageModels
************************/
/**
* List models.
*
* Lists Watson Knowledge Studio [custom entities and relations
* models](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing)
* that are deployed to your Natural Language Understanding service.
*
* @param {Object} [params] - The parameters to send to the service.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.ListModelsResults>>}
*/
listModels(params?: NaturalLanguageUnderstandingV1.ListModelsParams): Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.ListModelsResults>>;
/**
* Delete model.
*
* Deletes a custom model.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.modelId - Model ID of the model to delete.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.DeleteModelResults>>}
*/
deleteModel(params: NaturalLanguageUnderstandingV1.DeleteModelParams): Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.DeleteModelResults>>;
/*************************
* manageCategoriesModels
************************/
/**
* Create categories model.
*
* (Beta) Creates a custom categories model by uploading training data and associated metadata. The model begins the
* training and deploying process and is ready to use when the `status` is `available`.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.language - The 2-letter language code of this model.
* @param {NodeJS.ReadableStream | Buffer} params.trainingData - Training data in JSON format. For more information,
* see [Categories training data
* requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-categories##categories-training-data-requirements).
* @param {string} [params.trainingDataContentType] - The content type of trainingData.
* @param {string} [params.name] - An optional name for the model.
* @param {JsonObject} [params.userMetadata] - An optional map of metadata key-value pairs to store with this model.
* @param {string} [params.description] - An optional description of the model.
* @param {string} [params.modelVersion] - An optional version string.
* @param {string} [params.workspaceId] - ID of the Watson Knowledge Studio workspace that deployed this model to
* Natural Language Understanding.
* @param {string} [params.versionDescription] - The description of the version.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.CategoriesModel>>}
*/
createCategoriesModel(params: NaturalLanguageUnderstandingV1.CreateCategoriesModelParams): Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.CategoriesModel>>;
/**
* List categories models.
*
* (Beta) Returns all custom categories models associated with this service instance.
*
* @param {Object} [params] - The parameters to send to the service.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.CategoriesModelList>>}
*/
listCategoriesModels(params?: NaturalLanguageUnderstandingV1.ListCategoriesModelsParams): Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.CategoriesModelList>>;
/**
* Get categories model details.
*
* (Beta) Returns the status of the categories model with the given model ID.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.modelId - ID of the model.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.CategoriesModel>>}
*/
getCategoriesModel(params: NaturalLanguageUnderstandingV1.GetCategoriesModelParams): Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.CategoriesModel>>;
/**
* Update categories model.
*
* (Beta) Overwrites the training data associated with this custom categories model and retrains the model. The new
* model replaces the current deployment.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.modelId - ID of the model.
* @param {string} params.language - The 2-letter language code of this model.
* @param {NodeJS.ReadableStream | Buffer} params.trainingData - Training data in JSON format. For more information,
* see [Categories training data
* requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-categories##categories-training-data-requirements).
* @param {string} [params.trainingDataContentType] - The content type of trainingData.
* @param {string} [params.name] - An optional name for the model.
* @param {JsonObject} [params.userMetadata] - An optional map of metadata key-value pairs to store with this model.
* @param {string} [params.description] - An optional description of the model.
* @param {string} [params.modelVersion] - An optional version string.
* @param {string} [params.workspaceId] - ID of the Watson Knowledge Studio workspace that deployed this model to
* Natural Language Understanding.
* @param {string} [params.versionDescription] - The description of the version.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.CategoriesModel>>}
*/
updateCategoriesModel(params: NaturalLanguageUnderstandingV1.UpdateCategoriesModelParams): Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.CategoriesModel>>;
/**
* Delete categories model.
*
* (Beta) Un-deploys the custom categories model with the given model ID and deletes all associated customer data,
* including any training data or binary artifacts.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.modelId - ID of the model.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.DeleteModelResults>>}
*/
deleteCategoriesModel(params: NaturalLanguageUnderstandingV1.DeleteCategoriesModelParams): Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.DeleteModelResults>>;
/*************************
* manageClassificationsModels
************************/
/**
* Create classifications model.
*
* Creates a custom classifications model by uploading training data and associated metadata. The model begins the
* training and deploying process and is ready to use when the `status` is `available`.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.language - The 2-letter language code of this model.
* @param {NodeJS.ReadableStream | Buffer} params.trainingData - Training data in JSON format. For more information,
* see [Classifications training data
* requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-classifications#classification-training-data-requirements).
* @param {string} [params.trainingDataContentType] - The content type of trainingData.
* @param {string} [params.name] - An optional name for the model.
* @param {JsonObject} [params.userMetadata] - An optional map of metadata key-value pairs to store with this model.
* @param {string} [params.description] - An optional description of the model.
* @param {string} [params.modelVersion] - An optional version string.
* @param {string} [params.workspaceId] - ID of the Watson Knowledge Studio workspace that deployed this model to
* Natural Language Understanding.
* @param {string} [params.versionDescription] - The description of the version.
* @param {ClassificationsTrainingParameters} [params.trainingParameters] - Optional classifications training
* parameters along with model train requests.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.ClassificationsModel>>}
*/
createClassificationsModel(params: NaturalLanguageUnderstandingV1.CreateClassificationsModelParams): Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.ClassificationsModel>>;
/**
* List classifications models.
*
* Returns all custom classifications models associated with this service instance.
*
* @param {Object} [params] - The parameters to send to the service.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.ClassificationsModelList>>}
*/
listClassificationsModels(params?: NaturalLanguageUnderstandingV1.ListClassificationsModelsParams): Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.ClassificationsModelList>>;
/**
* Get classifications model details.
*
* Returns the status of the classifications model with the given model ID.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.modelId - ID of the model.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.ClassificationsModel>>}
*/
getClassificationsModel(params: NaturalLanguageUnderstandingV1.GetClassificationsModelParams): Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.ClassificationsModel>>;
/**
* Update classifications model.
*
* Overwrites the training data associated with this custom classifications model and retrains the model. The new
* model replaces the current deployment.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.modelId - ID of the model.
* @param {string} params.language - The 2-letter language code of this model.
* @param {NodeJS.ReadableStream | Buffer} params.trainingData - Training data in JSON format. For more information,
* see [Classifications training data
* requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-classifications#classification-training-data-requirements).
* @param {string} [params.trainingDataContentType] - The content type of trainingData.
* @param {string} [params.name] - An optional name for the model.
* @param {JsonObject} [params.userMetadata] - An optional map of metadata key-value pairs to store with this model.
* @param {string} [params.description] - An optional description of the model.
* @param {string} [params.modelVersion] - An optional version string.
* @param {string} [params.workspaceId] - ID of the Watson Knowledge Studio workspace that deployed this model to
* Natural Language Understanding.
* @param {string} [params.versionDescription] - The description of the version.
* @param {ClassificationsTrainingParameters} [params.trainingParameters] - Optional classifications training
* parameters along with model train requests.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.ClassificationsModel>>}
*/
updateClassificationsModel(params: NaturalLanguageUnderstandingV1.UpdateClassificationsModelParams): Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.ClassificationsModel>>;
/**
* Delete classifications model.
*
* Un-deploys the custom classifications model with the given model ID and deletes all associated customer data,
* including any training data or binary artifacts.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.modelId - ID of the model.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.DeleteModelResults>>}
*/
deleteClassificationsModel(params: NaturalLanguageUnderstandingV1.DeleteClassificationsModelParams): Promise<NaturalLanguageUnderstandingV1.Response<NaturalLanguageUnderstandingV1.DeleteModelResults>>;
}
/*************************
* interfaces
************************/
declare namespace NaturalLanguageUnderstandingV1 {
/** Options for the `NaturalLanguageUnderstandingV1` constructor. */
interface Options extends UserOptions {
/** Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is
* `2022-04-07`.
*/
version: string;
}
/** An operation response. */
interface Response<T = any> {
result: T;
status: number;
statusText: string;
headers: IncomingHttpHeaders;
}
/** The callback for a service request. */
type Callback<T> = (error: any, response?: Response<T>) => void;
/** The body of a service request that returns no response data. */
interface EmptyObject {
}
/** A standard JS object, defined to avoid the limitations of `Object` and `object` */
interface JsonObject {
[key: string]: any;
}
/*************************
* request interfaces
************************/
/** Parameters for the `analyze` operation. */
interface AnalyzeParams {
/** Specific features to analyze the document for. */
features: Features;
/** The plain text to analyze. One of the `text`, `html`, or `url` parameters is required. */
text?: string;
/** The HTML file to analyze. One of the `text`, `html`, or `url` parameters is required. */
html?: string;
/** The webpage to analyze. One of the `text`, `html`, or `url` parameters is required. */
url?: string;
/** Set this to `false` to disable webpage cleaning. For more information about webpage cleaning, see [Analyzing
* webpages](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages).
*/
clean?: boolean;
/** An [XPath
* query](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages#xpath)
* to perform on `html` or `url` input. Results of the query will be appended to the cleaned webpage text before it
* is analyzed. To analyze only the results of the XPath query, set the `clean` parameter to `false`.
*/
xpath?: string;
/** Whether to use raw HTML content if text cleaning fails. */
fallbackToRaw?: boolean;
/** Whether or not to return the analyzed text. */
returnAnalyzedText?: boolean;
/** ISO 639-1 code that specifies the language of your text. This overrides automatic language detection.
* Language support differs depending on the features you include in your analysis. For more information, see
* [Language
* support](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-language-support).
*/
language?: string;
/** Sets the maximum number of characters that are processed by the service. */
limitTextCharacters?: number;
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `listModels` operation. */
interface ListModelsParams {
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `deleteModel` operation. */
interface DeleteModelParams {
/** Model ID of the model to delete. */
modelId: string;
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `createCategoriesModel` operation. */
interface CreateCategoriesModelParams {
/** The 2-letter language code of this model. */
language: string;
/** Training data in JSON format. For more information, see [Categories training data
* requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-categories##categories-training-data-requirements).
*/
trainingData: NodeJS.ReadableStream | Buffer;
/** The content type of trainingData. */
trainingDataContentType?: CreateCategoriesModelConstants.TrainingDataContentType | string;
/** An optional name for the model. */
name?: string;
/** An optional map of metadata key-value pairs to store with this model. */
userMetadata?: JsonObject;
/** An optional description of the model. */
description?: string;
/** An optional version string. */
modelVersion?: string;
/** ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language Understanding. */
workspaceId?: string;
/** The description of the version. */
versionDescription?: string;
headers?: OutgoingHttpHeaders;
}
/** Constants for the `createCategoriesModel` operation. */
namespace CreateCategoriesModelConstants {
/** The content type of trainingData. */
enum TrainingDataContentType {
JSON = "json",
APPLICATION_JSON = "application/json"
}
}
/** Parameters for the `listCategoriesModels` operation. */
interface ListCategoriesModelsParams {
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `getCategoriesModel` operation. */
interface GetCategoriesModelParams {
/** ID of the model. */
modelId: string;
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `updateCategoriesModel` operation. */
interface UpdateCategoriesModelParams {
/** ID of the model. */
modelId: string;
/** The 2-letter language code of this model. */
language: string;
/** Training data in JSON format. For more information, see [Categories training data
* requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-categories##categories-training-data-requirements).
*/
trainingData: NodeJS.ReadableStream | Buffer;
/** The content type of trainingData. */
trainingDataContentType?: UpdateCategoriesModelConstants.TrainingDataContentType | string;
/** An optional name for the model. */
name?: string;
/** An optional map of metadata key-value pairs to store with this model. */
userMetadata?: JsonObject;
/** An optional description of the model. */
description?: string;
/** An optional version string. */
modelVersion?: string;
/** ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language Understanding. */
workspaceId?: string;
/** The description of the version. */
versionDescription?: string;
headers?: OutgoingHttpHeaders;
}
/** Constants for the `updateCategoriesModel` operation. */
namespace UpdateCategoriesModelConstants {
/** The content type of trainingData. */
enum TrainingDataContentType {
JSON = "json",
APPLICATION_JSON = "application/json"
}
}
/** Parameters for the `deleteCategoriesModel` operation. */
interface DeleteCategoriesModelParams {
/** ID of the model. */
modelId: string;
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `createClassificationsModel` operation. */
interface CreateClassificationsModelParams {
/** The 2-letter language code of this model. */
language: string;
/** Training data in JSON format. For more information, see [Classifications training data
* requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-classifications#classification-training-data-requirements).
*/
trainingData: NodeJS.ReadableStream | Buffer;
/** The content type of trainingData. */
trainingDataContentType?: CreateClassificationsModelConstants.TrainingDataContentType | string;
/** An optional name for the model. */
name?: string;
/** An optional map of metadata key-value pairs to store with this model. */
userMetadata?: JsonObject;
/** An optional description of the model. */
description?: string;
/** An optional version string. */
modelVersion?: string;
/** ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language Understanding. */
workspaceId?: string;
/** The description of the version. */
versionDescription?: string;
/** Optional classifications training parameters along with model train requests. */
trainingParameters?: ClassificationsTrainingParameters;
headers?: OutgoingHttpHeaders;
}
/** Constants for the `createClassificationsModel` operation. */
namespace CreateClassificationsModelConstants {
/** The content type of trainingData. */
enum TrainingDataContentType {
JSON = "json",
APPLICATION_JSON = "application/json"
}
}
/** Parameters for the `listClassificationsModels` operation. */
interface ListClassificationsModelsParams {
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `getClassificationsModel` operation. */
interface GetClassificationsModelParams {
/** ID of the model. */
modelId: string;
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `updateClassificationsModel` operation. */
interface UpdateClassificationsModelParams {
/** ID of the model. */
modelId: string;
/** The 2-letter language code of this model. */
language: string;
/** Training data in JSON format. For more information, see [Classifications training data
* requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-classifications#classification-training-data-requirements).
*/
trainingData: NodeJS.ReadableStream | Buffer;
/** The content type of trainingData. */
trainingDataContentType?: UpdateClassificationsModelConstants.TrainingDataContentType | string;
/** An optional name for the model. */
name?: string;
/** An optional map of metadata key-value pairs to store with this model. */
userMetadata?: JsonObject;
/** An optional description of the model. */
description?: string;
/** An optional version string. */
modelVersion?: string;
/** ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language Understanding. */
workspaceId?: string;
/** The description of the version. */
versionDescription?: string;
/** Optional classifications training parameters along with model train requests. */
trainingParameters?: ClassificationsTrainingParameters;
headers?: OutgoingHttpHeaders;
}
/** Constants for the `updateClassificationsModel` operation. */
namespace UpdateClassificationsModelConstants {
/** The content type of trainingData. */
enum TrainingDataContentType {
JSON = "json",
APPLICATION_JSON = "application/json"
}
}
/** Parameters for the `deleteClassificationsModel` operation. */
interface DeleteClassificationsModelParams {
/** ID of the model. */
modelId: string;
headers?: OutgoingHttpHeaders;
}
/*************************
* model interfaces
************************/
/**
* Results of the analysis, organized by feature.
*/
interface AnalysisResults {
/** Language used to analyze the text. */
language?: string;
/** Text that was used in the analysis. */
analyzed_text?: string;
/** URL of the webpage that was analyzed. */
retrieved_url?: string;
/** API usage information for the request. */
usage?: AnalysisResultsUsage;
/** The general concepts referenced or alluded to in the analyzed text. */
concepts?: ConceptsResult[];
/** The entities detected in the analyzed text. */
entities?: EntitiesResult[];
/** The keywords from the analyzed text. */
keywords?: KeywordsResult[];
/** The categories that the service assigned to the analyzed text. */
categories?: CategoriesResult[];
/** The classifications assigned to the analyzed text. */
classifications?: ClassificationsResult[];
/** The anger, disgust, fear, joy, or sadness conveyed by the content. */
emotion?: EmotionResult;
/** Webpage metadata, such as the author and the title of the page. */
metadata?: FeaturesResultsMetadata;
/** The relationships between entities in the content. */
relations?: RelationsResult[];
/** Sentences parsed into `subject`, `action`, and `object` form. */
semantic_roles?: SemanticRolesResult[];
/** The sentiment of the content. */
sentiment?: SentimentResult;
/** Tokens and sentences returned from syntax analysis. */
syntax?: SyntaxResult;
}
/**
* API usage information for the request.
*/
interface AnalysisResultsUsage {
/** Number of features used in the API call. */
features?: number;
/** Number of text characters processed. */
text_characters?: number;
/** Number of 10,000-character units processed. */
text_units?: number;
}
/**
* The author of the analyzed content.
*/
interface Author {
/** Name of the author. */
name?: string;
}
/**
* Categories model.
*/
interface CategoriesModel {
/** An optional name for the model. */
name?: string;
/** An optional map of metadata key-value pairs to store with this model. */
user_metadata?: JsonObject;
/** The 2-letter language code of this model. */
language: string;
/** An optional description of the model. */
description?: string;
/** An optional version string. */
model_version?: string;
/** ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language Understanding. */
workspace_id?: string;
/** The description of the version. */
version_description?: string;
/** The service features that are supported by the custom model. */
features?: string[];
/** When the status is `available`, the model is ready to use. */
status: CategoriesModel.Constants.Status | string;
/** Unique model ID. */
model_id: string;
/** dateTime indicating when the model was created. */
created: string;
notices?: Notice[];
/** dateTime of last successful model training. */
last_trained?: string;
/** dateTime of last successful model deployment. */
last_deployed?: string;
}
namespace CategoriesModel {
namespace Constants {
/** When the status is `available`, the model is ready to use. */
enum Status {
STARTING = "starting",
TRAINING = "training",
DEPLOYING = "deploying",
AVAILABLE = "available",
ERROR = "error",
DELETED = "deleted"
}
}
}
/**
* List of categories models.
*/
interface CategoriesModelList {
/** The categories models. */
models?: CategoriesModel[];
}
/**
* Returns a hierarchical taxonomy of the content. The top three categories are returned by default.
*
* Supported languages: Arabic, English, French, German, Italian, Japanese, Korean, Portuguese, Spanish.
*/
interface CategoriesOptions {
/** Set this to `true` to return explanations for each categorization. **This is available only for English
* categories.**.
*/
explanation?: boolean;
/** Maximum number of categories to return. */
limit?: number;
/** (Beta) Enter a [custom
* model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing)
* ID to override the standard categories model. **This is available only for English categories.**.
*/
model?: string;
}
/**
* Relevant text that contributed to the categorization.
*/
interface CategoriesRelevantText {
/** Text from the analyzed source that supports the categorization. */
text?: string;
}
/**
* A categorization of the analyzed text.
*/
interface CategoriesResult {
/** The path to the category through the multi-level taxonomy hierarchy. For more information about the
* categories, see [Categories
* hierarchy](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-categories#categories-hierarchy).
*/
label?: string;
/** Confidence score for the category classification. Higher values indicate greater confidence. */
score?: number;
/** Information that helps to explain what contributed to the categories result. */
explanation?: CategoriesResultExplanation;
}
/**
* Information that helps to explain what contributed to the categories result.
*/
interface CategoriesResultExplanation {
/** An array of relevant text from the source that contributed to the categorization. The sorted array begins
* with the phrase that contributed most significantly to the result, followed by phrases that were less and less
* impactful.
*/
relevant_text?: CategoriesRelevantText[];
}
/**
* Classifications model.
*/
interface ClassificationsModel {
/** An optional name for the model. */
name?: string;
/** An optional map of metadata key-value pairs to store with this model. */
user_metadata?: JsonObject;
/** The 2-letter language code of this model. */
language: string;
/** An optional description of the model. */
description?: string;
/** An optional version string. */
model_version?: string;
/** ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language Understanding. */
workspace_id?: string;
/** The description of the version. */
version_description?: string;
/** The service features that are supported by the custom model. */
features?: string[];
/** When the status is `available`, the model is ready to use. */
status: ClassificationsModel.Constants.Status | string;
/** Unique model ID. */
model_id: string;
/** dateTime indicating when the model was created. */
created: string;
notices?: Notice[];
/** dateTime of last successful model training. */
last_trained?: string;
/** dateTime of last successful model deployment. */
last_deployed?: string;
}
namespace ClassificationsModel {
namespace Constants {
/** When the status is `available`, the model is ready to use. */
enum Status {
STARTING = "starting",
TRAINING = "training",
DEPLOYING = "deploying",
AVAILABLE = "available",
ERROR = "error",
DELETED = "deleted"
}
}
}
/**
* List of classifications models.
*/
interface ClassificationsModelList {
/** The classifications models. */
models?: ClassificationsModel[];
}
/**
* Returns text classifications for the content.
*/
interface ClassificationsOptions {
/** Enter a [custom
* model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing)
* ID of the classifications model to be used.
*
* You can analyze tone by using a language-specific model ID. See [Tone analytics
* (Classifications)](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-tone_analytics)
* for more information.
*/
model?: string;
}
/**
* A classification of the analyzed text.
*/
interface ClassificationsResult {
/** Classification assigned to the text. */
class_name?: string;
/** Confidence score for the classification. Higher values indicate greater confidence. */
confidence?: number;
}
/**
* Optional classifications training parameters along with model train requests.
*/
interface ClassificationsTrainingParameters {
/** Model type selector to train either a single_label or a multi_label classifier. */
model_type?: ClassificationsTrainingParameters.Constants.ModelType | string;
}
namespace ClassificationsTrainingParameters {
namespace Constants {
/** Model type selector to train either a single_label or a multi_label classifier. */
enum ModelType {
SINGLE_LABEL = "single_label",
MULTI_LABEL = "multi_label"
}
}
}
/**
* Returns high-level concepts in the content. For example, a research paper about deep learning might return the
* concept, "Artificial Intelligence" although the term is not mentioned.
*
* Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Spanish.
*/
interface ConceptsOptions {
/** Maximum number of concepts to return. */
limit?: number;
}
/**
* The general concepts referenced or alluded to in the analyzed text.
*/
interface ConceptsResult {
/** Name of the concept. */
text?: string;
/** Relevance score between 0 and 1. Higher scores indicate greater relevance. */
relevance?: number;
/** Link to the corresponding DBpedia resource. */
dbpedia_resource?: string;
}
/**
* Delete model results.
*/
interface DeleteModelResults {
/** model_id of the deleted model. */
deleted?: string;
}
/**
* Disambiguation information for the entity.
*/
interface DisambiguationResult {
/** Common entity name. */
name?: string;
/** Link to the corresponding DBpedia resource. */
dbpedia_resource?: string;
/** Entity subtype information. */
subtype?: string[];
}
/**
* Emotion results for the document as a whole.
*/
interface DocumentEmotionResults {
/** Emotion results for the document as a whole. */
emotion?: EmotionScores;
}
/**
* DocumentSentimentResults.
*/
interface DocumentSentimentResults {
/** Indicates whether the sentiment is positive, neutral, or negative. */
label?: string;
/** Sentiment score from -1 (negative) to 1 (positive). */
score?: number;
}
/**
* Detects anger, disgust, fear, joy, or sadness that is conveyed in the content or by the context around target
* phrases specified in the targets parameter. You can analyze emotion for detected entities with `entities.emotion`
* and for keywords with `keywords.emotion`.
*
* Supported languages: English.
*/
interface EmotionOptions {
/** Set this to `false` to hide document-level emotion results. */
document?: boolean;
/** Emotion results will be returned for each target string that is found in the document. */
targets?: string[];
}
/**
* The detected anger, disgust, fear, joy, or sadness that is conveyed by the content. Emotion information can be
* returned for detected entities, keywords, or user-specified target phrases found in the text.
*/
interface EmotionResult {
/** Emotion results for the document as a whole. */
document?: DocumentEmotionResults;
/** Emotion results for specified targets. */
targets?: TargetedEmotionResults[];
}
/**
* EmotionScores.
*/
interface EmotionScores {
/** Anger score from 0 to 1. A higher score means that the text is more likely to convey anger. */
anger?: number;
/** Disgust score from 0 to 1. A higher score means that the text is more likely to convey disgust. */
disgust?: number;
/** Fear score from 0 to 1. A higher score means that the text is more likely to convey fear. */
fear?: number;
/** Joy score from 0 to 1. A higher score means that the text is more likely to convey joy. */
joy?: number;
/** Sadness score from 0 to 1. A higher score means that the text is more likely to convey sadness. */
sadness?: number;
}
/**
* Identifies people, cities, organizations, and other entities in the content. For more information, see [Entity
* types and
* subtypes](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-entity-type-systems).
*
* Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish.
* Arabic, Chinese, and Dutch are supported only through custom models.
*/
interface EntitiesOptions {
/** Maximum number of entities to return. */
limit?: number;
/** Set this to `true` to return locations of entity mentions. */
mentions?: boolean;
/** Enter a [custom
* model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing)
* ID to override the standard entity detection model.
*/
model?: string;
/** Set this to `true` to return sentiment information for detected entities. */
sentiment?: boolean;
/** Set this to `true` to analyze emotion for detected keywords. */
emotion?: boolean;
}
/**
* The important people, places, geopolitical entities and other types of entities in your content.
*/
interface EntitiesResult {
/** Entity type. */
type?: string;
/** The name of the entity. */
text?: string;
/** Relevance score from 0 to 1. Higher values indicate greater relevance. */
relevance?: number;
/** Confidence in the entity identification from 0 to 1. Higher values indicate higher confidence. In standard
* entities requests, confidence is returned only for English text. All entities requests that use custom models
* return the confidence score.
*/
confidence?: number;
/** Entity mentions and locations. */
mentions?: EntityMention[];
/** How many times the entity was mentioned in the text. */
count?: number;
/** Emotion analysis results for the entity, enabled with the `emotion` option. */
emotion?: EmotionScores;
/** Sentiment analysis results for the entity, enabled with the `sentiment` option. */
sentiment?: FeatureSentimentResults;
/** Disambiguation information for the entity. */
disambiguation?: DisambiguationResult;
}
/**
* EntityMention.
*/
interface EntityMention {
/** Entity mention text. */
text?: string;
/** Character offsets indicating the beginning and end of the mention in the analyzed text. */
location?: number[];
/** Confidence in the entity identification from 0 to 1. Higher values indicate higher confidence. In standard
* entities requests, confidence is returned only for English text. All entities requests that use custom models
* return the confidence score.
*/
confidence?: number;
}
/**
* FeatureSentimentResults.
*/
interface FeatureSentimentResults {
/** Sentiment score from -1 (negative) to 1 (positive). */
score?: number;
}
/**
* Analysis features and options.
*/
interface Features {
/** Returns text classifications for the content. */
classifications?: ClassificationsOptions;
/** Returns high-level concepts in the content. For example, a research paper about deep learning might return
* the concept, "Artificial Intelligence" although the term is not mentioned.
*
* Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Spanish.
*/
concepts?: ConceptsOptions;
/** Detects anger, disgust, fear, joy, or sadness that is conveyed in the content or by the context around
* target phrases specified in the targets parameter. You can analyze emotion for detected entities with
* `entities.emotion` and for keywords with `keywords.emotion`.
*
* Supported languages: English.
*/
emotion?: EmotionOptions;
/** Identifies people, cities, organizations, and other entities in the content. For more information, see
* [Entity types and
* subtypes](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-entity-type-systems).
*
* Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish.
* Arabic, Chinese, and Dutch are supported only through custom models.
*/
entities?: EntitiesOptions;
/** Returns important keywords in the content.
*
* Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish.
*/
keywords?: KeywordsOptions;
/** Returns information from the document, including author name, title, RSS/ATOM feeds, prominent page image,
* and publication date. Supports URL and HTML input types only.
*/
metadata?: JsonObject;
/** Recognizes when two entities are related and identifies the type of relation. For example, an `awardedTo`
* relation might connect the entities "Nobel Prize" and "Albert Einstein". For more information, see [Relation
* types](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-relations).
*
* Supported languages: Arabic, English, German, Japanese, Korean, Spanish.