ibm_watson.natural_language_understanding_v1 module

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.

class NaturalLanguageUnderstandingV1(version: str, authenticator: ibm_cloud_sdk_core.authenticators.authenticator.Authenticator = None, service_name: str = 'natural-language-understanding')[source]

Bases: ibm_cloud_sdk_core.base_service.BaseService

The Natural Language Understanding V1 service.

DEFAULT_SERVICE_URL = 'https://api.us-south.natural-language-understanding.watson.cloud.ibm.com'
DEFAULT_SERVICE_NAME = 'natural-language-understanding'
analyze(features: ibm_watson.natural_language_understanding_v1.Features, *, text: str = None, html: str = None, url: str = None, clean: bool = None, xpath: str = None, fallback_to_raw: bool = None, return_analyzed_text: bool = None, language: str = None, limit_text_characters: int = None, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Analyze text.

Analyzes text, HTML, or a public webpage for the following features: - Categories - 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).

Parameters
Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

list_models(**kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

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.

Parameters

headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

delete_model(model_id: str, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Delete model.

Deletes a custom model.

Parameters
  • model_id (str) – Model ID of the model to delete.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

class AnalysisResults(*, language: str = None, analyzed_text: str = None, retrieved_url: str = None, usage: Optional[ibm_watson.natural_language_understanding_v1.AnalysisResultsUsage] = None, concepts: List[ConceptsResult] = None, entities: List[EntitiesResult] = None, keywords: List[KeywordsResult] = None, categories: List[CategoriesResult] = None, emotion: Optional[ibm_watson.natural_language_understanding_v1.EmotionResult] = None, metadata: Optional[ibm_watson.natural_language_understanding_v1.AnalysisResultsMetadata] = None, relations: List[RelationsResult] = None, semantic_roles: List[SemanticRolesResult] = None, sentiment: Optional[ibm_watson.natural_language_understanding_v1.SentimentResult] = None, syntax: Optional[ibm_watson.natural_language_understanding_v1.SyntaxResult] = None)[source]

Bases: object

Results of the analysis, organized by feature.

Attr str language

(optional) Language used to analyze the text.

Attr str analyzed_text

(optional) Text that was used in the analysis.

Attr str retrieved_url

(optional) URL of the webpage that was analyzed.

Attr AnalysisResultsUsage usage

(optional) API usage information for the request.

Attr List[ConceptsResult] concepts

(optional) The general concepts referenced or alluded to in the analyzed text.

Attr List[EntitiesResult] entities

(optional) The entities detected in the analyzed text.

Attr List[KeywordsResult] keywords

(optional) The keywords from the analyzed text.

Attr List[CategoriesResult] categories

(optional) The categories that the service assigned to the analyzed text.

Attr EmotionResult emotion

(optional) The anger, disgust, fear, joy, or sadness conveyed by the content.

Attr AnalysisResultsMetadata metadata

(optional) Webpage metadata, such as the author and the title of the page.

Attr List[RelationsResult] relations

(optional) The relationships between entities in the content.

Attr List[SemanticRolesResult] semantic_roles

(optional) Sentences parsed into subject, action, and object form.

Attr SentimentResult sentiment

(optional) The sentiment of the content.

Attr SyntaxResult syntax

(optional) Tokens and sentences returned from syntax analysis.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.AnalysisResults[source]

Initialize a AnalysisResults object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class AnalysisResultsMetadata(*, authors: List[Author] = None, publication_date: str = None, title: str = None, image: str = None, feeds: List[Feed] = None)[source]

Bases: object

Webpage metadata, such as the author and the title of the page.

Attr List[Author] authors

(optional) The authors of the document.

Attr str publication_date

(optional) The publication date in the format ISO 8601.

Attr str title

(optional) The title of the document.

Attr str image

(optional) URL of a prominent image on the webpage.

Attr List[Feed] feeds

(optional) RSS/ATOM feeds found on the webpage.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.AnalysisResultsMetadata[source]

Initialize a AnalysisResultsMetadata object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class AnalysisResultsUsage(*, features: int = None, text_characters: int = None, text_units: int = None)[source]

Bases: object

API usage information for the request.

Attr int features

(optional) Number of features used in the API call.

Attr int text_characters

(optional) Number of text characters processed.

Attr int text_units

(optional) Number of 10,000-character units processed.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.AnalysisResultsUsage[source]

Initialize a AnalysisResultsUsage object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class Author(*, name: str = None)[source]

Bases: object

The author of the analyzed content.

Attr str name

(optional) Name of the author.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.Author[source]

Initialize a Author object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class CategoriesOptions(*, explanation: bool = None, limit: int = None, model: str = None)[source]

Bases: object

Returns a five-level taxonomy of the content. The top three categories are returned. Supported languages: Arabic, English, French, German, Italian, Japanese, Korean, Portuguese, Spanish.

Attr bool explanation

(optional) Set this to true to return explanations for each categorization. This is available only for English categories..

Attr int limit

(optional) Maximum number of categories to return.

Attr str model

(optional) Enter a [custom model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) ID to override the standard categories model. The custom categories experimental feature will be retired on 19 December 2019. On that date, deployed custom categories models will no longer be accessible in Natural Language Understanding. The feature will be removed from Knowledge Studio on an earlier date. Custom categories models will no longer be accessible in Knowledge Studio on 17 December 2019.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.CategoriesOptions[source]

Initialize a CategoriesOptions object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class CategoriesRelevantText(*, text: str = None)[source]

Bases: object

Relevant text that contributed to the categorization.

Attr str text

(optional) Text from the analyzed source that supports the categorization.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.CategoriesRelevantText[source]

Initialize a CategoriesRelevantText object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class CategoriesResult(*, label: str = None, score: float = None, explanation: Optional[ibm_watson.natural_language_understanding_v1.CategoriesResultExplanation] = None)[source]

Bases: object

A categorization of the analyzed text.

Attr str label

(optional) The path to the category through the 5-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).

Attr float score

(optional) Confidence score for the category classification. Higher values indicate greater confidence.

Attr CategoriesResultExplanation explanation

(optional) Information that helps to explain what contributed to the categories result.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.CategoriesResult[source]

Initialize a CategoriesResult object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class CategoriesResultExplanation(*, relevant_text: List[CategoriesRelevantText] = None)[source]

Bases: object

Information that helps to explain what contributed to the categories result.

Attr List[CategoriesRelevantText] relevant_text

(optional) 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.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.CategoriesResultExplanation[source]

Initialize a CategoriesResultExplanation object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class ConceptsOptions(*, limit: int = None)[source]

Bases: object

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.

Attr int limit

(optional) Maximum number of concepts to return.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.ConceptsOptions[source]

Initialize a ConceptsOptions object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class ConceptsResult(*, text: str = None, relevance: float = None, dbpedia_resource: str = None)[source]

Bases: object

The general concepts referenced or alluded to in the analyzed text.

Attr str text

(optional) Name of the concept.

Attr float relevance

(optional) Relevance score between 0 and 1. Higher scores indicate greater relevance.

Attr str dbpedia_resource

(optional) Link to the corresponding DBpedia resource.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.ConceptsResult[source]

Initialize a ConceptsResult object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class DeleteModelResults(*, deleted: str = None)[source]

Bases: object

Delete model results.

Attr str deleted

(optional) model_id of the deleted model.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.DeleteModelResults[source]

Initialize a DeleteModelResults object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class DisambiguationResult(*, name: str = None, dbpedia_resource: str = None, subtype: List[str] = None)[source]

Bases: object

Disambiguation information for the entity.

Attr str name

(optional) Common entity name.

Attr str dbpedia_resource

(optional) Link to the corresponding DBpedia resource.

Attr List[str] subtype

(optional) Entity subtype information.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.DisambiguationResult[source]

Initialize a DisambiguationResult object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class DocumentEmotionResults(*, emotion: Optional[ibm_watson.natural_language_understanding_v1.EmotionScores] = None)[source]

Bases: object

Emotion results for the document as a whole.

Attr EmotionScores emotion

(optional) Emotion results for the document as a whole.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.DocumentEmotionResults[source]

Initialize a DocumentEmotionResults object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class DocumentSentimentResults(*, label: str = None, score: float = None)[source]

Bases: object

DocumentSentimentResults.

Attr str label

(optional) Indicates whether the sentiment is positive, neutral, or negative.

Attr float score

(optional) Sentiment score from -1 (negative) to 1 (positive).

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.DocumentSentimentResults[source]

Initialize a DocumentSentimentResults object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class EmotionOptions(*, document: bool = None, targets: List[str] = None)[source]

Bases: object

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.

Attr bool document

(optional) Set this to false to hide document-level emotion results.

Attr List[str] targets

(optional) Emotion results will be returned for each target string that is found in the document.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.EmotionOptions[source]

Initialize a EmotionOptions object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class EmotionResult(*, document: Optional[ibm_watson.natural_language_understanding_v1.DocumentEmotionResults] = None, targets: List[TargetedEmotionResults] = None)[source]

Bases: object

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.

Attr DocumentEmotionResults document

(optional) Emotion results for the document as a whole.

Attr List[TargetedEmotionResults] targets

(optional) Emotion results for specified targets.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.EmotionResult[source]

Initialize a EmotionResult object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class EmotionScores(*, anger: float = None, disgust: float = None, fear: float = None, joy: float = None, sadness: float = None)[source]

Bases: object

EmotionScores.

Attr float anger

(optional) Anger score from 0 to 1. A higher score means that the text is more likely to convey anger.

Attr float disgust

(optional) Disgust score from 0 to 1. A higher score means that the text is more likely to convey disgust.

Attr float fear

(optional) Fear score from 0 to 1. A higher score means that the text is more likely to convey fear.

Attr float joy

(optional) Joy score from 0 to 1. A higher score means that the text is more likely to convey joy.

Attr float sadness

(optional) Sadness score from 0 to 1. A higher score means that the text is more likely to convey sadness.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.EmotionScores[source]

Initialize a EmotionScores object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class EntitiesOptions(*, limit: int = None, mentions: bool = None, model: str = None, sentiment: bool = None, emotion: bool = None)[source]

Bases: object

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-types). Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish. Arabic, Chinese, and Dutch are supported only through custom models.

