airflow.contrib.hooks.gcp_natural_language_hook
¶
Module Contents¶
-
class
airflow.contrib.hooks.gcp_natural_language_hook.
CloudNaturalLanguageHook
(gcp_conn_id='google_cloud_default', delegate_to=None)[source]¶ Bases:
airflow.contrib.hooks.gcp_api_base_hook.GoogleCloudBaseHook
Hook for Google Cloud Natural Language Service.
- Parameters
-
get_conn
(self)[source]¶ Retrieves connection to Cloud Natural Language service.
- Returns
Cloud Natural Language service object
- Return type
-
analyze_entities
(self, document, encoding_type=None, retry=None, timeout=None, metadata=None)[source]¶ Finds named entities in the text along with entity types, salience, mentions for each entity, and other properties.
- Parameters
document (dict or class google.cloud.language_v1.types.Document) – Input document. If a dict is provided, it must be of the same form as the protobuf message Document
encoding_type (google.cloud.language_v1.types.EncodingType) – The encoding type used by the API to calculate offsets.
retry (google.api_core.retry.Retry) – A retry object used to retry requests. If None is specified, requests will not be retried.
timeout (float) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.
metadata (sequence[tuple[str, str]]]) – Additional metadata that is provided to the method.
- Return type
-
analyze_entity_sentiment
(self, document, encoding_type=None, retry=None, timeout=None, metadata=None)[source]¶ Finds entities, similar to AnalyzeEntities in the text and analyzes sentiment associated with each entity and its mentions.
- Parameters
document (dict or class google.cloud.language_v1.types.Document) – Input document. If a dict is provided, it must be of the same form as the protobuf message Document
encoding_type (google.cloud.language_v1.types.EncodingType) – The encoding type used by the API to calculate offsets.
retry (google.api_core.retry.Retry) – A retry object used to retry requests. If None is specified, requests will not be retried.
timeout (float) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.
metadata (sequence[tuple[str, str]]]) – Additional metadata that is provided to the method.
- Return type
-
analyze_sentiment
(self, document, encoding_type=None, retry=None, timeout=None, metadata=None)[source]¶ Analyzes the sentiment of the provided text.
- Parameters
document (dict or class google.cloud.language_v1.types.Document) – Input document. If a dict is provided, it must be of the same form as the protobuf message Document
encoding_type (google.cloud.language_v1.types.EncodingType) – The encoding type used by the API to calculate offsets.
retry (google.api_core.retry.Retry) – A retry object used to retry requests. If None is specified, requests will not be retried.
timeout (float) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.
metadata (sequence[tuple[str, str]]]) – Additional metadata that is provided to the method.
- Return type
-
analyze_syntax
(self, document, encoding_type=None, retry=None, timeout=None, metadata=None)[source]¶ Analyzes the syntax of the text and provides sentence boundaries and tokenization along with part of speech tags, dependency trees, and other properties.
- Parameters
document (dict or class google.cloud.language_v1.types.Document#) – Input document. If a dict is provided, it must be of the same form as the protobuf message Document
encoding_type (google.cloud.language_v1.types.EncodingType) – The encoding type used by the API to calculate offsets.
retry (google.api_core.retry.Retry) – A retry object used to retry requests. If None is specified, requests will not be retried.
timeout (float) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.
metadata (sequence[tuple[str, str]]]) – Additional metadata that is provided to the method.
- Return type
-
annotate_text
(self, document, features, encoding_type=None, retry=None, timeout=None, metadata=None)[source]¶ A convenience method that provides all the features that analyzeSentiment, analyzeEntities, and analyzeSyntax provide in one call.
- Parameters
document (dict or google.cloud.language_v1.types.Document) – Input document. If a dict is provided, it must be of the same form as the protobuf message Document
features (dict or google.cloud.language_v1.enums.Features) – The enabled features. If a dict is provided, it must be of the same form as the protobuf message Features
encoding_type (google.cloud.language_v1.types.EncodingType) – The encoding type used by the API to calculate offsets.
retry (google.api_core.retry.Retry) – A retry object used to retry requests. If None is specified, requests will not be retried.
timeout (float) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.
metadata (sequence[tuple[str, str]]]) – Additional metadata that is provided to the method.
- Return type
-
classify_text
(self, document, retry=None, timeout=None, metadata=None)[source]¶ Classifies a document into categories.
- Parameters
document (dict or class google.cloud.language_v1.types.Document) – Input document. If a dict is provided, it must be of the same form as the protobuf message Document
retry (google.api_core.retry.Retry) – A retry object used to retry requests. If None is specified, requests will not be retried.
timeout (float) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.
metadata (sequence[tuple[str, str]]]) – Additional metadata that is provided to the method.
- Return type