데이터 세트 만들기 및 관리

데이터 세트에는 출발어와 도착어의 대응하는 문장 쌍으로 번역할 콘텐츠 유형의 대표 샘플이 들어 있습니다. 데이터세트는 모델 학습을 위한 입력으로 사용됩니다.

데이터세트 구축을 위한 주요 단계는 다음과 같습니다.

  1. 데이터세트를 만들고 출발어와 도착어를 지정합니다.
  2. 문장 쌍을 데이트세트로 가져옵니다.

프로젝트에는 서로 다른 모델의 학습에 사용하는 여러 개의 데이터 세트가 있을 수 있습니다. 사용 가능한 데이터 세트 목록을 가져와 더 이상 필요 없는 데이터 세트를 삭제할 수 있습니다.

데이터 세트 만들기

커스텀 모델을 생성하는 첫 단계는 모델 학습용 데이터를 저장할 비어 있는 데이터세트를 만드는 것입니다. 데이터 세트를 만들 때 모델의 출발어와 도착어를 지정합니다. 지원되는 언어 및 변형에 대한 자세한 내용은 커스텀 모델에 대한 언어 지원을 참조하세요.

웹 UI

AutoML Translation UI를 사용하면 새 데이터세트를 만들고 같은 페이지에서 항목을 해당 데이터세트에 가져올 수 있습니다.

  1. AutoML Translation UI로 이동합니다.

  2. 제목 표시줄 오른쪽 위의 드롭다운 목록에서 AutoML Translation을 사용 설정한 프로젝트를 선택합니다.

  3. 데이터 세트 페이지에서 데이터 세트 만들기를 클릭합니다.

    데이터 세트가 하나인 데이터 세트 페이지

  4. 데이터 세트 만들기 대화상자에서 다음을 수행합니다.

    • 데이터 세트의 이름을 입력합니다.
    • 드롭다운 목록에서 출발어와 도착어를 선택합니다. 출발어를 선택하면 사용 가능한 도착어가 표시됩니다.

    • 만들기를 클릭합니다. 가져오기 탭이 열립니다.

REST

데이터 세트 생성 요청 보내기

다음은 project.locations.datasets/create 메서드에 POST 요청을 보내는 방법을 보여줍니다. 이 예시에서는 Google Cloud CLI를 사용하는 프로젝트의 서비스 계정을 설정하기 위해 액세스 토큰을 사용합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • project-id: Google Cloud Platform 프로젝트 ID
  • dataset-name: 새 데이터 세트 이름
  • source-language-code: 'en'과 같은 ISO 639-1 코드로 번역할 언어
  • target-language-code: 'es'와 같은 ISO 639-1 코드로 번역할 언어

HTTP 메서드 및 URL:

POST https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/datasets

JSON 요청 본문:

{
    "displayName": "dataset-name",
    "translationDatasetMetadata": {
       "sourceLanguageCode": "source-language-code",
       "targetLanguageCode": "target-language-code"
     }
}

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

다음과 비슷한 JSON 응답이 표시됩니다.

{
  "name": "projects/project-number/locations/us-central1/operations/operation-id",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.automl.v1.OperationMetadata",
    "createTime": "2019-10-01T22:13:48.155710Z",
    "updateTime": "2019-10-01T22:13:48.155710Z",
    "createDatasetDetails": {}
  }
}

결과 가져오기

요청 결과를 가져오려면 operations 리소스에 GET 요청을 보내야 합니다. 아래에 이러한 요청을 보내는 방법이 나와 있습니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • operation-name: API에 대한 원래 호출의 응답으로 반환되는 작업의 이름
  • project-id: Google Cloud Platform 프로젝트 ID

HTTP 메서드 및 URL:

GET https://automl.googleapis.com/v1/operation-name

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

다음과 비슷한 JSON 응답이 표시됩니다.

{
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.automl.v1.OperationMetadata",
    "createTime": "2019-10-01T22:13:48.155710Z",
    "updateTime": "2019-10-01T22:13:52.321072Z",
    ...
  },
  "done": true,
  "response": {
    "@type": "resource-type",
    "name": "resource-name"
  }
}