Attr int limit

(optional) Maximum number of entities to return.

Attr bool mentions

(optional) Set this to true to return locations of entity mentions.

Attr str model

(optional) 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.

Attr bool sentiment

(optional) Set this to true to return sentiment information for detected entities.

Attr bool emotion

(optional) Set this to true to analyze emotion for detected keywords.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.EntitiesOptions[source]

Initialize a EntitiesOptions object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class EntitiesResult(*, type: str = None, text: str = None, relevance: float = None, confidence: float = None, mentions: List[EntityMention] = None, count: int = None, emotion: Optional[ibm_watson.natural_language_understanding_v1.EmotionScores] = None, sentiment: Optional[ibm_watson.natural_language_understanding_v1.FeatureSentimentResults] = None, disambiguation: Optional[ibm_watson.natural_language_understanding_v1.DisambiguationResult] = None)[source]

Bases: object

The important people, places, geopolitical entities and other types of entities in your content.

Attr str type

(optional) Entity type.

Attr str text

(optional) The name of the entity.

Attr float relevance

(optional) Relevance score from 0 to 1. Higher values indicate greater relevance.

Attr float confidence

(optional) 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.

Attr List[EntityMention] mentions

(optional) Entity mentions and locations.

Attr int count

(optional) How many times the entity was mentioned in the text.

