| :py:mod:`airflow.providers.google.cloud.hooks.natural_language` |
| =============================================================== |
| |
| .. py:module:: airflow.providers.google.cloud.hooks.natural_language |
| |
| .. autoapi-nested-parse:: |
| |
| This module contains a Google Cloud Natural Language Hook. |
| |
| |
| |
| Module Contents |
| --------------- |
| |
| Classes |
| ~~~~~~~ |
| |
| .. autoapisummary:: |
| |
| airflow.providers.google.cloud.hooks.natural_language.CloudNaturalLanguageHook |
| |
| |
| |
| |
| .. py:class:: CloudNaturalLanguageHook(gcp_conn_id = 'google_cloud_default', delegate_to = None, impersonation_chain = None) |
| |
| Bases: :py:obj:`airflow.providers.google.common.hooks.base_google.GoogleBaseHook` |
| |
| Hook for Google Cloud Natural Language Service. |
| |
| :param gcp_conn_id: The connection ID to use when fetching connection info. |
| :param delegate_to: The account to impersonate using domain-wide delegation of authority, |
| if any. For this to work, the service account making the request must have |
| domain-wide delegation enabled. |
| :param impersonation_chain: Optional service account to impersonate using short-term |
| credentials, or chained list of accounts required to get the access_token |
| of the last account in the list, which will be impersonated in the request. |
| If set as a string, the account must grant the originating account |
| the Service Account Token Creator IAM role. |
| If set as a sequence, the identities from the list must grant |
| Service Account Token Creator IAM role to the directly preceding identity, with first |
| account from the list granting this role to the originating account. |
| |
| .. py:method:: get_conn(self) |
| |
| Retrieves connection to Cloud Natural Language service. |
| |
| :return: Cloud Natural Language service object |
| :rtype: google.cloud.language_v1.LanguageServiceClient |
| |
| |
| .. py:method:: analyze_entities(self, document, encoding_type = None, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Finds named entities in the text along with entity types, |
| salience, mentions for each entity, and other properties. |
| |
| :param document: Input document. |
| If a dict is provided, it must be of the same form as the protobuf message Document |
| :param encoding_type: The encoding type used by the API to calculate offsets. |
| :param retry: A retry object used to retry requests. If None is specified, requests will not be |
| retried. |
| :param timeout: 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. |
| :param metadata: Additional metadata that is provided to the method. |
| :rtype: google.cloud.language_v1.types.AnalyzeEntitiesResponse |
| |
| |
| .. py:method:: analyze_entity_sentiment(self, document, encoding_type = None, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Finds entities, similar to AnalyzeEntities in the text and analyzes sentiment associated with each |
| entity and its mentions. |
| |
| :param document: Input document. |
| If a dict is provided, it must be of the same form as the protobuf message Document |
| :param encoding_type: The encoding type used by the API to calculate offsets. |
| :param retry: A retry object used to retry requests. If None is specified, requests will not be |
| retried. |
| :param timeout: 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. |
| :param metadata: Additional metadata that is provided to the method. |
| :rtype: google.cloud.language_v1.types.AnalyzeEntitiesResponse |
| |
| |
| .. py:method:: analyze_sentiment(self, document, encoding_type = None, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Analyzes the sentiment of the provided text. |
| |
| :param document: Input document. |
| If a dict is provided, it must be of the same form as the protobuf message Document |
| :param encoding_type: The encoding type used by the API to calculate offsets. |
| :param retry: A retry object used to retry requests. If None is specified, requests will not be |
| retried. |
| :param timeout: 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. |
| :param metadata: Additional metadata that is provided to the method. |
| :rtype: google.cloud.language_v1.types.AnalyzeSentimentResponse |
| |
| |
| .. py:method:: analyze_syntax(self, document, encoding_type = None, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Analyzes the syntax of the text and provides sentence boundaries and tokenization along with part |
| of speech tags, dependency trees, and other properties. |
| |
| :param document: Input document. |
| If a dict is provided, it must be of the same form as the protobuf message Document |
| :param encoding_type: The encoding type used by the API to calculate offsets. |
| :param retry: A retry object used to retry requests. If None is specified, requests will not be |
| retried. |
| :param timeout: 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. |
| :param metadata: Additional metadata that is provided to the method. |
| :rtype: google.cloud.language_v1.types.AnalyzeSyntaxResponse |
| |
| |
| .. py:method:: annotate_text(self, document, features, encoding_type = None, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| A convenience method that provides all the features that analyzeSentiment, |
| analyzeEntities, and analyzeSyntax provide in one call. |
| |
| :param document: Input document. |
| If a dict is provided, it must be of the same form as the protobuf message Document |
| :param features: The enabled features. |
| If a dict is provided, it must be of the same form as the protobuf message Features |
| :param encoding_type: The encoding type used by the API to calculate offsets. |
| :param retry: A retry object used to retry requests. If None is specified, requests will not be |
| retried. |
| :param timeout: 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. |
| :param metadata: Additional metadata that is provided to the method. |
| :rtype: google.cloud.language_v1.types.AnnotateTextResponse |
| |
| |
| .. py:method:: classify_text(self, document, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Classifies a document into categories. |
| |
| :param document: Input document. |
| If a dict is provided, it must be of the same form as the protobuf message Document |
| :param retry: A retry object used to retry requests. If None is specified, requests will not be |
| retried. |
| :param timeout: 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. |
| :param metadata: Additional metadata that is provided to the method. |
| :rtype: google.cloud.language_v1.types.ClassifyTextResponse |
| |
| |
| |