Go

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Go API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import (
	"context"
	"fmt"
	"io"

	automl "cloud.google.com/go/automl/apiv1"
	"cloud.google.com/go/automl/apiv1/automlpb"
)

// translateCreateDataset creates a dataset for translate.
func translateCreateDataset(w io.Writer, projectID string, location string, datasetName string, sourceLanguageCode string, targetLanguageCode string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	// datasetName := "dataset_display_name"

	// Supported languages:
	//   https://cloud.google.com/translate/automl/docs/languages
	// sourceLanguageCode := "en"
	// targetLanguageCode := "ja"

	ctx := context.Background()
	client, err := automl.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &automlpb.CreateDatasetRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s", projectID, location),
		Dataset: &automlpb.Dataset{
			DisplayName: datasetName,
			DatasetMetadata: &automlpb.Dataset_TranslationDatasetMetadata{
				TranslationDatasetMetadata: &automlpb.TranslationDatasetMetadata{
					SourceLanguageCode: sourceLanguageCode,
					TargetLanguageCode: targetLanguageCode,
				},
			},
		},
	}

	op, err := client.CreateDataset(ctx, req)
	if err != nil {
		return fmt.Errorf("CreateDataset: %w", err)
	}
	fmt.Fprintf(w, "Processing operation name: %q\n", op.Name())

	dataset, err := op.Wait(ctx)
	if err != nil {
		return fmt.Errorf("Wait: %w", err)
	}

	fmt.Fprintf(w, "Dataset name: %v\n", dataset.GetName())

	return nil
}

Java

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Java API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.automl.v1.AutoMlClient;
import com.google.cloud.automl.v1.Dataset;
import com.google.cloud.automl.v1.LocationName;
import com.google.cloud.automl.v1.OperationMetadata;
import com.google.cloud.automl.v1.TranslationDatasetMetadata;
import java.io.IOException;
import java.util.concurrent.ExecutionException;

class TranslateCreateDataset {

  public static void main(String[] args)
      throws IOException, ExecutionException, InterruptedException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    String displayName = "YOUR_DATASET_NAME";
    createDataset(projectId, displayName);
  }

  // Create a dataset
  static void createDataset(String projectId, String displayName)
      throws IOException, ExecutionException, InterruptedException {
    // 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.
    try (AutoMlClient client = AutoMlClient.create()) {
      // A resource that represents Google Cloud Platform location.
      LocationName projectLocation = LocationName.of(projectId, "us-central1");

      // Specify the source and target language.
      TranslationDatasetMetadata translationDatasetMetadata =
          TranslationDatasetMetadata.newBuilder()
              .setSourceLanguageCode("en")
              .setTargetLanguageCode("ja")
              .build();
      Dataset dataset =
          Dataset.newBuilder()
              .setDisplayName(displayName)
              .setTranslationDatasetMetadata(translationDatasetMetadata)
              .build();
      OperationFuture<Dataset, OperationMetadata> future =
          client.createDatasetAsync(projectLocation, dataset);

      Dataset createdDataset = future.get();

      // Display the dataset information.
      System.out.format("Dataset name: %s\n", createdDataset.getName());
      // To get the dataset id, you have to parse it out of the `name` field. As dataset Ids are
      // required for other methods.
      // Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`
      String[] names = createdDataset.getName().split("/");
      String datasetId = names[names.length - 1];
      System.out.format("Dataset id: %s\n", datasetId);
    }
  }
}

Node.js

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Node.js API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'us-central1';
// const displayName = 'YOUR_DISPLAY_NAME';

// Imports the Google Cloud AutoML library
const {AutoMlClient} = require('@google-cloud/automl').v1;

// Instantiates a client
const client = new AutoMlClient();

async function createDataset() {
  // Construct request
  const request = {
    parent: client.locationPath(projectId, location),
    dataset: {
      displayName: displayName,
      translationDatasetMetadata: {
        sourceLanguageCode: 'en',
        targetLanguageCode: 'ja',
      },
    },
  };

  // Create dataset
  const [operation] = await client.createDataset(request);

  // Wait for operation to complete.
  const [response] = await operation.promise();

  console.log(`Dataset name: ${response.name}`);
  console.log(`
    Dataset id: ${
      response.name
        .split('/')
        [response.name.split('/').length - 1].split('\n')[0]
    }`);
}

