airflow.providers.google.cloud.hooks.natural_language¶
本模組包含 Google Cloud Natural Language Hook。
類¶
用於 Google Cloud Natural Language Service 的 Hook。 |
模組內容¶
- class airflow.providers.google.cloud.hooks.natural_language.CloudNaturalLanguageHook(gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]¶
基類:
airflow.providers.google.common.hooks.base_google.GoogleBaseHook用於 Google Cloud Natural Language Service 的 Hook。
- 引數:
gcp_conn_id (str) – 用於獲取連線資訊的連線 ID。
impersonation_chain (str | collections.abc.Sequence[str] | None) – 可選的服務帳號,用於使用短期憑據進行模擬,或獲取列表中最後一個帳號的 access_token 所需的鏈式帳號列表,該帳號將在請求中被模擬。如果設定為字串,該帳號必須授予原始帳號 Service Account Token Creator IAM 角色。如果設定為序列,列表中的身份必須授予 Service Account Token Creator IAM 角色給直接前一個身份,列表中第一個帳號將此角色授予原始帳號。
- get_conn()[source]¶
檢索與 Cloud Natural Language 服務的連線。
- 返回:
Cloud Natural Language 服務物件
- 返回型別:
google.cloud.language_v1.LanguageServiceClient
- analyze_entities(document, encoding_type=None, retry=DEFAULT, timeout=None, metadata=())[source]¶
在文字中查詢命名實體及其各種屬性。
例如,實體型別、顯著性、每個實體的提及等屬性。
- 引數:
document (dict | google.cloud.language_v1.types.Document) – 輸入文件。如果提供字典,其形式必須與 protobuf 訊息 Document 相同
encoding_type (google.cloud.language_v1.EncodingType | None) – API 用於計算偏移量的編碼型別。
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 用於重試請求的重試物件。如果指定 None,則不會重試請求。
timeout (float | None) – 等待請求完成的時間,以秒為單位。請注意,如果指定了 retry,則超時應用於每次單獨的嘗試。
metadata (collections.abc.Sequence[tuple[str, str]]) – 提供給方法的額外元資料。
- analyze_entity_sentiment(document, encoding_type=None, retry=DEFAULT, timeout=None, metadata=())[source]¶
與 AnalyzeEntities 類似,同時分析與每個實體及其提及相關的情感。
- 引數:
document (dict | google.cloud.language_v1.types.Document) – 輸入文件。如果提供字典,其形式必須與 protobuf 訊息 Document 相同
encoding_type (google.cloud.language_v1.EncodingType | None) – API 用於計算偏移量的編碼型別。
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 用於重試請求的重試物件。如果指定 None,則不會重試請求。
timeout (float | None) – 等待請求完成的時間,以秒為單位。請注意,如果指定了 retry,則超時應用於每次單獨的嘗試。
metadata (collections.abc.Sequence[tuple[str, str]]) – 提供給方法的額外元資料。
- analyze_sentiment(document, encoding_type=None, retry=DEFAULT, timeout=None, metadata=())[source]¶
分析提供文字的情感。
- 引數:
document (dict | google.cloud.language_v1.types.Document) – 輸入文件。如果提供字典,其形式必須與 protobuf 訊息 Document 相同
encoding_type (google.cloud.language_v1.EncodingType | None) – API 用於計算偏移量的編碼型別。
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 用於重試請求的重試物件。如果指定 None,則不會重試請求。
timeout (float | None) – 等待請求完成的時間,以秒為單位。請注意,如果指定了 retry,則超時應用於每次單獨的嘗試。
metadata (collections.abc.Sequence[tuple[str, str]]) – 提供給方法的額外元資料。
- analyze_syntax(document, encoding_type=None, retry=DEFAULT, timeout=None, metadata=())[source]¶
分析文字的語法。
提供句子邊界和分詞,以及詞性標記、依存樹和其他屬性。
- 引數:
document (dict | google.cloud.language_v1.types.Document) – 輸入文件。如果提供字典,其形式必須與 protobuf 訊息 Document 相同
encoding_type (google.cloud.language_v1.EncodingType | None) – API 用於計算偏移量的編碼型別。
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 用於重試請求的重試物件。如果指定 None,則不會重試請求。
timeout (float | None) – 等待請求完成的時間,以秒為單位。請注意,如果指定了 retry,則超時應用於每次單獨的嘗試。
metadata (collections.abc.Sequence[tuple[str, str]]) – 提供給方法的額外元資料。
- annotate_text(document, features, encoding_type=None, retry=DEFAULT, timeout=None, metadata=())[source]¶
透過一次呼叫提供 analyzeSentiment、analyzeEntities 和 analyzeSyntax 所提供的所有功能。
- 引數:
document (dict | google.cloud.language_v1.types.Document) – 輸入文件。如果提供字典,其形式必須與 protobuf 訊息 Document 相同
features (dict | google.cloud.language_v1.types.AnnotateTextRequest.Features) – 啟用的功能。如果提供字典,其形式必須與 protobuf 訊息 Features 相同
encoding_type (google.cloud.language_v1.EncodingType | None) – API 用於計算偏移量的編碼型別。
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 用於重試請求的重試物件。如果指定 None,則不會重試請求。
timeout (float | None) – 等待請求完成的時間,以秒為單位。請注意,如果指定了 retry,則超時應用於每次單獨的嘗試。
metadata (collections.abc.Sequence[tuple[str, str]]) – 提供給方法的額外元資料。
- classify_text(document, retry=DEFAULT, timeout=None, metadata=())[source]¶
將文件分類到不同的類別。
- 引數:
document (dict | google.cloud.language_v1.types.Document) – 輸入文件。如果提供字典,其形式必須與 protobuf 訊息 Document 相同
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 用於重試請求的重試物件。如果指定 None,則不會重試請求。
timeout (float | None) – 等待請求完成的時間,以秒為單位。請注意,如果指定了 retry,則超時應用於每次單獨的嘗試。
metadata (collections.abc.Sequence[tuple[str, str]]) – 提供給方法的額外元資料。