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/services/natural-language-understanding?topic=natural-language-understanding-customizing) with Watson Knowledge Studio to detect custom entities, relations, and categories in Natural Language Understanding.
-
class
NaturalLanguageUnderstandingV1
(version, authenticator=None)[source]¶ Bases:
ibm_cloud_sdk_core.base_service.BaseService
The Natural Language Understanding V1 service.
-
default_service_url
= 'https://gateway.watsonplatform.net/natural-language-understanding/api'¶
-
analyze
(features, *, text=None, html=None, url=None, clean=None, xpath=None, fallback_to_raw=None, return_analyzed_text=None, language=None, limit_text_characters=None, **kwargs)[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 (Experimental).
- Parameters
features (Features) – Specific features to analyze the document for.
text (str) – (optional) The plain text to analyze. One of the text, html, or url parameters is required.
html (str) – (optional) The HTML file to analyze. One of the text, html, or url parameters is required.
url (str) – (optional) The webpage to analyze. One of the text, html, or url parameters is required.
clean (bool) – (optional) Set this to false to disable webpage cleaning. To learn more about webpage cleaning, see the [Analyzing webpages](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages) documentation.
xpath (str) – (optional) An [XPath query](https://cloud.ibm.com/docs/services/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.
fallback_to_raw (bool) – (optional) Whether to use raw HTML content if text cleaning fails.
return_analyzed_text (bool) – (optional) Whether or not to return the analyzed text.
language (str) – (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. See [Language support](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-language-support) for more information.
limit_text_characters (int) – (optional) Sets the maximum number of characters that are processed by the service.
headers (dict) – A dict containing the request headers
- Returns
A DetailedResponse containing the result, headers and HTTP status code.
- Return type
DetailedResponse
-
list_models
(**kwargs)[source]¶ List models.
Lists Watson Knowledge Studio [custom entities and relations models](https://cloud.ibm.com/docs/services/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
-
-
class
AnalysisResults
(*, language=None, analyzed_text=None, retrieved_url=None, usage=None, concepts=None, entities=None, keywords=None, categories=None, emotion=None, metadata=None, relations=None, semantic_roles=None, sentiment=None, syntax=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.
-
class
AnalysisResultsMetadata
(*, authors=None, publication_date=None, title=None, image=None, feeds=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.
-
class
AnalysisResultsUsage
(*, features=None, text_characters=None, text_units=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.
-
class
Author
(*, name=None)[source]¶ Bases:
object
The author of the analyzed content.
- Attr str name
(optional) Name of the author.
-
class
CategoriesOptions
(*, explanation=None, limit=None, model=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/services/natural-language-understanding?topic=natural-language-understanding-customizing) ID to override the standard categories model.
-
class
CategoriesRelevantText
(*, text=None)[source]¶ Bases:
object
Relevant text that contributed to the categorization.
- Attr str text
(optional) Text from the analyzed source that supports the categorization.
-
class
CategoriesResult
(*, label=None, score=None, explanation=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 the complete list of categories, see the [Categories hierarchy](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-categories#categories-hierarchy) documentation.
- 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.
-
class
CategoriesResultExplanation
(*, relevant_text=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.
-
class
ConceptsOptions
(*, limit=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.
-
class
ConceptsResult
(*, text=None, relevance=None, dbpedia_resource=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.
-
class
DeleteModelResults
(*, deleted=None)[source]¶ Bases:
object
Delete model results.
- Attr str deleted
(optional) model_id of the deleted model.
-
class
DisambiguationResult
(*, name=None, dbpedia_resource=None, subtype=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.
-
class
DocumentEmotionResults
(*, emotion=None)[source]¶ Bases:
object
Emotion results for the document as a whole.
- Attr EmotionScores emotion
(optional) Emotion results for the document as a whole.
-
class
DocumentSentimentResults
(*, label=None, score=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).
-
class
EmotionOptions
(*, document=None, targets=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.
-
class
EmotionResult
(*, document=None, targets=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.
-
class
EmotionScores
(*, anger=None, disgust=None, fear=None, joy=None, sadness=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.
-
class
EntitiesOptions
(*, limit=None, mentions=None, model=None, sentiment=None, emotion=None)[source]¶ Bases:
object
Identifies people, cities, organizations, and other entities in the content. See [Entity types and subtypes](https://cloud.ibm.com/docs/services/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/services/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.
-
class
EntitiesResult
(*, type=None, text=None, relevance=None, confidence=None, mentions=None, count=None, emotion=None, sentiment=None, disambiguation=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.
-
class
EntityMention
(*, text=None, location=None, confidence=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.
-
class
FeatureSentimentResults
(*, score=None)[source]¶ Bases:
object
FeatureSentimentResults.
- Attr float score
(optional) Sentiment score from -1 (negative) to 1 (positive).
-
class
Features
(*, concepts=None, emotion=None, entities=None, keywords=None, metadata=None, relations=None, semantic_roles=None, sentiment=None, categories=None, syntax=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. See [Entity types and subtypes](https://cloud.ibm.com/docs/services/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”. See [Relation types](https://cloud.ibm.com/docs/services/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.
-
class
Feed
(*, link=None)[source]¶ Bases:
object
RSS or ATOM feed found on the webpage.
- Attr str link
(optional) URL of the RSS or ATOM feed.
-
class
KeywordsOptions
(*, limit=None, sentiment=None, emotion=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.
-
class
KeywordsResult
(*, count=None, relevance=None, text=None, emotion=None, sentiment=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.
-
class
ListModelsResults
(*, models=None)[source]¶ Bases:
object
Custom models that are available for entities and relations.
- Attr list[Model] models
(optional) An array of available models.
-
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.
-
class
Model
(*, status=None, model_id=None, language=None, description=None, workspace_id=None, version=None, version_description=None, created=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 indicating 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 version
(optional) 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.
-
class
RelationArgument
(*, entities=None, location=None, text=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.
-
class
RelationEntity
(*, text=None, type=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.
-
class
RelationsOptions
(*, model=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”. See [Relation types](https://cloud.ibm.com/docs/services/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/services/natural-language-understanding?topic=natural-language-understanding-customizing) ID to override the default model.
-
class
RelationsResult
(*, score=None, sentence=None, type=None, arguments=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.
-
class
SemanticRolesEntity
(*, type=None, text=None)[source]¶ Bases:
object
SemanticRolesEntity.
- Attr str type
(optional) Entity type.
- Attr str text
(optional) The entity text.
-
class
SemanticRolesKeyword
(*, text=None)[source]¶ Bases:
object
SemanticRolesKeyword.
- Attr str text
(optional) The keyword text.
-
class
SemanticRolesOptions
(*, limit=None, keywords=None, entities=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.
-
class
SemanticRolesResult
(*, sentence=None, subject=None, action=None, object=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.
-
class
SemanticRolesResultAction
(*, text=None, normalized=None, verb=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)
-
class
SemanticRolesResultObject
(*, text=None, keywords=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.
-
class
SemanticRolesResultSubject
(*, text=None, entities=None, keywords=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.
-
class
SemanticRolesVerb
(*, text=None, tense=None)[source]¶ Bases:
object
SemanticRolesVerb.
- Attr str text
(optional) The keyword text.
- Attr str tense
(optional) Verb tense.
-
class
SentenceResult
(*, text=None, location=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.
-
class
SentimentOptions
(*, document=None, targets=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.
-
class
SentimentResult
(*, document=None, targets=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.
-
class
SyntaxOptions
(*, tokens=None, sentences=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.
-
class
SyntaxOptionsTokens
(*, lemma=None, part_of_speech=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.
-
class
SyntaxResult
(*, tokens=None, sentences=None)[source]¶ Bases:
object
Tokens and sentences returned from syntax analysis.
- Attr list[TokenResult] tokens
(optional)
- Attr list[SentenceResult] sentences
(optional)
-
class
TargetedEmotionResults
(*, text=None, emotion=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.
-
class
TargetedSentimentResults
(*, text=None, score=None)[source]¶ Bases:
object
TargetedSentimentResults.
- Attr str text
(optional) Targeted text.
- Attr float score
(optional) Sentiment score from -1 (negative) to 1 (positive).
-
class
TokenResult
(*, text=None, part_of_speech=None, location=None, lemma=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 descriptions of 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.
-
class
PartOfSpeechEnum
[source]¶ Bases:
enum.Enum
The part of speech of the token. For descriptions of 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'¶
-