createDataset();

Python

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Python API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google.cloud import automl

# TODO(developer): Uncomment and set the following variables
# project_id = "YOUR_PROJECT_ID"
# display_name = "YOUR_DATASET_NAME"

client = automl.AutoMlClient()

# A resource that represents Google Cloud Platform location.
project_location = f"projects/{project_id}/locations/us-central1"
# For a list of supported languages, see:
# https://cloud.google.com/translate/automl/docs/languages
dataset_metadata = automl.TranslationDatasetMetadata(
    source_language_code="en", target_language_code="ja"
)
dataset = automl.Dataset(
    display_name=display_name,
    translation_dataset_metadata=dataset_metadata,
)

# Create a dataset with the dataset metadata in the region.
response = client.create_dataset(parent=project_location, dataset=dataset)

created_dataset = response.result()

# Display the dataset information
print(f"Dataset name: {created_dataset.name}")
print("Dataset id: {}".format(created_dataset.name.split("/")[-1]))

추가 언어

C#: 클라이언트 라이브러리 페이지의 C# 설정 안내를 따른 후 .NET용 AutoML 번역 참조 문서를 참조하세요.

PHP: 클라이언트 라이브러리 페이지의 PHP 설정 안내를 따른 후 PHP용 AutoML 번역 참조 문서를 참조하세요.

Ruby: 클라이언트 라이브러리 페이지의 Ruby 설정 안내를 따른 다음 Ruby용 AutoML 번역 참조 문서를 참조하세요.

데이터 세트로 항목 가져오기

데이터세트를 만들었으면 이제 학습 문장 쌍을 가져올 수 있습니다. 학습 데이터 준비에 대한 자세한 내용은 학습 데이터 준비를 참조하세요.

웹 UI

AutoML Translation UI를 사용하면 새 데이터 세트를 만들고 같은 페이지에서 항목을 해당 데이터 세트에 가져올 수 있습니다. 데이터 세트 만들기를 참조하세요. 기존 데이터 세트로 항목을 가져오려면 다음 단계를 따르세요.

데이터 세트 폴더를 만든 후 데이터를 업로드합니다.

  1. 모델 학습에 사용할 문장 쌍을 업로드합니다.

    가져오기 탭에서 로컬 컴퓨터 또는 Cloud Storage에서 TSV 또는 TMX 파일을 업로드할 수 있습니다. 로컬에서 가져온 파일의 경우 파일을 선택한 후 찾아보기를 클릭합니다. 폴더 목록이 표시됩니다. 파일을 업로드할 폴더를 선택합니다. Cloud Storage에서 호스팅되는 이 디렉터리는 데이터 보존을 보장하는 데 필요합니다.

    문장 쌍이 포함된 여러 개별 파일을 업로드하려면 학습, 유효성 검사, 테스트에 별도의 파일 사용(Advanced) 체크박스를 선택합니다. 데이터 세트에 100,000개가 넘는 문장 쌍이 있는 경우 이 옵션을 사용하는 것이 좋습니다. 유효성 검사 및 테스트 세트에 10,000개 이하의 문장 쌍을 할당해야 합니다. 그렇지 않으면 AutoML Translation이 오류를 반환합니다.

    가져오기 탭

  2. 계속을 클릭합니다.

    데이터 세트 페이지로 돌아갑니다. 문서를 가져오는 동안 데이터 세트에 진행률 애니메이션이 표시됩니다. 데이터 세트가 정상적으로 업로드되면 프로그램에 가입할 때 사용한 이메일 주소로 메시지가 발송됩니다.

  3. 데이터 세트를 검토합니다.

    데이터를 정상적으로 가져왔으면 데이터 세트 탭에서 데이터 세트를 선택하여 데이터 세트의 세부정보를 확인합니다. 문장 탭이 사용 설정되고 데이터 세트의 이름이 표시됩니다. 문장 쌍이 나열됩니다. 각 쌍에는 '학습', '유효성 검사' 또는 '테스트'가 할당되며, 각 단계는 해당 쌍이 사용되는 처리 단계를 나타냅니다.

