Options
All
  • Public
  • Public/Protected
  • All
Menu

Class NaturalLanguageUnderstandingV1

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. interfaces

You can create custom models 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

Hierarchy

  • BaseService
    • NaturalLanguageUnderstandingV1

Index

Constructors

constructor

Properties

version

version: string

Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2021-08-01.

Static DEFAULT_SERVICE_NAME

DEFAULT_SERVICE_NAME: string = "natural-language-understanding"

Static DEFAULT_SERVICE_URL

DEFAULT_SERVICE_URL: string = "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com"

Methods

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
    • Summarization (Experimental)

    If a language for the input text is not specified with the language parameter, the service automatically detects the language.

    Parameters

    Name Type Attribute Description
    params AnalyzeParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    features Features Specific features to analyze the document for.
    clean boolean Optional 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).
    fallbackToRaw boolean Optional Whether to use raw HTML content if text cleaning fails.
    headers OutgoingHttpHeaders Optional
    html string Optional The HTML file to analyze. One of the `text`, `html`, or `url` parameters is required.
    language string Optional 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).
    limitTextCharacters number Optional Sets the maximum number of characters that are processed by the service.
    returnAnalyzedText boolean Optional Whether or not to return the analyzed text.
    text string Optional The plain text to analyze. One of the `text`, `html`, or `url` parameters is required.
    url string Optional The webpage to analyze. One of the `text`, `html`, or `url` parameters is required.
    xpath string Optional 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`.

    Returns Promise<Response<AnalysisResults>>

createCategoriesModel

  • 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.

    Parameters

    Name Type Attribute Description
    params CreateCategoriesModelParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    language string The 2-letter language code of this model.
    trainingData ReadableStream | Buffer 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).
    description string Optional An optional description of the model.
    headers OutgoingHttpHeaders Optional
    modelVersion string Optional An optional version string.
    name string Optional An optional name for the model.
    trainingDataContentType TrainingDataContentType | string Optional The content type of trainingData.
    versionDescription string Optional The description of the version.
    workspaceId string Optional ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language Understanding.

    Returns Promise<Response<CategoriesModel>>

createClassificationsModel

  • 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.

    Parameters

    Name Type Attribute Description
    params CreateClassificationsModelParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    language string The 2-letter language code of this model.
    trainingData ReadableStream | Buffer 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).
    description string Optional An optional description of the model.
    headers OutgoingHttpHeaders Optional
    modelVersion string Optional An optional version string.
    name string Optional An optional name for the model.
    trainingDataContentType TrainingDataContentType | string Optional The content type of trainingData.
    versionDescription string Optional The description of the version.
    workspaceId string Optional ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language Understanding.

    Returns Promise<Response<ClassificationsModel>>

createSentimentModel

  • Create sentiment model.

    (Beta) Creates a custom sentiment 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.

    Parameters

    Name Type Attribute Description
    params CreateSentimentModelParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    language string The 2-letter language code of this model.
    trainingData ReadableStream | Buffer Training data in CSV format. For more information, see [Sentiment training data requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-custom-sentiment#sentiment-training-data-requirements).
    description string Optional An optional description of the model.
    headers OutgoingHttpHeaders Optional
    modelVersion string Optional An optional version string.
    name string Optional An optional name for the model.
    versionDescription string Optional The description of the version.
    workspaceId string Optional ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language Understanding.

    Returns Promise<Response<SentimentModel>>

deleteCategoriesModel

  • 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.

    Parameters

    Name Type Attribute Description
    params DeleteCategoriesModelParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    modelId string ID of the model.
    headers OutgoingHttpHeaders Optional

    Returns Promise<Response<DeleteModelResults>>

deleteClassificationsModel

  • 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.

    Parameters

    Name Type Attribute Description
    params DeleteClassificationsModelParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    modelId string ID of the model.
    headers OutgoingHttpHeaders Optional

    Returns Promise<Response<DeleteModelResults>>

deleteModel

deleteSentimentModel

  • Delete sentiment model.

    (Beta) Un-deploys the custom sentiment model with the given model ID and deletes all associated customer data, including any training data or binary artifacts.

    Parameters

    Name Type Attribute Description
    params DeleteSentimentModelParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    modelId string ID of the model.
    headers OutgoingHttpHeaders Optional

    Returns Promise<Response<DeleteModelResults>>

disableRetries

  • disableRetries(): void
  • Disables retries.

    Returns void

enableRetries

  • enableRetries(retryOptions?: RetryOptions): void
  • Enable retries for unfulfilled requests.

    Parameters

    Name Type Attribute Description
    retryOptions RetryOptions Optional

    configuration for retries

    Returns void

getAuthenticator

  • getAuthenticator(): any
  • Get the instance of the authenticator set on the service.

    Returns any

getCategoriesModel

getClassificationsModel

getHttpClient

  • getHttpClient(): AxiosInstance
  • Get the Axios instance set on the service. All requests will be made using this instance.

    Returns AxiosInstance

getSentimentModel

listCategoriesModels

listClassificationsModels

listModels

listSentimentModels

setEnableGzipCompression

  • setEnableGzipCompression(setting: boolean): void
  • Turn request body compression on or off.

    Parameters

    Name Type Attribute Description
    setting boolean

    Will turn it on if 'true', off if 'false'.

    Returns void

setServiceUrl

  • setServiceUrl(url: string): void
  • Set the service URL to send requests to.

    Parameters

    Name Type Attribute Description
    url string

    The base URL for the service.

    Returns void

updateCategoriesModel

  • 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.

    Parameters

    Name Type Attribute Description
    params UpdateCategoriesModelParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    language string The 2-letter language code of this model.
    modelId string ID of the model.
    trainingData ReadableStream | Buffer 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).
    description string Optional An optional description of the model.
    headers OutgoingHttpHeaders Optional
    modelVersion string Optional An optional version string.
    name string Optional An optional name for the model.
    trainingDataContentType TrainingDataContentType | string Optional The content type of trainingData.
    versionDescription string Optional The description of the version.
    workspaceId string Optional ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language Understanding.

    Returns Promise<Response<CategoriesModel>>

updateClassificationsModel

  • Update classifications model.

    Overwrites the training data associated with this custom classifications model and retrains the model. The new model replaces the current deployment.

    Parameters

    Name Type Attribute Description
    params UpdateClassificationsModelParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    language string The 2-letter language code of this model.
    modelId string ID of the model.
    trainingData ReadableStream | Buffer 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).
    description string Optional An optional description of the model.
    headers OutgoingHttpHeaders Optional
    modelVersion string Optional An optional version string.
    name string Optional An optional name for the model.
    trainingDataContentType TrainingDataContentType | string Optional The content type of trainingData.
    versionDescription string Optional The description of the version.
    workspaceId string Optional ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language Understanding.

    Returns Promise<Response<ClassificationsModel>>

updateSentimentModel

  • Update sentiment model.

    (Beta) Overwrites the training data associated with this custom sentiment model and retrains the model. The new model replaces the current deployment.

    Parameters

    Name Type Attribute Description
    params UpdateSentimentModelParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    language string The 2-letter language code of this model.
    modelId string ID of the model.
    trainingData ReadableStream | Buffer Training data in CSV format. For more information, see [Sentiment training data requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-custom-sentiment#sentiment-training-data-requirements).
    description string Optional An optional description of the model.
    headers OutgoingHttpHeaders Optional
    modelVersion string Optional An optional version string.
    name string Optional An optional name for the model.
    versionDescription string Optional The description of the version.
    workspaceId string Optional ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language Understanding.

    Returns Promise<Response<SentimentModel>>

Generated using TypeDoc