位置

使用集合让一切井井有条 根据您的偏好保存内容并对其进行分类。

借助 Cloud Natural Language,您可以控制存储和处理项目资源的位置。具体来说,您可以将 Cloud Natural Language 配置为仅在欧盟或美国存储您的静态数据以及对您的数据执行机器学习。

默认情况下,Cloud Natural Language 在全球位置存储和处理资源,这意味着 Cloud Natural Language 不保证您的资源将保留在特定的位置或区域内。如果您选择欧盟位置,则 Google 只会在欧盟存储您的数据以及对其执行机器学习。如果您选择美国位置,则 Google 只会在美国存储您的数据以及对其执行机器学习。您和您的用户可以从任意位置访问该数据。

使用 API 设置位置

Cloud Natural Language API 支持全球 API 端点 (language.googleapis.com)、欧盟端点 (eu-language.googleapis.com)、美国端点 (us-language.googleapis.com)。如需仅在欧盟存储和处理您的数据,请在 REST API 调用中使用 URI eu-language.googleapis.com(而不是 language.googleapis.com)。如需仅在美国存储和处理您的数据,请在 REST API 调用中使用 URI us-language.googleapis.com(而不是 language.googleapis.com)。

使用客户端库设置位置

默认情况下,客户端库会访问全球 API 端点 (language.googleapis.com)。如需仅在欧盟或美国存储和处理您的数据,您需要明确设置相应端点。以下代码示例展示了如何配置此设置。

Python

# Imports the Google Cloud client library
from google.cloud import language_v1

client_options = {"api_endpoint": "eu-language.googleapis.com:443"}

# Instantiates a client
client = language_v1.LanguageServiceClient(client_options=client_options)

Java

LanguageServiceSettings settings =
    LanguageServiceSettings.newBuilder().setEndpoint("eu-language.googleapis.com:443").build();

// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests. After completing all of your requests, call
// the "close" method on the client to safely clean up any remaining background resources.
LanguageServiceClient client = LanguageServiceClient.create(settings);

Node.js

// Imports the Google Cloud client library
const language = require('@google-cloud/language');

// Specifies the location of the api endpoint
const clientOptions = {apiEndpoint: 'eu-language.googleapis.com'};

// Instantiates a client
const client = new language.LanguageServiceClient(clientOptions);