REST

projects.locations.datasets.importData 메서드를 사용하여 항목을 데이터 세트로 가져옵니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • dataset-name: 데이터 세트를 만들 때 API에서 반환한 데이터 세트의 이름
  • bucket-name: 데이터 세트를 설명하는 입력 CSV가 포함된 Cloud Storage 버킷
  • csv-file-name: 데이터 세트를 설명하는 입력 CSV 파일의 이름
  • project-id: Google Cloud Platform 프로젝트 ID

HTTP 메서드 및 URL:

POST https://automl.googleapis.com/v1/dataset-name:importData

JSON 요청 본문:

{
  "inputConfig": {
    "gcsSource": {
      "inputUris": "gs://bucket-name/csv-file-name"
    }
  }
}

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

다음과 비슷한 JSON 응답이 표시됩니다.

{
  "name": "projects/project-number/locations/us-central1/operations/operation-id",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.automl.v1beta1.OperationMetadata",
    "createTime": "2018-04-27T01:28:36.128120Z",
    "updateTime": "2018-04-27T01:28:36.128150Z",
    "cancellable": true
  }
}

Go

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Go API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import (
	"context"
	"fmt"
	"io"

	automl "cloud.google.com/go/automl/apiv1"
	"cloud.google.com/go/automl/apiv1/automlpb"
)

// importDataIntoDataset imports data into a dataset.
func importDataIntoDataset(w io.Writer, projectID string, location string, datasetID string, inputURI string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	// datasetID := "TRL123456789..."
	// inputURI := "gs://BUCKET_ID/path_to_training_data.csv"

	ctx := context.Background()
	client, err := automl.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &automlpb.ImportDataRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/datasets/%s", projectID, location, datasetID),
		InputConfig: &automlpb.InputConfig{
			Source: &automlpb.InputConfig_GcsSource{
				GcsSource: &automlpb.GcsSource{
					InputUris: []string{inputURI},
				},
			},
		},
	}

	op, err := client.ImportData(ctx, req)
	if err != nil {
		return fmt.Errorf("ImportData: %w", err)
	}
	fmt.Fprintf(w, "Processing operation name: %q\n", op.Name())

	if err := op.Wait(ctx); err != nil {
		return fmt.Errorf("Wait: %w", err)
	}

	fmt.Fprintf(w, "Data imported.\n")

	return nil
}

Java

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Java API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.automl.v1.AutoMlClient;
import com.google.cloud.automl.v1.DatasetName;
import com.google.cloud.automl.v1.GcsSource;
import com.google.cloud.automl.v1.InputConfig;
import com.google.cloud.automl.v1.OperationMetadata;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

class ImportDataset {

  public static void main(String[] args)
      throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    String datasetId = "YOUR_DATASET_ID";
    String path = "gs://BUCKET_ID/path_to_training_data.csv";
    importDataset(projectId, datasetId, path);
  }

  // Import a dataset
  static void importDataset(String projectId, String datasetId, String path)
      throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // 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.
    try (AutoMlClient client = AutoMlClient.create()) {
      // Get the complete path of the dataset.
      DatasetName datasetFullId = DatasetName.of(projectId, "us-central1", datasetId);

      // Get multiple Google Cloud Storage URIs to import data from
      GcsSource gcsSource =
          GcsSource.newBuilder().addAllInputUris(Arrays.asList(path.split(","))).build();

      // Import data from the input URI
      InputConfig inputConfig = InputConfig.newBuilder().setGcsSource(gcsSource).build();
      System.out.println("Processing import...");

      // Start the import job
      OperationFuture<Empty, OperationMetadata> operation =
          client.importDataAsync(datasetFullId, inputConfig);

      System.out.format("Operation name: %s%n", operation.getName());

      // If you want to wait for the operation to finish, adjust the timeout appropriately. The
      // operation will still run if you choose not to wait for it to complete. You can check the
      // status of your operation using the operation's name.
      Empty response = operation.get(45, TimeUnit.MINUTES);
      System.out.format("Dataset imported. %s%n", response);
    } catch (TimeoutException e) {
      System.out.println("The operation's polling period was not long enough.");
      System.out.println("You can use the Operation's name to get the current status.");
      System.out.println("The import job is still running and will complete as expected.");
      throw e;
    }
  }
}

