Natural Language Response Classes#
Entity#
Definition for Google Cloud Natural Language API entities.
An entity is used to describe a proper name extracted from text.
-
class
google.cloud.language.entity.
Entity
(name, entity_type, metadata, salience, mentions)[source]# Bases:
object
A Google Cloud Natural Language API entity.
Represents a phrase in text that is a known entity, such as a person, an organization, or location. The API associates information, such as salience and mentions, with entities.
The only supported metadata (as of August 2016) is
wikipedia_url
, so this value will be removed from the passed inmetadata
and put in its own property.See Entity message.
Parameters: - name (str) – The name / phrase identified as the entity.
- entity_type (str) – The type of the entity. See EntityType enum.
- metadata (dict) – The metadata associated with the entity.
- salience (float) – The prominence of the entity / phrase within the text containing it.
- mentions (list) – List of strings that mention the entity.
-
class
google.cloud.language.entity.
EntityType
[source]# Bases:
object
List of possible entity types.
-
CONSUMER_GOOD
= 'CONSUMER_GOOD'# Consumer good entity type.
-
EVENT
= 'EVENT'# Event entity type.
-
LOCATION
= 'LOCATION'# Location entity type.
-
ORGANIZATION
= 'ORGANIZATION'# Organization entity type.
-
OTHER
= 'OTHER'# Other entity type (i.e. known but not classified).
-
PERSON
= 'PERSON'# Person entity type.
-
UNKNOWN
= 'UNKNOWN'# Unknown entity type.
-
WORK_OF_ART
= 'WORK_OF_ART'# Work of art entity type.
-
Sentiment#
Definition for Google Cloud Natural Language API sentiment.
Sentiment is the response to an analyzeSentiment
request.
-
class
google.cloud.language.sentiment.
Sentiment
(polarity, magnitude)[source]# Bases:
object
A Google Cloud Natural Language API sentiment object.
See Sentiment message and Sentiment basics.
Parameters:
Syntax#
Google Cloud Natural Language API helpers for tokenized text.
The annotateText
method, when used with the “syntax” feature,
breaks a document down into tokens and sentences.
-
class
google.cloud.language.syntax.
PartOfSpeech
[source]# Bases:
object
Part of speech of a
Token
.-
ADJECTIVE
= 'ADJ'# Part of speech: Adjective.
-
ADPOSITION
= 'ADP'# Adposition (preposition and postposition).
-
ADVERB
= 'ADV'# Adverb.
-
AFFIX
= 'AFFIX'# Affix.
-
CARDINAL_NUMBER
= 'NUM'# Cardinal number.
-
CONJUNCTION
= 'CONJ'# Conjunction.
-
DETERMINER
= 'DET'# Determiner.
-
NOUN
= 'NOUN'# Noun (common and proper).
-
OTHER
= 'X'# Other: foreign words, typos, abbreviations.
-
PARTICIPLE
= 'PRT'# Particle or other function word.
-
PRONOUN
= 'PRON'# Pronoun.
-
PUNCTUATION
= 'PUNCT'# Punctuation.
-
UNKNOWN
= 'UNKNOWN'# Unknown part of speech.
-
VERB
= 'VERB'# Verb (all tenses and modes).
-
-
class
google.cloud.language.syntax.
Sentence
(content, begin)[source]# Bases:
object
A Google Cloud Natural Language API sentence object.
See Sentence message.
Parameters:
-
class
google.cloud.language.syntax.
Token
(text_content, text_begin, part_of_speech, edge_index, edge_label, lemma)[source]# Bases:
object
A Google Cloud Natural Language API token object.
See Token message.
Parameters: - text_content (str) – The text that the token is composed of.
- text_begin (int) – The beginning offset of the content in the original document according to the encoding type specified in the API request.
- part_of_speech (str) – The part of speech of the token. See
PartOfSpeech
for possible values. - edge_index (int) – The head of this token in the dependency tree. This is
the index of the token which has an arc going to this
token. The index is the position of the token in the
array of tokens returned by the API method. If this
token is a root token, then the
edge_index
is its own index. - edge_label (str) – See Label enum.
- lemma (str) – The Lemma of the token.