Attr EmotionScores emotion

(optional) Emotion analysis results for the entity, enabled with the emotion option.

Attr FeatureSentimentResults sentiment

(optional) Sentiment analysis results for the entity, enabled with the sentiment option.

Attr DisambiguationResult disambiguation

(optional) Disambiguation information for the entity.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.EntitiesResult[source]

Initialize a EntitiesResult object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class EntityMention(*, text: str = None, location: List[int] = None, confidence: float = None)[source]

Bases: object

EntityMention.

Attr str text

(optional) Entity mention text.

Attr List[int] location

(optional) Character offsets indicating the beginning and end of the mention in the analyzed text.

Attr float confidence

(optional) 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.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.EntityMention[source]

Initialize a EntityMention object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class FeatureSentimentResults(*, score: float = None)[source]

Bases: object

FeatureSentimentResults.

Attr float score

(optional) Sentiment score from -1 (negative) to 1 (positive).

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.FeatureSentimentResults[source]

Initialize a FeatureSentimentResults object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class Features(*, concepts: Optional[ibm_watson.natural_language_understanding_v1.ConceptsOptions] = None, emotion: Optional[ibm_watson.natural_language_understanding_v1.EmotionOptions] = None, entities: Optional[ibm_watson.natural_language_understanding_v1.EntitiesOptions] = None, keywords: Optional[ibm_watson.natural_language_understanding_v1.KeywordsOptions] = None, metadata: Optional[ibm_watson.natural_language_understanding_v1.MetadataOptions] = None, relations: Optional[ibm_watson.natural_language_understanding_v1.RelationsOptions] = None, semantic_roles: Optional[ibm_watson.natural_language_understanding_v1.SemanticRolesOptions] = None, sentiment: Optional[ibm_watson.natural_language_understanding_v1.SentimentOptions] = None, categories: Optional[ibm_watson.natural_language_understanding_v1.CategoriesOptions] = None, syntax: Optional[ibm_watson.natural_language_understanding_v1.SyntaxOptions] = None)[source]