Node.js

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Node.js API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'us-central1';
// const datasetId = 'YOUR_DISPLAY_ID';
// const path = 'gs://BUCKET_ID/path_to_training_data.csv';

// Imports the Google Cloud AutoML library
const {AutoMlClient} = require('@google-cloud/automl').v1;

// Instantiates a client
const client = new AutoMlClient();

async function importDataset() {
  // Construct request
  const request = {
    name: client.datasetPath(projectId, location, datasetId),
    inputConfig: {
      gcsSource: {
        inputUris: path.split(','),
      },
    },
  };

  // Import dataset
  console.log('Proccessing import');
  const [operation] = await client.importData(request);

  // Wait for operation to complete.
  const [response] = await operation.promise();
  console.log(`Dataset imported: ${response}`);
}

importDataset();

Python

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Python API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google.cloud import automl

# TODO(developer): Uncomment and set the following variables
# project_id = "YOUR_PROJECT_ID"
# dataset_id = "YOUR_DATASET_ID"
# path = "gs://YOUR_BUCKET_ID/path/to/data.csv"

client = automl.AutoMlClient()
# Get the full path of the dataset.
dataset_full_id = client.dataset_path(project_id, "us-central1", dataset_id)
# Get the multiple Google Cloud Storage URIs
input_uris = path.split(",")
gcs_source = automl.GcsSource(input_uris=input_uris)
input_config = automl.InputConfig(gcs_source=gcs_source)
# Import data from the input URI
response = client.import_data(name=dataset_full_id, input_config=input_config)

print("Processing import...")
print(f"Data imported. {response.result()}")

추가 언어

C#: 클라이언트 라이브러리 페이지의 C# 설정 안내를 따른 후 .NET용 AutoML 번역 참조 문서를 참조하세요.

PHP: 클라이언트 라이브러리 페이지의 PHP 설정 안내를 따른 후 PHP용 AutoML 번역 참조 문서를 참조하세요.

Ruby: 클라이언트 라이브러리 페이지의 Ruby 설정 안내를 따른 다음 Ruby용 AutoML 번역 참조 문서를 참조하세요.

데이터 세트를 만들고 값을 채웠으면 모델을 학습할 수 있습니다. 모델 만들기 및 관리를 참조하세요.

데이터 세트 관리

데이터 세트 나열

프로젝트에는 수많은 데이터 세트가 포함될 수 있습니다. 이 섹션에서는 프로젝트에 사용할 수 있는 데이터세트의 목록을 검색하는 방법에 대해 설명합니다.

웹 UI

AutoML Translation UI에서 사용할 수 있는 데이터 세트 목록을 확인하려면 왼쪽 탐색 메뉴 맨 위에 있는 데이터 세트 링크를 클릭합니다.

데이터 세트가 하나인 데이터 세트 페이지

다른 프로젝트의 데이터 세트를 보려면 제목 표시줄 오른쪽 위에 있는 드롭다운 목록에서 프로젝트를 선택하세요.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • project-id: Google Cloud Platform 프로젝트 ID

HTTP 메서드 및 URL:

GET https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/datasets

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

다음과 비슷한 JSON 응답이 표시됩니다.

{
  "datasets": [
    {
      "name": "projects/project-number/locations/us-central1/datasets/dataset-id",
      "displayName": "dataset-display-name",
      "createTime": "2019-10-01T22:47:38.347689Z",
      "etag": "AB3BwFpPWn6klFqJ867nz98aXr_JHcfYFQBMYTf7rcO-JMi8Ez4iDSNrRW4Vv501i488",
      "translationDatasetMetadata": {
        "sourceLanguageCode": "source-language",
        "targetLanguageCode": "target-language"
      }
    },
    ...
  ]
}

