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]]) – 提供给方法的额外元数据。