Bases: object

Analysis features and options.

Attr ConceptsOptions concepts

(optional) 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.

Attr EmotionOptions emotion

(optional) 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.

Attr EntitiesOptions entities

(optional) 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-types). Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish. Arabic, Chinese, and Dutch are supported only through custom models.

Attr KeywordsOptions keywords

(optional) Returns important keywords in the content. Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish.

Attr MetadataOptions metadata

(optional) 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.

Attr RelationsOptions relations

(optional) 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. Chinese, Dutch, French, Italian, and Portuguese custom models are also supported.

Attr SemanticRolesOptions semantic_roles

(optional) Parses sentences into subject, action, and object form. Supported languages: English, German, Japanese, Korean, Spanish.

Attr SentimentOptions sentiment

(optional) Analyzes the general sentiment of your content or the sentiment toward specific target phrases. You can analyze sentiment for detected entities with entities.sentiment and for keywords with keywords.sentiment.

Supported languages: Arabic, English, French, German, Italian, Japanese,

Korean, Portuguese, Russian, Spanish.

Attr CategoriesOptions categories

(optional) Returns a five-level taxonomy of the content. The top three categories are returned. Supported languages: Arabic, English, French, German, Italian, Japanese, Korean, Portuguese, Spanish.

Attr SyntaxOptions syntax

(optional) Returns tokens and sentences from the input text.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.Features[source]

Initialize a Features object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class Feed(*, link: str = None)[source]

Bases: object

RSS or ATOM feed found on the webpage.

Attr str link

(optional) URL of the RSS or ATOM feed.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.Feed[source]

Initialize a Feed object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class KeywordsOptions(*, limit: int = None, sentiment: bool = None, emotion: bool = None)[source]

Bases: object

Returns important keywords in the content. Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish.

Attr int limit

(optional) Maximum number of keywords to return.

Attr bool sentiment

(optional) Set this to true to return sentiment information for detected keywords.

Attr bool emotion

(optional) Set this to true to analyze emotion for detected keywords.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.KeywordsOptions[source]

Initialize a KeywordsOptions object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class KeywordsResult(*, count: int = None, relevance: float = None, text: str = None, emotion: Optional[ibm_watson.natural_language_understanding_v1.EmotionScores] = None, sentiment: Optional[ibm_watson.natural_language_understanding_v1.FeatureSentimentResults] = None)[source]