Go

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Go API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import (
	"context"
	"fmt"
	"io"

	automl "cloud.google.com/go/automl/apiv1"
	"cloud.google.com/go/automl/apiv1/automlpb"
	"google.golang.org/api/iterator"
)

// listDatasets lists existing datasets.
func listDatasets(w io.Writer, projectID string, location string) error {
	// projectID := "my-project-id"
	// location := "us-central1"

	ctx := context.Background()
	client, err := automl.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &automlpb.ListDatasetsRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s", projectID, location),
	}

	it := client.ListDatasets(ctx, req)

	// Iterate over all results
	for {
		dataset, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("ListGlossaries.Next: %w", err)
		}

		fmt.Fprintf(w, "Dataset name: %v\n", dataset.GetName())
		fmt.Fprintf(w, "Dataset display name: %v\n", dataset.GetDisplayName())
		fmt.Fprintf(w, "Dataset create time:\n")
		fmt.Fprintf(w, "\tseconds: %v\n", dataset.GetCreateTime().GetSeconds())
		fmt.Fprintf(w, "\tnanos: %v\n", dataset.GetCreateTime().GetNanos())

		// Translate
		if metadata := dataset.GetTranslationDatasetMetadata(); metadata != nil {
			fmt.Fprintf(w, "Translation dataset metadata:\n")
			fmt.Fprintf(w, "\tsource_language_code: %v\n", metadata.GetSourceLanguageCode())
			fmt.Fprintf(w, "\ttarget_language_code: %v\n", metadata.GetTargetLanguageCode())
		}

	}

	return nil
}

Java

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Java API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import com.google.cloud.automl.v1.AutoMlClient;
import com.google.cloud.automl.v1.Dataset;
import com.google.cloud.automl.v1.ListDatasetsRequest;
import com.google.cloud.automl.v1.LocationName;
import java.io.IOException;

class ListDatasets {

  static void listDatasets() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    listDatasets(projectId);
  }

  // List the datasets
  static void listDatasets(String projectId) throws IOException {
    // 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.
    try (AutoMlClient client = AutoMlClient.create()) {
      // A resource that represents Google Cloud Platform location.
      LocationName projectLocation = LocationName.of(projectId, "us-central1");
      ListDatasetsRequest request =
          ListDatasetsRequest.newBuilder().setParent(projectLocation.toString()).build();

      // List all the datasets available in the region by applying filter.
      System.out.println("List of datasets:");
      for (Dataset dataset : client.listDatasets(request).iterateAll()) {
        // Display the dataset information
        System.out.format("\nDataset name: %s\n", dataset.getName());
        // To get the dataset id, you have to parse it out of the `name` field. As dataset Ids are
        // required for other methods.
        // Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`
        String[] names = dataset.getName().split("/");
        String retrievedDatasetId = names[names.length - 1];
        System.out.format("Dataset id: %s\n", retrievedDatasetId);
        System.out.format("Dataset display name: %s\n", dataset.getDisplayName());
        System.out.println("Dataset create time:");
        System.out.format("\tseconds: %s\n", dataset.getCreateTime().getSeconds());
        System.out.format("\tnanos: %s\n", dataset.getCreateTime().getNanos());
        System.out.println("Translation dataset metadata:");
        System.out.format(
            "\tSource language code: %s\n",
            dataset.getTranslationDatasetMetadata().getSourceLanguageCode());
        System.out.format(
            "\tTarget language code: %s\n",
            dataset.getTranslationDatasetMetadata().getTargetLanguageCode());
      }
    }
  }
}

Node.js

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Node.js API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'us-central1';

// Imports the Google Cloud AutoML library
const {AutoMlClient} = require('@google-cloud/automl').v1;

// Instantiates a client
const client = new AutoMlClient();

