airflow.providers.google.cloud.hooks.natural_language
¶
此模組包含 Google Cloud Natural Language Hook。
模組內容¶
類別¶
Google Cloud Natural Language 服務的 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 服務的 Hook。
- 參數
gcp_conn_id (str) – 用於取得連線資訊時使用的連線 ID。
impersonation_chain (str | collections.abc.Sequence[str] | None) – 可選的服務帳戶,用於模擬身分以使用短期憑證,或是取得列表中最後一個帳戶的 access_token 所需的鏈式帳戶列表,該帳戶將在請求中被模擬。如果設定為字串,則該帳戶必須授予原始帳戶「服務帳戶權杖建立者」IAM 角色。如果設定為序列,則列表中的身分必須將「服務帳戶權杖建立者」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) – 輸入文件。如果提供 dict,則其格式必須與 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) – 等待請求完成的時間量(以秒為單位)。請注意,如果指定了重試,則逾時適用於每個個別嘗試。
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) – 輸入文件。如果提供 dict,則其格式必須與 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) – 等待請求完成的時間量(以秒為單位)。請注意,如果指定了重試,則逾時適用於每個個別嘗試。
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) – 輸入文件。如果提供 dict,則其格式必須與 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) – 等待請求完成的時間量(以秒為單位)。請注意,如果指定了重試,則逾時適用於每個個別嘗試。
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) – 輸入文件。如果提供 dict,則其格式必須與 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) – 等待請求完成的時間量(以秒為單位)。請注意,如果指定了重試,則逾時適用於每個個別嘗試。
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) – 輸入文件。如果提供 dict,則其格式必須與 protobuf 訊息 Document 相同
features (dict | google.cloud.language_v1.types.AnnotateTextRequest.Features) – 已啟用的功能。如果提供 dict,則其格式必須與 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) – 等待請求完成的時間量(以秒為單位)。請注意,如果指定了重試,則逾時適用於每個個別嘗試。
metadata (collections.abc.Sequence[tuple[str, str]]) – 提供給方法的其他元數據。
- classify_text(document, retry=DEFAULT, timeout=None, metadata=())[source]¶
將文件分類到各種類別中。
- 參數
document (dict | google.cloud.language_v1.types.Document) – 輸入文件。如果提供 dict,則其格式必須與 protobuf 訊息 Document 相同
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – 用於重試請求的重試物件。如果未指定 None,則不會重試請求。
timeout (float | None) – 等待請求完成的時間量(以秒為單位)。請注意,如果指定了重試,則逾時適用於每個個別嘗試。
metadata (collections.abc.Sequence[tuple[str, str]]) – 提供給方法的其他元數據。