Bases: object

The important keywords in the content, organized by relevance.

Attr int count

(optional) Number of times the keyword appears in the analyzed text.

Attr float relevance

(optional) Relevance score from 0 to 1. Higher values indicate greater relevance.

Attr str text

(optional) The keyword text.

Attr EmotionScores emotion

(optional) Emotion analysis results for the keyword, enabled with the emotion option.

Attr FeatureSentimentResults sentiment

(optional) Sentiment analysis results for the keyword, enabled with the sentiment option.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.KeywordsResult[source]

Initialize a KeywordsResult object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class ListModelsResults(*, models: List[Model] = None)[source]

Bases: object

Custom models that are available for entities and relations.

Attr List[Model] models

(optional) An array of available models.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.ListModelsResults[source]

Initialize a ListModelsResults object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class MetadataOptions[source]

Bases: object

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.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.MetadataOptions[source]

Initialize a MetadataOptions object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class Model(*, status: str = None, model_id: str = None, language: str = None, description: str = None, workspace_id: str = None, model_version: str = None, version: str = None, version_description: str = None, created: datetime.datetime = None)[source]

Bases: object

Model.

Attr str status

(optional) When the status is available, the model is ready to use.

Attr str model_id

(optional) Unique model ID.

Attr str language

(optional) ISO 639-1 code that indicates the language of the model.

Attr str description

(optional) Model description.

Attr str workspace_id

(optional) ID of the Watson Knowledge Studio workspace that deployed this model to Natural Language Understanding.

Attr str model_version

(optional) The model version, if it was manually provided in Watson Knowledge Studio.

Attr str version

(optional) (Deprecated — use model_version) The model version, if it was manually provided in Watson Knowledge Studio.

Attr str version_description

(optional) The description of the version, if it was manually provided in Watson Knowledge Studio.

Attr datetime created

(optional) A dateTime indicating when the model was created.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.Model[source]

Initialize a Model object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class StatusEnum(value)[source]

Bases: enum.Enum

When the status is available, the model is ready to use.

STARTING = 'starting'
TRAINING = 'training'
DEPLOYING = 'deploying'
AVAILABLE = 'available'
ERROR = 'error'
DELETED = 'deleted'
class RelationArgument(*, entities: List[RelationEntity] = None, location: List[int] = None, text: str = None)[source]

Bases: object

RelationArgument.

Attr List[RelationEntity] entities

(optional) An array of extracted entities.

Attr List[int] location

(optional) Character offsets indicating the beginning and end of the mention in the analyzed text.

Attr str text

(optional) Text that corresponds to the argument.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.RelationArgument[source]

Initialize a RelationArgument object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class RelationEntity(*, text: str = None, type: str = None)[source]

Bases: object

An entity that corresponds with an argument in a relation.

Attr str text

(optional) Text that corresponds to the entity.

Attr str type

(optional) Entity type.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.RelationEntity[source]

Initialize a RelationEntity object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class RelationsOptions(*, model: str = None)[source]

Bases: object

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. Chinese, Dutch, French, Italian, and Portuguese custom models are also supported.

Attr str model

(optional) Enter a [custom model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) ID to override the default model.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.RelationsOptions[source]

Initialize a RelationsOptions object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class RelationsResult(*, score: float = None, sentence: str = None, type: str = None, arguments: List[RelationArgument] = None)[source]

Bases: object

The relations between entities found in the content.

Attr float score

(optional) Confidence score for the relation. Higher values indicate greater confidence.

Attr str sentence

(optional) The sentence that contains the relation.

Attr str type

(optional) The type of the relation.

Attr List[RelationArgument] arguments

(optional) Entity mentions that are involved in the relation.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.RelationsResult[source]

Initialize a RelationsResult object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class SemanticRolesEntity(*, type: str = None, text: str = None)[source]

Bases: object

SemanticRolesEntity.

Attr str type

(optional) Entity type.

Attr str text

(optional) The entity text.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.SemanticRolesEntity[source]