async function listDatasets() {
  // Construct request
  const request = {
    parent: client.locationPath(projectId, location),
    filter: 'translation_dataset_metadata:*',
  };

  const [response] = await client.listDatasets(request);

  console.log('List of datasets:');
  for (const dataset of response) {
    console.log(`Dataset name: ${dataset.name}`);
    console.log(
      `Dataset id: ${
        dataset.name.split('/')[dataset.name.split('/').length - 1]
      }`
    );
    console.log(`Dataset display name: ${dataset.displayName}`);
    console.log('Dataset create time');
    console.log(`\tseconds ${dataset.createTime.seconds}`);
    console.log(`\tnanos ${dataset.createTime.nanos / 1e9}`);
    if (dataset.translationDatasetMetadata !== undefined) {
      console.log('Translation dataset metadata:');
      console.log(
        `\tSource language code: ${dataset.translationDatasetMetadata.sourceLanguageCode}`
      );
      console.log(
        `\tTarget language code: ${dataset.translationDatasetMetadata.targetLanguageCode}`
      );
    }
  }
}

listDatasets();

Python

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Python API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google.cloud import automl

# TODO(developer): Uncomment and set the following variables
# project_id = "YOUR_PROJECT_ID"

client = automl.AutoMlClient()
# A resource that represents Google Cloud Platform location.
project_location = f"projects/{project_id}/locations/us-central1"

# List all the datasets available in the region.
request = automl.ListDatasetsRequest(parent=project_location, filter="")
response = client.list_datasets(request=request)

print("List of datasets:")
for dataset in response:
    print(f"Dataset name: {dataset.name}")
    print("Dataset id: {}".format(dataset.name.split("/")[-1]))
    print(f"Dataset display name: {dataset.display_name}")
    print(f"Dataset create time: {dataset.create_time}")
    print("Translation dataset metadata:")
    print(
        "\tsource_language_code: {}".format(
            dataset.translation_dataset_metadata.source_language_code
        )
    )
    print(
        "\ttarget_language_code: {}".format(
            dataset.translation_dataset_metadata.target_language_code
        )
    )

추가 언어

C#: 클라이언트 라이브러리 페이지의 C# 설정 안내를 따른 후 .NET용 AutoML 번역 참조 문서를 참조하세요.

PHP: 클라이언트 라이브러리 페이지의 PHP 설정 안내를 따른 후 PHP용 AutoML 번역 참조 문서를 참조하세요.

Ruby: 클라이언트 라이브러리 페이지의 Ruby 설정 안내를 따른 다음 Ruby용 AutoML 번역 참조 문서를 참조하세요.

데이터 세트 삭제

웹 UI

  1. AutoML Translation UI의 왼쪽 탐색 메뉴 맨 위에 있는 데이터 세트 링크를 클릭하여 사용 가능한 데이터 세트 목록을 표시합니다.

    데이터 세트가 하나인 데이터 세트 페이지

  2. 삭제하려는 행의 맨 오른쪽에 있는 점 3개로 된 메뉴를 클릭하고 삭제를 선택합니다.

  3. 확인 대화상자에서 확인을 클릭합니다.

REST

  • 데이터 세트를 만들 때 응답에서 dataset-name을 데이터 세트의 전체 이름으로 바꿉니다. 전체 이름은 projects/{project-id}/locations/us-central1/datasets/{dataset-id} 형식입니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • dataset-name: 삭제할 데이터 세트의 이름(project/project-id/locations/us-central1/datasets/dataset-id 형식)

HTTP 메서드 및 URL:

DELETE https://automl.googleapis.com/v1/dataset-name

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

다음과 비슷한 JSON 응답이 표시됩니다.

{
  "name": "projects/project-number/locations/us-central1/operations/operation-id",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.automl.v1.OperationMetadata",
    "createTime": "2019-10-02T16:43:03.923442Z",
    "updateTime": "2019-10-02T16:43:03.923442Z",
    "deleteDetails": {}
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.protobuf.Empty"
  }
}

Go

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Go API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import (
	"context"
	"fmt"
	"io"

	automl "cloud.google.com/go/automl/apiv1"
	"cloud.google.com/go/automl/apiv1/automlpb"
)

// deleteDataset deletes a dataset.
func deleteDataset(w io.Writer, projectID string, location string, datasetID string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	// datasetID := "TRL123456789..."

	ctx := context.Background()
	client, err := automl.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &automlpb.DeleteDatasetRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/datasets/%s", projectID, location, datasetID),
	}

	op, err := client.DeleteDataset(ctx, req)
	if err != nil {
		return fmt.Errorf("DeleteDataset: %w", err)
	}
	fmt.Fprintf(w, "Processing operation name: %q\n", op.Name())

	if err := op.Wait(ctx); err != nil {
		return fmt.Errorf("Wait: %w", err)
	}

	fmt.Fprintf(w, "Dataset deleted.\n")

	return nil
}