Initialize a SemanticRolesEntity object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class SemanticRolesKeyword(*, text: str = None)[source]

Bases: object

SemanticRolesKeyword.

Attr str text

(optional) The keyword text.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.SemanticRolesKeyword[source]

Initialize a SemanticRolesKeyword object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class SemanticRolesOptions(*, limit: int = None, keywords: bool = None, entities: bool = None)[source]

Bases: object

Parses sentences into subject, action, and object form. Supported languages: English, German, Japanese, Korean, Spanish.

Attr int limit

(optional) Maximum number of semantic_roles results to return.

Attr bool keywords

(optional) Set this to true to return keyword information for subjects and objects.

Attr bool entities

(optional) Set this to true to return entity information for subjects and objects.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.SemanticRolesOptions[source]

Initialize a SemanticRolesOptions object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class SemanticRolesResult(*, sentence: str = None, subject: Optional[ibm_watson.natural_language_understanding_v1.SemanticRolesResultSubject] = None, action: Optional[ibm_watson.natural_language_understanding_v1.SemanticRolesResultAction] = None, object: Optional[ibm_watson.natural_language_understanding_v1.SemanticRolesResultObject] = None)[source]

Bases: object

The object containing the actions and the objects the actions act upon.

Attr str sentence

(optional) Sentence from the source that contains the subject, action, and object.

Attr SemanticRolesResultSubject subject

(optional) The extracted subject from the sentence.

Attr SemanticRolesResultAction action

(optional) The extracted action from the sentence.

Attr SemanticRolesResultObject object

(optional) The extracted object from the sentence.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.SemanticRolesResult[source]

Initialize a SemanticRolesResult object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class SemanticRolesResultAction(*, text: str = None, normalized: str = None, verb: Optional[ibm_watson.natural_language_understanding_v1.SemanticRolesVerb] = None)[source]

Bases: object

The extracted action from the sentence.

Attr str text

(optional) Analyzed text that corresponds to the action.

Attr str normalized

(optional) normalized version of the action.

Attr SemanticRolesVerb verb

(optional)

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.SemanticRolesResultAction[source]

Initialize a SemanticRolesResultAction object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class SemanticRolesResultObject(*, text: str = None, keywords: List[SemanticRolesKeyword] = None)[source]

Bases: object

The extracted object from the sentence.

Attr str text

(optional) Object text.

Attr List[SemanticRolesKeyword] keywords

(optional) An array of extracted keywords.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.SemanticRolesResultObject[source]

Initialize a SemanticRolesResultObject object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class SemanticRolesResultSubject(*, text: str = None, entities: List[SemanticRolesEntity] = None, keywords: List[SemanticRolesKeyword] = None)[source]

Bases: object

The extracted subject from the sentence.

Attr str text

(optional) Text that corresponds to the subject role.

Attr List[SemanticRolesEntity] entities

(optional) An array of extracted entities.

Attr List[SemanticRolesKeyword] keywords

(optional) An array of extracted keywords.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.SemanticRolesResultSubject[source]

Initialize a SemanticRolesResultSubject object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class SemanticRolesVerb(*, text: str = None, tense: str = None)[source]

Bases: object

SemanticRolesVerb.

Attr str text

(optional) The keyword text.

Attr str tense

(optional) Verb tense.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.SemanticRolesVerb[source]

Initialize a SemanticRolesVerb object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class SentenceResult(*, text: str = None, location: List[int] = None)[source]

Bases: object

SentenceResult.

Attr str text

(optional) The sentence.

Attr List[int] location

(optional) Character offsets indicating the beginning and end of the sentence in the analyzed text.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.SentenceResult[source]

Initialize a SentenceResult object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class SentimentOptions(*, document: bool = None, targets: List[str] = None)[source]

Bases: object

Analyzes the general sentiment of your content or the sentiment toward specific target phrases. You can analyze sentiment for detected entities with entities.sentiment and for keywords with keywords.sentiment.

Supported languages: Arabic, English, French, German, Italian, Japanese, Korean,

Portuguese, Russian, Spanish.

Attr bool document

(optional) Set this to false to hide document-level sentiment results.

Attr List[str] targets

(optional) Sentiment results will be returned for each target string that is found in the document.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.SentimentOptions[source]

Initialize a SentimentOptions object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class SentimentResult(*, document: Optional[ibm_watson.natural_language_understanding_v1.DocumentSentimentResults] = None, targets: List[TargetedSentimentResults] = None)[source]

Bases: object

The sentiment of the content.

Attr DocumentSentimentResults document

(optional) The document level sentiment.

Attr List[TargetedSentimentResults] targets

(optional) The targeted sentiment to analyze.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.SentimentResult[source]

Initialize a SentimentResult object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class SyntaxOptions(*, tokens: Optional[ibm_watson.natural_language_understanding_v1.SyntaxOptionsTokens] = None, sentences: bool = None)[source]

Bases: object

Returns tokens and sentences from the input text.

Attr SyntaxOptionsTokens tokens

(optional) Tokenization options.

Attr bool sentences

(optional) Set this to true to return sentence information.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.SyntaxOptions[source]

Initialize a SyntaxOptions object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class SyntaxOptionsTokens(*, lemma: bool = None, part_of_speech: bool = None)[source]

Bases: object

Tokenization options.

Attr bool lemma

(optional) Set this to true to return the lemma for each token.

Attr bool part_of_speech

(optional) Set this to true to return the part of speech for each token.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.SyntaxOptionsTokens[source]

Initialize a SyntaxOptionsTokens object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class SyntaxResult(*, tokens: List[TokenResult] = None, sentences: List[SentenceResult] = None)[source]

Bases: object

Tokens and sentences returned from syntax analysis.

Attr List[TokenResult] tokens

(optional)

Attr List[SentenceResult] sentences

(optional)

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.SyntaxResult[source]

Initialize a SyntaxResult object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class TargetedEmotionResults(*, text: str = None, emotion: Optional[ibm_watson.natural_language_understanding_v1.EmotionScores] = None)[source]

Bases: object

Emotion results for a specified target.

Attr str text

(optional) Targeted text.

Attr EmotionScores emotion

(optional) The emotion results for the target.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.TargetedEmotionResults[source]

Initialize a TargetedEmotionResults object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class TargetedSentimentResults(*, text: str = None, score: float = None)[source]

Bases: object

TargetedSentimentResults.

Attr str text

(optional) Targeted text.

Attr float score

(optional) Sentiment score from -1 (negative) to 1 (positive).

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.TargetedSentimentResults[source]

Initialize a TargetedSentimentResults object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class TokenResult(*, text: str = None, part_of_speech: str = None, location: List[int] = None, lemma: str = None)[source]

Bases: object

TokenResult.

Attr str text

(optional) The token as it appears in the analyzed text.

Attr str part_of_speech

(optional) The part of speech of the token. For more information about the values, see [Universal Dependencies POS tags](https://universaldependencies.org/u/pos/).

Attr List[int] location

(optional) Character offsets indicating the beginning and end of the token in the analyzed text.

Attr str lemma

(optional) The [lemma](https://wikipedia.org/wiki/Lemma_%28morphology%29) of the token.

classmethod from_dict(_dict: Dict)ibm_watson.natural_language_understanding_v1.TokenResult[source]

Initialize a TokenResult object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class PartOfSpeechEnum(value)[source]

Bases: enum.Enum

The part of speech of the token. For more information about the values, see [Universal Dependencies POS tags](https://universaldependencies.org/u/pos/).

ADJ = 'ADJ'
ADP = 'ADP'
ADV = 'ADV'
AUX = 'AUX'
CCONJ = 'CCONJ'
DET = 'DET'
INTJ = 'INTJ'
NOUN = 'NOUN'
NUM = 'NUM'
PART = 'PART'
PRON = 'PRON'
PROPN = 'PROPN'
PUNCT = 'PUNCT'
SCONJ = 'SCONJ'
SYM = 'SYM'
VERB = 'VERB'
X = 'X'