Java

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Java API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import com.google.cloud.automl.v1.AutoMlClient;
import com.google.cloud.automl.v1.DatasetName;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.util.concurrent.ExecutionException;

class DeleteDataset {

  static void deleteDataset() throws IOException, ExecutionException, InterruptedException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    String datasetId = "YOUR_DATASET_ID";
    deleteDataset(projectId, datasetId);
  }

  // Delete a dataset
  static void deleteDataset(String projectId, String datasetId)
      throws IOException, ExecutionException, InterruptedException {
    // 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.
    try (AutoMlClient client = AutoMlClient.create()) {
      // Get the full path of the dataset.
      DatasetName datasetFullId = DatasetName.of(projectId, "us-central1", datasetId);
      Empty response = client.deleteDatasetAsync(datasetFullId).get();
      System.out.format("Dataset deleted. %s\n", response);
    }
  }
}

Node.js

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Node.js API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'us-central1';
// const datasetId = 'YOUR_DATASET_ID';

// Imports the Google Cloud AutoML library
const {AutoMlClient} = require('@google-cloud/automl').v1;

// Instantiates a client
const client = new AutoMlClient();

async function deleteDataset() {
  // Construct request
  const request = {
    name: client.datasetPath(projectId, location, datasetId),
  };

  const [operation] = await client.deleteDataset(request);

  // Wait for operation to complete.
  const [response] = await operation.promise();
  console.log(`Dataset deleted: ${response}`);
}

deleteDataset();

Python

AutoML Translation용 클라이언트 라이브러리를 설치하고 사용하는 방법은 AutoML Translation 클라이언트 라이브러리를 참조하세요. 자세한 내용은 AutoML Translation Python API 참조 문서를 확인하세요.

AutoML Translation에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google.cloud import automl

# TODO(developer): Uncomment and set the following variables
# project_id = "YOUR_PROJECT_ID"
# dataset_id = "YOUR_DATASET_ID"

client = automl.AutoMlClient()
# Get the full path of the dataset
dataset_full_id = client.dataset_path(project_id, "us-central1", dataset_id)
response = client.delete_dataset(name=dataset_full_id)

print(f"Dataset deleted. {response.result()}")

추가 언어

C#: 클라이언트 라이브러리 페이지의 C# 설정 안내를 따른 후 .NET용 AutoML 번역 참조 문서를 참조하세요.

PHP: 클라이언트 라이브러리 페이지의 PHP 설정 안내를 따른 후 PHP용 AutoML 번역 참조 문서를 참조하세요.

Ruby: 클라이언트 라이브러리 페이지의 Ruby 설정 안내를 따른 다음 Ruby용 AutoML 번역 참조 문서를 참조하세요.

가져오기 문제

데이터 세트를 만들 때 문장 쌍이 너무 길거나 출발어와 도착어에서 쌍이 정확하게 동일한 경우 AutoML Translation에서 문장 쌍이 삭제될 수 있습니다.

문장 쌍이 너무 긴 경우 문장을 약 200단어 이하로 분할한 다음 분할된 쌍을 포함하도록 데이터 세트를 다시 만드는 것이 좋습니다. 데이터를 처리하는 동안 AutoML Translation은 내부 프로세스를 사용하여 입력 데이터를 토큰화하므로 문장의 크기를 늘릴 수 있습니다. 이 토큰화된 데이터는 AutoML Translation이 데이터 크기를 측정하는 데 사용하는 데이터입니다. 따라서 200단어 제한은 최대 길이의 추정치입니다.

출발어와 도착어가 동일한 문장 쌍의 경우 데이터 세트에서 삭제할 수 있습니다. 이러한 문장을 번역하지 않으려면 용어집 리소스를 사용하여 AutoML Translation이 특정 용어를 처리하는 방식을 정의하는 커스텀 사전을 빌드하세요.