122
Amazon Translate 開発者ガイド

Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate開発者ガイド

Page 2: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド

Amazon Translate: 開発者ガイドCopyright © 2020 Amazon Web Services, Inc. and/or its affiliates. All rights reserved.

Amazon's trademarks and trade dress may not be used in connection with any product or service that is not Amazon's,in any manner that is likely to cause confusion among customers, or in any manner that disparages or discreditsAmazon. All other trademarks not owned by Amazon are the property of their respective owners, who may or may notbe affiliated with, connected to, or sponsored by Amazon.

Page 3: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド

Table of ContentsAmazon Translate とは ....................................................................................................................... 1

サポートされている言語と言語コード ............................................................................................ 1ユースケース ............................................................................................................................. 3初めて使用する方 ....................................................................................................................... 3Amazon Translate 料金表 ............................................................................................................ 4

仕組み ............................................................................................................................................... 5言語の自動検出 .......................................................................................................................... 5例外処理 .................................................................................................................................... 5次のステップ ............................................................................................................................. 6

開始方法 ............................................................................................................................................ 7ステップ 1: アカウントを設定する ................................................................................................ 7

AWS にサインアップする .................................................................................................... 7IAM ユーザーを作成する ...................................................................................................... 7次のステップ ..................................................................................................................... 8

ステップ 2: AWS CLI をセットアップする ..................................................................................... 8次のステップ ..................................................................................................................... 9

ステップ 3: 開始方法 (コンソール) ................................................................................................ 9次のステップ .................................................................................................................... 10

ステップ 4: 使用開始 (AWS CLI) ................................................................................................. 10コマンドラインを使用したテキストの翻訳 ............................................................................ 11JSON ファイルを使用したテキストの翻訳 ............................................................................ 11次のステップ .................................................................................................................... 12

ステップ 5: 開始方法 (SDK) ....................................................................................................... 12SDK for Java の使用 ......................................................................................................... 12AWS SDK for Python の使用 .............................................................................................. 13Mobile SDK for Android の使用 ........................................................................................... 15Mobile SDK for iOS の使用 ................................................................................................ 16

カスタム用語 .................................................................................................................................... 19動作の仕組み ............................................................................................................................ 19カスタム用語の作成 .................................................................................................................. 19

対応言語 .......................................................................................................................... 20カスタム用語の使用 .................................................................................................................. 21用語の暗号化 ............................................................................................................................ 22ベストプラクティス .................................................................................................................. 22

例 ................................................................................................................................................... 23Amazon Polly を Amazon Translate に使用する ............................................................................ 23

コード ............................................................................................................................. 24Amazon Translate を使用してチャットチャネルを翻訳する ............................................................. 27Amazon Translate を DynamoDB に使用する ................................................................................ 35

コード例 .......................................................................................................................... 36Amazon Translate を使用したウェブページの翻訳 ......................................................................... 38Amazon Translate を使用して大きいドキュメントを翻訳する .......................................................... 41Amazon Translate で署名バージョン 4 を使用する ........................................................................ 43

セットアップ .................................................................................................................... 43コード ............................................................................................................................. 44

セキュリティ .................................................................................................................................... 47データ保護 ............................................................................................................................... 47

保管時の暗号化 ................................................................................................................. 48キーの管理 ....................................................................................................................... 48

Identity and Access Management ................................................................................................ 48対象者 ............................................................................................................................. 49アイデンティティを使用した認証 ........................................................................................ 49ポリシーを使用したアクセスの管理 ..................................................................................... 51Amazon Translate と IAM の連携 ........................................................................................ 52

iii

Page 4: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド

アイデンティティベースのポリシーの例 ............................................................................... 54ユーザーに自分のアクセス許可の表示を許可 ......................................................................... 57トラブルシューティング .................................................................................................... 58Amazon Translate API の権限リファレンス .......................................................................... 60

モニタリング ............................................................................................................................ 60CloudWatch によるモニタリング ......................................................................................... 62AWS CloudTrail を使用した Amazon Translate API コールのログ作成 ...................................... 63Amazon Translate の CloudWatch メトリクスとディメンション .............................................. 65

コンプライアンス検証 ............................................................................................................... 66耐障害性 .................................................................................................................................. 67インフラストラクチャセキュリティ ............................................................................................. 67

ガイドラインと制限 .......................................................................................................................... 68サポートされている AWS リージョン .......................................................................................... 68コンプライアンス ...................................................................................................................... 68スロットリング ......................................................................................................................... 68ガイドライン ............................................................................................................................ 68サービス制限 ............................................................................................................................ 68

ドキュメント履歴 .............................................................................................................................. 70API リファレンス .............................................................................................................................. 74

HTTP ヘッダー ......................................................................................................................... 74Actions .................................................................................................................................... 74

DeleteTerminology ............................................................................................................ 75DescribeTextTranslationJob ................................................................................................ 77GetTerminology ................................................................................................................ 79ImportTerminology ............................................................................................................. 82ListTerminologies .............................................................................................................. 85ListTextTranslationJobs ...................................................................................................... 88StartTextTranslationJob ...................................................................................................... 91StopTextTranslationJob ...................................................................................................... 95TranslateText ................................................................................................................... 97

Data Types ............................................................................................................................ 100AppliedTerminology ......................................................................................................... 101EncryptionKey ................................................................................................................. 102InputDataConfig .............................................................................................................. 103JobDetails ...................................................................................................................... 104OutputDataConfig ............................................................................................................ 105Term ............................................................................................................................. 106TerminologyData ............................................................................................................. 107TerminologyDataLocation ................................................................................................. 108TerminologyProperties ...................................................................................................... 109TextTranslationJobFilter .................................................................................................... 111TextTranslationJobProperties ............................................................................................ 112

Common Errors ...................................................................................................................... 114Common Parameters ............................................................................................................... 115

AWS の用語集 ................................................................................................................................ 118

iv

Page 5: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドサポートされている言語と言語コード

Amazon Translate とはAmazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテキスト翻訳サービスです。Amazon Translate を使用して非構造化テキストドキュメントを翻訳したり、複数の言語で動作するアプリケーションを構築したりできます。

サポートされている言語と言語コードAmazon Translate は、ソース言語 (入力言語) とターゲット言語 (出力言語) 間の翻訳を提供します。ソース言語とターゲット言語の組み合わせは、言語ペアと呼ばれます。

Amazon Translate は、次の表にリストされている言語間でテキストを翻訳できます (以下に示すいくつかの例外があります)。

言語 言語コード

アフリカーンス語 af

アルバニア語 sq

アムハラ語 am

アラビア語 ar

アゼルバイジャン語 az

ベンガル語 bn

ボスニア語 bs

ブルガリア語 bg

簡体字中国語 zh

繁体字中国語 zh-TW

クロアチア語 hr

チェコ語 cs

デンマーク語 da

ダリ語 fa-AF

オランダ語 nl

英語 en

エストニア語 et

フィンランド語 fi

フランス語 fr

フランス語 (カナダ) fr-CA

グルジア語 ka

1

Page 6: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドサポートされている言語と言語コード

言語 言語コード

ドイツ語 de

ギリシャ語 el

ハウサ語 ha

ヘブライ語 he

ヒンディー語 hi

ハンガリー語 hu

インドネシア語 id

イタリア語 it

日本語 ja

韓国語 ko

ラトビア語 lv

マレー語 ms

ノルウェー語 no

ペルシャ語 fa

パシュト語 ps

ポーランド語 pl

ポルトガル語 pt

ルーマニア語 ro

ロシア語 ru

セルビア語 sr

スロバキア語 sk

スロベニア語 sl

ソマリ語 、

スペイン語 es

スワヒリ語 sw

スウェーデン語 sv

タガログ語 tl

タミル語 ta

タイ語 th

トルコ語 tr

ウクライナ語 uk

2

Page 7: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドユースケース

言語 言語コード

ウルドゥー語 ur

ベトナム語 vi

Amazon Translate は、次の言語ペア間でテキストを翻訳することはできません。

• 簡体字中国語から繁体字中国語• 繁体字中国語から簡体字中国語• フランス語 (カナダ) から任意の言語• 韓国語からヘブライ語• ノルウェー語からアラビア語• ノルウェー語からヘブライ語

ユースケースAmazon Translate を使用して以下を行います。

Amazon Translate を統合して、アプリケーションで複数言語のユーザーエクスペリエンスを有効にする:• ミーティングメモ、技術者によるレポート、ナレッジベースの記事、投稿など、社内で作成したコ

ンテンツを翻訳できます。• メール、ゲーム内チャット、カスタマーサービスなど、対人コミュニケーションを翻訳できるの

で、顧客と社員のニーズに合わせた言語で連絡を交わすことができます。会社の受信データを処理および管理できます。

• ソーシャルメディア、ニュースフィードなどのテキストをさまざまな言語で分析できます。• eDiscovery のケースなど、さまざまな言語で情報を検索できます。

Amazon Translate を他の AWS のサービスと統合して、言語に依存しない処理を可能にします。• Amazon Comprehend で、ソーシャルメディアストリームなどの非構造化テキストから、名前付き

エンティティ、感情、キーフレーズを抽出します。• Amazon Transcribe で、さまざまな言語で字幕やライブキャプションを作成します。• Amazon Polly を使用して、翻訳されたコンテンツを読み上げます。• Amazon S3 に保存されているドキュメントレポジトリを翻訳します。• Amazon DynamoDB、Amazon Aurora、および Amazon Redshift の各データベースに保存されてい

るテキストを翻訳します。• AWS Lambda または AWS Glue を使用してワークフローをシームレスに統合します。

Amazon Translate を初めてお使いになる方向けの情報

初めて使用する方には、次のセクションを順に読むことをお勧めします。

1. Amazon Translate の詳細 (p. 5) – Amazon Translate について説明します。2. Amazon Translate の使用開始 (p. 7) – AWS アカウントを設定し、Amazon Translate の使用を開始

する方法について説明します。3. 例 (p. 23) – Java と Python のコード例を提供します。例を使用して、Amazon Translate の機能を探

求してください。

3

Page 8: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate 料金表

4. API リファレンス (p. 74) – Amazon Translate オペレーションのリファレンスドキュメントが含まれています。

Amazon Translate 料金表他の AWS 製品と同様、Amazon Translate を使用するための契約や最低契約金は必要ありません。Amazon Translate の使用料金の詳細については、Amazon Translate 料金表を参照してください。

4

Page 9: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド言語の自動検出

Amazon Translate の詳細この Amazon Translate サービスは、言語翻訳のトレーニングを受けたニューラルネットワークに基づいています。これにより、ソース言語 (翻訳するテキストの元の言語) と、ターゲット言語 (翻訳するテキストの対象の言語) の間の翻訳が可能になります。ソース言語またはターゲット言語として英語を使用する必要はありませんが、Amazon Translate で、すべての言語の組み合わせがサポートされているわけではありません。詳細については、「サポートされている言語と言語コード (p. 1)」を参照してください。

Amazon Translate を使用すると、ソーステキストを提供し出力テキストを取得します。

• ソーステキスト—翻訳したいテキストです。UTF-8 形式でソーステキストを提供します。• 出力テキスト — Amazon Translate がターゲット言語に翻訳したテキスト。出力テキストも UTF-8 形式

です。ソース言語とターゲット言語によっては、出力テキストの文字数が入力テキストよりも多くなる場合があります。

翻訳モデルには 2 つのコンポーネント (エンコーダーとデコーダー) があります。エンコーダーはソースの文を一度に 1 単語ずつ読み取り、意味を捕捉するセマンティック表現を構築します。デコーダーは、セマンティック表現を使用して、ターゲット言語で一度に 1 単語の翻訳を生成します。

Amazon Translate はコンテキストを理解するために注意メカニズムを使用します。これは、ソーステキストのどの単語が次のターゲットの単語を生成する上で最も関連性があるか判断する場合に役立ちます。注意メカニズムはエンコーダーを有効にして、ソース文のもっとも関連性のある部分を重視します。これにより、デコーダーはあいまいな単語や語句を正確に翻訳することができます。

モデルが生成するターゲット単語は、デコーダーの入力になります。ネットワークは文の最後に達するまで単語を生成します。

言語の自動検出Amazon Translate はソーステキストで使用されている言語を自動検出できます。自動言語検出を使用するには、auto をソース言語として指定します。Amazon Translate はお客様に代わって AmazonComprehend を呼び出し、ソーステキストで指定されている言語を検出します。言語の自動検出を選択することで、お客様は Amazon Comprehend のサービス条件および契約に同意するものとみなされます。Amazon Comprehend の価格設定については、「Amazon Comprehend 料金表」を参照してください。

例外処理サポートされていないソース言語またはターゲット言語を指定した場合、Amazon Translate は次の例外を返します。

• UnsupportedLanguagePairException – Amazon Translate は言語間の翻訳をサポートしています。言語ペアの翻訳がサポートされていない場合は、この例外が返されます。詳細については、「サポートされている言語 (p. 1)」を参照してください。

• DetectedLanguageLowConfidenceException – 言語自動検出を使用していて Amazon Translate が正確なソース言語を検出できたか定かではない場合に、この例外が返されます。信頼性のレベルが低い場合でも、それが許容される範囲である場合は例外で返されたソース言語を使用できます。

5

Page 10: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド次のステップ

次のステップAmazon Translate の仕組みの学習が完了したので、次のセクションではソリューション作成についてご覧ください。

• Amazon Translate の使用開始 (p. 7)• 例 (p. 23)

6

Page 11: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドステップ 1: アカウントを設定する

Amazon Translate の使用開始Amazon Translate の使用を開始するには、AWS アカウントをセットアップし、AWS Identity and AccessManagement (IAM) ユーザーを作成します。AWS Command Line Interface (AWS CLI) を使用するには、これをダウンロードして設定します。

トピック• ステップ 1: AWS アカウントを設定して管理ユーザーを作成する (p. 7)• ステップ 2: AWS Command Line Interface (AWS CLI) を設定する (p. 8)• ステップ 3: 開始方法 (コンソール) (p. 9)• ステップ 4: 使用開始 (AWS CLI) (p. 10)• ステップ 5: 開始方法 (SDK) (p. 12)

ステップ 1: AWS アカウントを設定して管理ユーザーを作成する

Amazon Translate を初めて使用する場合は、事前に以下のタスクをすべて実行してください。

1. AWS にサインアップする (p. 7)2. IAM ユーザーを作成する (p. 7)

AWS にサインアップするAmazon Web Services (AWS) にサインアップすると、Amazon Translate などすべての AWS のサービスに対して AWS アカウントが自動的にサインアップされます。料金が発生するのは、実際に使用したサービスの分のみです。

Amazon Translate の場合、使用したリソースに対してのみ料金を支払います。AWS の新規のお客様の場合、Amazon Translate を無料で使い始めることができます。詳細については、「AWS 無料利用枠」を参照してください。

すでに AWS アカウントをお持ちの場合は、次の手順に進んでください。

AWS アカウントを作成するには

1. https://portal.aws.amazon.com/billing/signup を開きます。2. オンラインの手順に従います。

サインアップ手順の一環として、通話呼び出しを受け取り、電話のキーパッドを用いて確認コードを入力することが求められます。

次のタスクで AWS アカウント ID が必要となるので、記録しておいてください。

IAM ユーザーを作成するAmazon Translate などの AWS のサービスでは、サービスにアクセスする際に認証情報を提供する必要があります。これにより、サービスのリソースへアクセスするための権限があるかどうかが判断されます。

7

Page 12: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド次のステップ

AWS アカウントの認証情報ではなく、AWS Identity and Access Management (IAM) を使用して AWS にアクセスすることを強くお勧めします。IAM を使用して AWS にアクセスするには、IAM ユーザーを作成して、管理権限を使ってこのユーザーを IAM グループに追加し、IAM ユーザーに管理権限を付与します。そして、特別な URL とその IAM ユーザーの認証情報を使用して AWS にアクセスできます。

このガイドの演習では、adminuser という管理者権限を持つ IAM ユーザーが存在するとします。

管理者ユーザーを作成するには

• AWS アカウントで、adminuser という管理者ユーザーを作成します。手順については、IAM ユーザーガイド の「最初の IAM 管理者のユーザーおよびグループの作成」を参照してください。

IAM の詳細については、以下を参照してください。

• AWS Identity and Access Management (IAM)• はじめに• IAM ユーザーガイド

次のステップステップ 2: AWS Command Line Interface (AWS CLI) を設定する (p. 8)

ステップ 2: AWS Command Line Interface (AWSCLI) を設定する

AWS CLI を使用して Amazon Translate へのインタラクティブな呼び出しを行います。

AWS CLI をセットアップするには

1. AWS CLI をダウンロードして設定します。手順については、AWS Command Line Interface ユーザーガイドの次のトピックを参照してください。

• AWS Command Line Interface のセットアップ• AWS Command Line Interfaceの設定

2. AWS CLI config ファイルで、管理者ユーザー用の名前付きプロファイルを追加します。

[profile adminuser]aws_access_key_id = adminuser access key IDaws_secret_access_key = adminuser secret access keyregion = aws-region

このプロファイルは、AWS CLI コマンドを実行するときに使用します。名前付きプロファイルの詳細については、AWS Command Line Interface ユーザーガイドの「名前付きプロファイル」を参照してください。AWS リージョンのリストについては、アマゾン ウェブ サービス全般のリファレンスの「リージョンとエンドポイント」を参照してください。

3. コマンドプロンプトで以下のヘルプコマンドを入力して、セットアップを確認します。

aws translate help

Amazon Translate の簡単な説明と、使用可能なコマンドのリストが表示されます。

8

Page 13: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド次のステップ

次のステップステップ 3: 開始方法 (コンソール) (p. 9)

ステップ 3: 開始方法 (コンソール)Amazon Translate の使用を開始する最も簡単な方法は、コンソールを使って何らかのテキストを翻訳することです。最大 5,000 文字をコンソールを使用して翻訳できます。「Amazon Translate の詳細 (p. 5)」の概念と用語を確認してから、先に進むことをお勧めします。

テキストの翻訳を開始するには、AWS マネジメントコンソール に移動して、Amazon Translate コンソールを開きます。

Amazon Translate を初めて使用する場合は、[リアルタイム翻訳を起動] を選択します。

[リアルタイム変換] で、ソースとターゲットの言語を選択します。左側のテキストボックスに翻訳するテキストを入力します。翻訳されたテキストが右側のテキストボックスに表示されます。

[JSON samples] のセクションで TranslateText (p. 97) オペレーションの JSON 入力と出力を確認できます。

9

Page 14: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド次のステップ

次のステップステップ 4: 使用開始 (AWS CLI) (p. 10)

ステップ 4: 使用開始 (AWS CLI)次の演習では、AWS コマンドラインインターフェイス (AWS CLI) を使用してテキストを翻訳します。以下の演習を行うには、CLI に精通している必要があります。また、テキストエディタが必要です。詳細については、「ステップ 2: AWS Command Line Interface (AWS CLI) を設定する (p. 8)」を参照してください。

Amazon Translate を使用してテキストを CLI で翻訳するには、2 つの方法があります。ショートテキストの場合、translate-text コマンドのパラメータとして翻訳するテキストを提供できます。長いテキストの場合、ソース言語、ターゲット言語、および JSON ファイルのテキストを指定できます。

コマンドラインから Amazon Translate を使用するには、サービスのエンドポイントとリージョンを知る必要があります。利用可能なリージョンのリストについては、AWS 全般リファレンスの「AmazonTranslate リージョンとエンドポイント」を参照してください。

10

Page 15: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドコマンドラインを使用したテキストの翻訳

コマンドラインを使用したテキストの翻訳次の例は、コマンドラインから translate-text オペレーションを使用してテキストを翻訳する方法を示しています。例は、Unix、Linux、および macOS 用にフォーマットされています。Windows の場合は、各行末のバックスラッシュ (\) Unix 連結文字をキャレット (^) に置き換えてください。コマンドラインで、以下のように入力します。

aws translate translate-text \ --region region \ --source-language-code "en" \ --target-language-code "es" \ --text "hello, world "

レスポンスは以下の JSON です。

{ "TargetLanguageCode": "es", "Text": "Hola, mundo", "SourceLanguageCode": "en"}

JSON ファイルを使用したテキストの翻訳この例では、translate-text オペレーションを使用して、JSON ファイルから長いテキストブロックを翻訳する方法を示します。ソース言語とターゲットの言語をコマンドラインで指定できますが、この例では、JSON ファイルでそれらを指定します。

Note

JSON ファイルは、読みやすくするためフォーマットされています。"Text" フィールドの形式を変更して改行を削除します。例は、Unix、Linux、および macOS 用にフォーマットされています。Windows の場合は、各行末のバックスラッシュ (\) Unix 連結文字をキャレット (^) に置き換えてください。

JSON ファイルを使用してテキストを翻訳するには

1. 次のテキストを、translate.json という JSON ファイルにコピーします。

{ "Text": "Amazon Translate translates documents between languages in real time. It uses advanced machine learning technologies to provide high-quality real-time translation. Use it to translate documents or to build applications that work in multiple languages.", "SourceLanguageCode": "en", "TargetLanguageCode": "fr"}

2. AWS CLI で、次のコマンドを実行します。

aws translate translate-text \ --region region \ --cli-input-json file://translate.json > translated.json

このコマンドは、次の JSON テキストを含む JSON ファイルを出力します。

{ "TargetLanguageCode": "fr",

11

Page 16: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド次のステップ

"Text": "Amazon Translate traduit les documents entre les langue en temps réel. Il utilise des technologies avancées d'apprentissage de la machine pour fournir une traduction en temps réel de haute qualité. Utilisez-le pour traduire des documents ou pour créer des applications qui fonctionnent en plusieurs langues.", "SourceLanguageCode": "en"}

次のステップAmazon Translate を使用するその他の方法については、「例 (p. 23)」を参照してください。

ステップ 5: 開始方法 (SDK)次の例では、Java および Python で Amazon Translate の TranslateText (p. 97) オペレーションを使用する方法を示します。それらを使用して、TranslateText オペレーションおよび独自のアプリケーション構成要素について学習します。

Java の例を実行するには、AWS SDK for Java をインストールする必要があります。SDK for Java をインストールする手順については、「AWS SDK for Java のセットアップ」を参照してください。

トピック• AWS SDK for Java を使用したテキストの翻訳 (p. 12)• AWS SDK for Python (Boto) を使用したテキストの翻訳 (p. 13)• AWS Mobile SDK for Android を使用したテキストの翻訳 (p. 15)• AWS Mobile SDK for iOS を使用したテキストの翻訳 (p. 16)

AWS SDK for Java を使用したテキストの翻訳次の例は、Java で TranslateText (p. 97) オペレーションを使用する方法を示しています。この例を実行するには、AWS SDK for Java が必要です。SDK for Java をインストールする手順については、「AWSSDK for Java のセットアップ」を参照してください。

import com.amazonaws.auth.AWSStaticCredentialsProvider;import com.amazonaws.auth.BasicAWSCredentials;import com.amazonaws.client.builder.AwsClientBuilder;import com.amazonaws.services.translate.AmazonTranslate;import com.amazonaws.services.translate.AmazonTranslateClient;import com.amazonaws.services.translate.model.TranslateTextRequest;import com.amazonaws.services.translate.model.TranslateTextResult; public class App { private static final String REGION = "region"; public static void main( String[] args ) { // Create credentials using a provider chain. For more information, see // https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html AWSCredentialsProvider awsCreds = DefaultAWSCredentialsProviderChain.getInstance(); AmazonTranslate translate = AmazonTranslateClient.builder() .withCredentials(new AWSStaticCredentialsProvider(awsCreds.getCredentials())) .withRegion(REGION)

12

Page 17: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAWS SDK for Python の使用

.build(); TranslateTextRequest request = new TranslateTextRequest() .withText("Hello, world") .withSourceLanguageCode("en") .withTargetLanguageCode("es"); TranslateTextResult result = translate.translateText(request); System.out.println(result.getTranslatedText()); }}

選択した言語ペアが正しい組み合わせで Amazon Translate によってサポートされている限り、ソース言語とターゲット言語は変更できます。詳細については、「サポートされている言語と言語コード (p. 1)」を参照してください。

AWS SDK for Python (Boto) を使用したテキストの翻訳次の例は、Python で TranslateText (p. 97) オペレーションを使用する方法を示しています。これを実行するには、最初に AWS CLI 経由で Amazon Translate をインストールする必要があります。手順については、「the section called “ステップ 2: AWS CLI をセットアップする” (p. 8)」を参照してください。

import boto3

translate = boto3.client(service_name='translate', region_name='region', use_ssl=True)

result = translate.translate_text(Text="Hello, World", SourceLanguageCode="en", TargetLanguageCode="de")print('TranslatedText: ' + result.get('TranslatedText'))print('SourceLanguageCode: ' + result.get('SourceLanguageCode'))print('TargetLanguageCode: ' + result.get('TargetLanguageCode'))

選択した言語ペアが正しい組み合わせで Amazon Translate によってサポートされている限り、ソース言語とターゲット言語は変更できます。詳細については、「サポートされている言語と言語コード (p. 1)」を参照してください。

カスタム用語

別の例として、Python でのカスタム用語オペレーションの使用を示します。

#!/usr/bin/env python # -*- coding: utf-8 -*- import boto3 translate = boto3.client(service_name='translate') # The terminology file 'my-first-terminology.csv' has the following contents: ''' en,fr Amazon Family,Amazon Famille ''' # Read the terminology from a local file with open('/tmp/my-first-terminology.csv', 'rb') as f: data = f.read() file_data = bytearray(data) print("Importing the terminology into Amazon Translate...")

13

Page 18: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAWS SDK for Python の使用

response = translate.import_terminology(Name='my-first-terminology', MergeStrategy='OVERWRITE', TerminologyData={"File": file_data, "Format": 'CSV'}) print("Terminology imported: "), print(response.get('TerminologyProperties')) print("\n") print("Getting the imported terminology...") response = translate.get_terminology(Name='my-first-terminology', TerminologyDataFormat='CSV') print("Received terminology: "), print(response.get('TerminologyProperties')) print("The terminology data file can be downloaded here: " + response.get('TerminologyDataLocation').get('Location')) print("\n") print("Listing the first 10 terminologies for the account...") response = translate.list_terminologies(MaxResults=10) print("Received terminologies: "), print(response.get('TerminologyPropertiesList')) print("\n") print("Translating 'Amazon Family' from English to French with no terminology...") response = translate.translate_text(Text="Amazon Family", SourceLanguageCode="en", TargetLanguageCode="fr") print("Translated text: " + response.get('TranslatedText')) print("\n") print("Translating 'Amazon Family' from English to French with the 'my-first-terminology' terminology...") response = translate.translate_text(Text="Amazon Family", TerminologyNames=["my-first-terminology"], SourceLanguageCode="en", TargetLanguageCode="fr") print("Translated text: " + response.get('TranslatedText')) print("\n") # The terminology file 'my-updated-terminology.csv' has the following contents: ''' en,fr Amazon Family,Amazon Famille Prime Video, Prime Video ''' # Read the terminology from a local file with open('/tmp/my-updated-terminology.csv', 'rb') as f: data = f.read() file_data = bytearray(data) print("Updating the imported terminology in Amazon Translate...") response = translate.import_terminology(Name='my-first-terminology', MergeStrategy='OVERWRITE', TerminologyData={"File": file_data, "Format": 'CSV'}) print("Terminology updated: "), print(response.get('TerminologyProperties')) print("\n") print("Translating 'Prime Video' from English to French with no terminology...") response = translate.translate_text(Text="Prime Video", SourceLanguageCode="en", TargetLanguageCode="fr") print("Translated text: " + response.get('TranslatedText')) print("\n") print("Translating 'Prime Video' from English to French with the 'my-first-terminology' terminology...") response = translate.translate_text(Text="Prime Video", TerminologyNames=["my-first-terminology"], SourceLanguageCode="en", TargetLanguageCode="fr") print("Translated text: " + response.get('TranslatedText')) print("\n")

14

Page 19: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドMobile SDK for Android の使用

print("Cleaning up by deleting 'my-first-terminology'...") translate.delete_terminology(Name="my-first-terminology") print("Terminology deleted.")

AWS Mobile SDK for Android を使用したテキストの翻訳Android アプリケーションで Amazon Translate を使用してテキストを翻訳できます。

例を設定するには

1. AWS Mobile SDK for Android をセットアップします。手順については、AWS モバイル開発者ガイドの「Android: SDK のセットアップオプション」を参照してください。

2. この例を実行するための最小限必要なアクセス権限を持つ IAM ユーザーを作成します。IAM ユーザーの作成方法について詳しくは、AWS Identity and Access Managementユーザーガイドの「AWS アカウント内での IAM ユーザーの作成」を参照してください。必要なアクセス許可ポリシーについては、「Amazon Translate アイデンティティベースのポリシー (p. 53)」を参照してください。ユーザーを作成した後、認証情報をダウンロードするか、アクセスキーとシークレットアクセスキーを記録します。

3. Android Studio を使用して新規プロジェクトを作成する4. build.gradle ファイルの依存関係セクションに以下を追加します。

dependencies { implementation 'com.amazonaws:aws-android-sdk-translate:2.6.20'}

5. AndroidManifest.xml ファイルに次のアクセス権限を追加します。

<uses-permission android:name="android.permission.INTERNET"/><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

6. プロジェクトにソースコードをコピーする7. アクセスキーとシークレットアクセスキーを、ステップ 1 で記録したキーに変更します。

コード以下のコードを使用して例を作成します。

package com.amazonaws.amazontranslatetester; import android.app.Activity;import android.util.Log; import com.amazonaws.auth.AWSCredentials;import com.amazonaws.handlers.AsyncHandler;import com.amazonaws.services.translate.AmazonTranslateAsyncClient;import com.amazonaws.services.translate.model.TranslateTextRequest;import com.amazonaws.services.translate.model.TranslateTextResult; public class MainActivity extends Activity { private static final String LOG_TAG = MainActivity.class.getSimpleName();

15

Page 20: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドMobile SDK for iOS の使用

@Override protected void onCreate(Bundle savedInstanceState) { AWSCredentials awsCredentials = new AWSCredentials() { @Override public String getAWSAccessKeyId() { return "access key"; } @Override public String getAWSSecretKey() { return "secret key"; } }; AmazonTranslateAsyncClient translateAsyncClient = new AmazonTranslateAsyncClient(awsCredentials); TranslateTextRequest translateTextRequest = new TranslateTextRequest() .withText("Hello, world") .withSourceLanguageCode("en") .withTargetLanguageCode("es"); translateAsyncClient.translateTextAsync(translateTextRequest, new AsyncHandler<TranslateTextRequest, TranslateTextResult>() { @Override public void onError(Exception e) { Log.e(LOG_TAG, "Error occurred in translating the text: " + e.getLocalizedMessage()); } @Override public void onSuccess(TranslateTextRequest request, TranslateTextResult translateTextResult) { Log.d(LOG_TAG, "Original Text: " + request.getText()); Log.d(LOG_TAG, "Translated Text: " + translateTextResult.getTranslatedText()); } }); }}

AWS Mobile SDK for iOS を使用したテキストの翻訳iOS アプリケーションで Amazon Translate を使用してテキストを翻訳できます。

例を設定するには

1. この例を実行するための最小限必要なアクセス権限を持つ IAM ユーザーを作成します。IAM ユーザーの作成方法について詳しくは、AWS Identity and Access Managementユーザーガイドの「AWS アカウント内での IAM ユーザーの作成」を参照してください。必要なアクセス許可ポリシーについては、「Amazon Translate アイデンティティベースのポリシー (p. 53)」を参照してください。ユーザーを作成した後、認証情報をダウンロードするか、アクセスキーとシークレットアクセスキーを記録します。

2. Xcode バージョン 8.0 以降をインストールします。Xcode の最新バージョンは Apple ウェブサイトhttps://developer.apple.com/xcode/ からダウンロードできます。

3. Cocoapods をインストールします.ターミナルウィンドウで、以下のコマンドを実行します。

sudo gem install cocoapods

4. Xcode を使用してプロジェクトを作成します。次に、ターミナルウィンドウで、プロジェクトの.xcodeproj ファイルが含まれているディレクトリに移動し、以下のコマンドを実行します。

16

Page 21: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドMobile SDK for iOS の使用

pod init

5. 主要な Mobile SDK for iOS コンポーネントを pod ファイルに追加します。

platform :ios, '9.0'target :'app name' do use_frameworks! pod 'AWSTranslate', '~> 2.6.19' # other podsend

6. ターミナルウィンドウで次のコマンドを実行して、依存関係をインストールします。

pod install --repo-update

7. 「pod install」を実行することで、新しいワークスペースファイルが作成されます。Xcode プロジェクトを閉じ、/project_name.xcworkspace ファイルを使用して開きます。今後 Xcode プロジェクトを開くには、このファイルのみを使用する必要があります。

コードで呼び出された新しいライブラリから API を解決するには、アプリケーションを開いてから再ビルドします。

8. ビューコントローラーに次のインポートステートメントを追加します。

import AWSTranslate

9. XCode プロジェクトに次のコードをコピーします。アクセスキーとシークレットキーを、ステップ 1で記録した値に置き換えます。

コード以下のコードを使用して例を作成します。

var credentialsProvider = AWSStaticCredentialsProvider(accessKey: "access key", secretKey: "secret key")

var configuration = AWSServiceConfiguration(region: AWSRegionUSEast1, credentialsProvider: credentialsProvider)

AWSServiceManager.default().defaultServiceConfiguration = configuration

let translateClient = AWSTranslate.default()let translateRequest = AWSTranslateTranslateTextRequest()translateRequest?.sourceLanguageCode = "en"translateRequest?.targetLanguageCode = "es"translateRequest?.text = "Hello World" let callback: (AWSTranslateTranslateTextResponse?, Error?) -> Void = { (response, error) in guard let response = response else { print("Got error \(error)") return } if let translatedText = response.translatedText { print(translatedText) }

17

Page 22: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドMobile SDK for iOS の使用

} translateClient.translateText(translateRequest!, completionHandler: callback)

18

Page 23: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド動作の仕組み

カスタム用語翻訳リクエストでカスタム用語を使用すると、ブランド名、キャラクター名、モデル名、およびその他の独自コンテンツを、コンテキストや Amazon Translate アルゴリズムによる決定とは無関係に、毎回目的どおりに翻訳することができます。

用語ファイルを簡単にセットアップし、Amazon Translate アカウントにアタッチできます。テキストを翻訳する際に、カスタム用語の使用も選択すると、ソースの該当する単語は目的どおりに翻訳されます。

たとえば、以下について考えてみます。Amazon Family には、おむつ、ベビーフードなどの定期購入で最大 20% の割引が得られるなど、Amazon プライム会員専用のさまざまな特典が用意されています。フランスでは、このプログラムは Amazon Famille と呼ばれます。追加のコンテキストを使用せずに AmazonTranslate を使用して Amazon Family をフランス語に翻訳すると、結果は Famille Amazon になります。これは正確な翻訳ですが、フランスの Amazon チームが必要としている訳語ではありません。しかし、これに「Amazon Family でショッピングを行ったことがありますか?」のようなコンテキストを追加すると、Amazon Translate はプログラム名を訳す必要がないと判断し、結果は「Avez-vous déjà fait desachats avec Amazon Family?」となります。これは良い翻訳ですが、まだ Amazon チームが必要としているものではありません。このような問題は、カスタム用語で解決できます。Amazon Family を AmazonFamille と訳す必要があることを示すエントリをカスタム用語に追加すれば、コンテキストにかかわらず毎回このように翻訳されます。これで、Amazon Family は Amazon Famille と訳され、「Amazon Family でショッピングを行ったことがありますか?」は「Avez-vous déjà fait des achats avec Amazon Famille?」と訳されます。

トピック• 動作の仕組み (p. 19)• カスタム用語の作成 (p. 19)• カスタム用語の使用 (p. 21)• 用語の暗号化 (p. 22)• ベストプラクティス (p. 22)

動作の仕組み通常、Amazon Translate は翻訳リクエストを受け取ると、ソースの文を読み取り、コンテンツのセマンティック表現を作成 (つまり、文を解釈) し、ターゲット言語の翻訳を生成します。

翻訳リクエストの一部としてカスタム用語を使用すると、エンジンは用語ファイルをスキャンしてから最終的な結果を返します。エンジンが、用語エントリとソーステキストの文字列の間で完全一致を識別すると、提案された翻訳内の該当する文字列を見つけ、それを用語のエントリに置き換えます。AmazonFamily の例では、最初に「Avez-vous déjà fait des achats avec Amazon Family?」という訳を生成しますが、応答を提供する前に停止し、Amazon Family を Amazon Famille に置き換えます。

カスタム用語の作成ソーステキストには CSV ファイルまたは TMX ファイルを使用し、用語ファイルにはターゲットの (翻訳された) 用語を使用できます。各用語には 1 つのソーステキストが使用されますが、ターゲット言語とソース言語を使用できる限り、言語ごとに 1 つずつ、複数のターゲット用語を使用できます。

CSV (カンマ区切り値)

最初の列にはソーステキスト、他の列にはターゲットの翻訳が含まれます。最初の行は言語コードで構成され、最初の列にはソース言語、その他の列にはターゲット言語が含まれます。

19

Page 24: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド対応言語

en fr de es

Amazon Amazon Amazon Amazon

TMX (Translation Memory eXchange)

TMX ファイルは、翻訳ソフトウェアで一般的に使用される XML 形式のファイルです。この形式は CSV とは異なりますが、コンテンツは類似しています。

<?xml version="1.0" encoding="UTF-8"?><tmx version="1.4"> <header creationtool="XYZTool" creationtoolversion="0" datatype="PlainText" segtype="sentence" adminlang="en-us" srclang="en" o-tmf="test"/> <body> <tu> <tuv xml:lang="en"> <seg>Amazon</seg> </tuv> <tuv xml:lang="fr"> <seg>Amazon</seg> </tuv> <tuv xml:lang="de"> <seg>Amazon</seg> </tuv> <tuv xml:lang="es"> <seg>Amazon</seg> </tuv> </tu> </body></tmx>

次に、これらのファイルは Amazon Translate アカウントにアタッチされます。翻訳ジョブが実行され、カスタム用語の使用を選択すると、Amazon Translate はソースの単語が見つかるたびに、指定された単語を使用します。

Important

カスタム用語内でソースの単語は大文字と小文字が区別され、完全一致ではない単語には適用されません。

対応言語一部の言語では、文のコンテキストに基づいて単語の形が変わりません。多くの場合、これらの言語では、カスタム用語を適用することにより翻訳品質全体が向上します。ただし、一部の言語では単語の形が大幅に変わります。そうした言語にこの機能を適用することはお勧めしませんが、適用することは可能です。

次の表に、この機能を使用できる言語と推奨事項を示します。

言語 推奨/非推奨

東アジア言語 (中国語、インドネシア語、日本語、韓国語、マレー語)

推奨

20

Page 25: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドカスタム用語の使用

言語 推奨/非推奨

ゲルマン言語 (デンマーク語、オランダ語、英語、ドイツ語、ノルウェー語、スウェーデン語)

推奨

ロマンス言語 (フランス語、イタリア語、ルーマニア語、スペイン語、ポルトガル語)

推奨

セム言語 (アラビア語、ヘブライ語) 推奨

インドイラン言語 (ヒンディー語、ペルシャ語、ウルドゥー語)

推奨

ギリシャ語 推奨

タイ語 推奨

ベトナム語 推奨

バルトスラブ語 (チェコ語、ポーランド語、ロシア語、ウクライナ語)

非推奨

ウラル言語 (フィンランド語、ハンガリー語) 非推奨

アラビア語 非推奨

トルコ語 非推奨

カスタム用語の使用TranslateText (p. 97) オペレーションを使用してテキストに翻訳する際にカスタム用語を使用する場合のプロセスは、カスタム用語を使用せずにテキストを翻訳する場合と似ています。その違いは、カスタム用語を使用してオペレーションを呼び出す場合は、オプションの TerminologyNames パラメータを含めることです。

たとえば、Amazon_Family.csv という次の用語ファイルがアカウントにアタッチされているとします。

en,fr Amazon Family,Amazon Famille

以下を使用してカスタム用語を呼び出し、CLI を使用してテキストを翻訳できます。Note

この例は、Unix、Linux、および macOS 用にフォーマットされています。Windows の場合は、各行末のバックスラッシュ (\) Unix 連結文字をキャレット (^) に置き換えてください。

aws translate translate-text \ --region region \ --source-language-code "en" \ --target-language-code "fr" \ --terminology-names "Amazon_Family" \ --text "Have you ever shopped with Amazon Family?"

ここでは、選択したカスタム用語を使用してこのテキストを直接的に「Avez-vous déjà fait des achatsavec Famille Amazon?」と訳す代わりに (望ましくありません)、「Avez-vous déjà fait des achats avecAmazon Famille?」と訳します。

21

Page 26: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド用語の暗号化

Python を使用する場合、以下により同じタスクを実行できます。

import boto3 translate = boto3.client(service_name='translate') print("Translating 'Have you ever shopped with Amazon Family?' from English to French with the 'Amazon_Family' custom terminology...")response = translate.translate_text(Text="Have you ever shopped with Amazon Family?", TerminologyNames=["Amazon_Family"], SourceLanguageCode="en", TargetLanguageCode="fr")print("Translated text: " + response.get('TranslatedText'))print("\n")

カスタム用語を使った Amazon Translate オペレーションの使用の詳細については、「Actions (p. 74)」を参照してください。

用語の暗号化Amazon Translate はお客様のすべてのデータを保護するべく取り組んでおり、カスタム用語についても同様です。各カスタム用語は、作成時に暗号化され、お客様のみがアクセス可能になります。

使用できる暗号化オプションは 3 つです。

• AWS 暗号化の使用。これはデフォルトのオプションであり、他の方法を選択しない場合に、情報を保護するために使用されます。

• お客様のアカウントに関連付けられた暗号化キーの使用。これを選択すると、コンソールのメニューに、使用する関連付けられた暗号化キーの選択が表示されます。

• お客様のアカウントに関連付けられていない暗号化キーの使用。このオプションを選択した場合、暗号化キーの Amazon リソースネーム (ARN) を入力するボックスがコンソールに表示されます。

ベストプラクティス以下は、カスタム用語を使用する際の推奨のベストプラクティスです。

• カスタム用語は最小限に維持します。制御する単語と、完全にあいないな単語のみを含めます。別の意味では決して使用しないことがわかっている単語や、必ず同じように訳す単語のみを使用します。理想的には、ブランド名や製品名などの固有名詞にリストを限定します。

• カスタム用語は大文字と小文字が区別されます。単語の大文字バージョンと大文字でないバージョンの両方を含める必要がある場合は、各バージョンのエントリを含める必要があります。

• 同じソース語句に対して複数の異なる訳語を含めないでください (たとえば、エントリ 1-EN:Amazon、FR: Amazon、エントリ 2-EN: Amazon、FR: Amazone)。

• 一部の言語では、文のコンテキストに基づいて単語の形が変わりません。多くの場合、これらの言語では、カスタム用語を適用することにより翻訳品質全体が向上します。ただし、一部の言語では単語の形が大幅に変わります。そうした言語にこの機能を適用することはお勧めしませんが、適用することは可能です。詳細については、「対応言語 (p. 20)」を参照してください。

22

Page 27: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Polly を Amazon Translate に使用する

例次の例は、Amazon Translate を使用する方法を示しています。

トピック• Amazon Polly を Amazon Translate に使用する (p. 23)• Amazon Translate を使用してチャットチャネルを翻訳する (p. 27)• Amazon Translate を Amazon DynamoDB に使用する (p. 35)• Amazon Translate を使用したウェブページの翻訳 (p. 38)• Amazon Translate を使用して大きいドキュメントを翻訳する (p. 41)• Amazon Translate で署名バージョン 4 を使用する (p. 43)

Amazon Polly を Amazon Translate に使用する翻訳されたテキストを読み上げるには、Amazon Polly と Amazon Translate を使用できます。この例では、Amazon Translate を使用してテキストを翻訳できるウェブページを作成し、Amazon Polly を使用してそのテキストを読み上げます。そのコードは次のように要約できます。

• ウェブページを作成するための CSS と HTML• Amazon Translate と Amazon Polly のコントローラーを作成する初期化コード。• ウェブページからデータを読み取り、Amazon Translate を呼び出す関数。• ウェブページからデータを読み取り、Amazon Polly を呼び出す関数。• ウェブページを作成するためのユーティリティ関数。

例を設定するには

1. AWS SDK for JavaScript をインストールして設定します。SDK for JavaScript をインストールする手順については、「Installing the SDK for JavaScript」を参照してください。

2. 例のコードを、ウェブサーバー上の HTML ファイルにコピーします。3. <script> タグを、SDK for JavaScript をインストールした場所に更新します。4. リージョンとエンドポイントを、Amazon Translate および Amazon Polly オペレーションを実行す

るリージョンに変更します。Amazon Translate がサポートされるリージョンのリストについては、「AWS のリージョンとエンドポイント」を参照してください。Amazon Polly がサポートされるリージョンのリストについては、AWS 全般リファレンスの「AWS リージョンとエンドポイント」を参照してください。

5. この例を実行するための最小限必要なアクセス権限を持つ IAM ユーザーを作成します。IAM ユーザーの作成方法について詳しくは、AWS Identity and Access Managementユーザーガイドの「AWSアカウント内での IAM ユーザーの作成」を参照してください。必要なアクセス権限ポリシーについては、Amazon Polly 開発者ガイドの「Amazon Translate アイデンティティベースのポリシー (p. 53)」および「Amazon Polly での ID ベースポリシー (IAM ポリシー) の使用」を参照してください。

6. 前のステップで作成した IAM ユーザーのアクセス ID およびシークレットキーを入力します。

23

Page 28: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドコード

コードウェブページの例の完全なコードを以下に示します。このコードを HTML ファイルにコピーして、お客様のウェブサーバーで例を実行できます。

<!DOCTYPE html><html>

<head> <title>Amazon Translate</title> <script src="aws-sdk/dist/aws-sdk.js"></script></head>

<body> <h1 style="text-align: left">Amazon Translate Demo</h1> <br/> <table class="tg"> <tr> <th align="left">Source Language Code: <select id="sourceLanguageCodeDropdown"> <option value="en">en</option> <option value="ar">ar</option> <option value="cs">cs</option> <option value="de">de</option> <option value="es">es</option> <option value="fr">fr</option> <option value="it">it</option> <option value="ja">ja</option> <option value="pt">pt</option> <option value="ru">ru</option> <option value="tr">tr</option> <option value="zh">zh</option> <option value="zh-TW">zh-TW</option> </select> </th> <th align="left">Target Language Code: <select id="targetLanguageCodeDropdown"> <option value="en">en</option> <option value="ar">ar</option> <option value="cs">cs</option> <option value="de">de</option> <option value="es">es</option> <option value="fr">fr</option> <option value="it">it</option> <option value="ja">ja</option> <option value="pt">pt</option> <option value="ru">ru</option> <option value="tr">tr</option> <option value="zh">zh</option> <option value="zh-TW">zh-TW</option> </select> </th> </tr> <tr> <th> <textarea id="inputText" name="inputText" rows="10" cols="50" placeholder="Text to translate..."></textarea> </th> <th> <textarea id="outputText" name="outputText" rows="10" cols="50" placeholder="Translated text..."></textarea> </th>

24

Page 29: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドコード

</tr> <tr> <th align="left"> <button type="button" name="translateButton" onclick="doTranslate()">Translate</button> <button type="button" name="synthesizeButton" onclick="doSynthesizeInput()">Synthesize Input Speech</button> <button type="button" name="clearButton" onclick="clearInputs()">Clear</button> </th> <th align="left"> <button type="button" name="synthesizeButton" onclick="doSynthesizeOutput()">Synthesize Output Speech</button> </th> </tr> </table> <script type="text/javascript"> // set the focus to the input box document.getElementById("inputText").focus();

/** * Change the region and endpoint. */ AWS.config.region = 'region'; // Region

/** * In a production application you should use a secure method of authenticating uses, such as the ones * described here: * https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-browser.html * * Note that Amazon Translate does not work with Amazon Cognito ID. * * For this example you place the credentials of an IAM user in the HTML page. The IAM user associated * with these credentials must have permissions to call Amazon Translate. We recommend using the following * permissions policy and nothing more, as anyone that has access to this HTML page will also have access to * these hard-coded credentials. * { * "Version": "2012-10-17", * "Statement": [ * { * "Action": [ * "translate:TranslateText", * "polly:SynthesizeSpeech" * ], * "Resource": "*", * "Effect": "Allow" * } * ] * } * * For more information about the AWS Credentials object, see: * http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Credentials.html */ AWS.config.credentials = new AWS.Credentials("access key", "secret key");

var translate = new AWS.Translate({region: AWS.config.region}); var polly = new AWS.Polly();

function doTranslate() { var inputText = document.getElementById('inputText').value; if (!inputText) {

25

Page 30: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドコード

alert("Input text cannot be empty."); exit(); }

// get the language codes var sourceDropdown = document.getElementById("sourceLanguageCodeDropdown"); var sourceLanguageCode = sourceDropdown.options[sourceDropdown.selectedIndex].text;

var targetDropdown = document.getElementById("targetLanguageCodeDropdown"); var targetLanguageCode = targetDropdown.options[targetDropdown.selectedIndex].text;

var params = { Text: inputText, SourceLanguageCode: sourceLanguageCode, TargetLanguageCode: targetLanguageCode };

translate.translateText(params, function(err, data) { if (err) { console.log(err, err.stack); alert("Error calling Amazon Translate. " + err.message); return; } if (data) { var outputTextArea = document.getElementById('outputText'); outputTextArea.value = data.TranslatedText; } }); }

function doSynthesizeInput() { var text = document.getElementById('inputText').value.trim(); if (!text) { return; } var sourceLanguageCode = document.getElementById("sourceLanguageCodeDropdown").value; doSynthesize(text, sourceLanguageCode); }

function doSynthesizeOutput() { var text = document.getElementById('outputText').value.trim(); if (!text) { return; } var targetLanguageCode = document.getElementById("targetLanguageCodeDropdown").value; doSynthesize(text, targetLanguageCode); }

function doSynthesize(text, languageCode) { var voiceId; switch (languageCode) { case "de": voiceId = "Marlene"; break; case "en": voiceId = "Joanna"; break; case "es": voiceId = "Penelope"; break; case "fr": voiceId = "Celine";

26

Page 31: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate を使用してチャットチャネルを翻訳する

break; case "pt": voiceId = "Vitoria"; break; default: voiceId = null; break; } if (!voiceId) { alert("Speech synthesis unsupported for language code: \"" + languageCode + "\""); return; } var params = { OutputFormat: "mp3", SampleRate: "8000", Text: text, TextType: "text", VoiceId: voiceId }; polly.synthesizeSpeech(params, function(err, data) { if (err) { console.log(err, err.stack); // an error occurred alert("Error calling Amazon Polly. " + err.message); } else { var uInt8Array = new Uint8Array(data.AudioStream); var arrayBuffer = uInt8Array.buffer; var blob = new Blob([arrayBuffer]); var url = URL.createObjectURL(blob);

audioElement = new Audio([url]); audioElement.play(); } }); }

function clearInputs() { document.getElementById('inputText').value = ""; document.getElementById('outputText').value = ""; document.getElementById("sourceLanguageCodeDropdown").value = "en"; document.getElementById("targetLanguageCodeDropdown").value = "en"; } </script></body>

</html>

Amazon Translate を使用してチャットチャネルを翻訳する

Amazon Translate を使用してチャットメッセージをリアルタイムで翻訳できます。この例では Twitchチャンネルを使用しますが、これを手始めとして、他のチャットプラットフォーム、カスタマーサービスのやり取り、メッセージボードなどのリアルタイムストリーミングテキストにも応用できます。

この例では、英語のリアルタイムメッセージと、そのリアルタイム翻訳を左右に並べて表示するウェブページを使用します。Amazon Polly にメッセージを送信してテキストを入力できます。チャットで個人をフォローするには、ユーザー名を入力します。アプリケーションは、そのユーザーからのメッセージのみを受け付けます。

27

Page 32: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate を使用してチャットチャネルを翻訳する

コードは次のように要約できます。

• ウェブページを作成するための CSS と HTML• Amazon Translate と Amazon Polly のコントローラーを作成する初期化コード。• チャットメッセージを受信したときに実行されるコールバック関数。• チャットメッセージを送信する関数。• Amazon Translate を呼び出してメッセージを翻訳する関数。• Amazon Polly を呼び出してスピーチを合成する関数。• ウェブページを作成するためのユーティリティ関数。

例を設定するには

1. AWS SDK for JavaScript をインストールして設定します。SDK for JavaScript をインストールする手順については、「Installing the SDK for JavaScript」を参照してください。

2. 例のコードを、ウェブサーバー上の HTML ファイルにコピーします。3. <script> タグを、SDK for JavaScript をインストールした場所に更新します。4. リージョンとエンドポイントを、Amazon Translate および Amazon Polly オペレーションを実行

するリージョンに変更します。Amazon Translate がサポートされるリージョンのリストについては、AWS 全般リファレンスの「AWS リージョンとエンドポイント」を参照してください。

5. この例を実行するための最小限必要なアクセス権限を持つ IAM ユーザーを作成します。IAM ユーザーの作成方法について詳しくは、AWS Identity and Access Managementユーザーガイドの「AWSアカウント内での IAM ユーザーの作成」を参照してください。必要なアクセス権限ポリシーについては、Amazon Polly 開発者ガイドの「Amazon Translate アイデンティティベースのポリシー (p. 53)」および「Amazon Polly での ID ベースポリシー (IAM ポリシー) の使用」を参照してください。

6. 前のステップで作成した IAM ユーザーのアクセス ID およびシークレットキーを入力します。7. アカウントの Twitch ユーザー名と OAuth トークンを指定します。Twitch アカウントは https://

www.twitch.tv で作成できます。Twitch OAuth トークンは https://twitchapps.com/tmi で作成できます。

<!doctype html><html lang="en"><head> <title>Amazon Translate</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Latest compiled and minified CSS for Bootstrap --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Custom CSS --> <style> .topHeader { background-color: #6441a4; padding: 10px; border-bottom: solid 1px #cacaca; color: white }

.panelHeading { background-color: #6441a4 !important; }

28

Page 33: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate を使用してチャットチャネルを翻訳する

.panelBody { min-height: 450px; max-height: 450px;overflow-y: scroll; }

body{ margin-left: 0px; margin-right: 0px; height: 100%; } </style></head><body> <div class="container-fluid"> <!--Top Header--> <div class="row topHeader"> <div class="col-md-12"> <h4>Amazon Translate - Artificial Intelligence on AWS - Powerful machine learning for all Developers and Data Scientists</h4> </div> </div>

<!--Status Label--> <div class="row"> <div class="col-md-12"> <p class="bg-info"> <div id="connecting-div"></div> </p> </div> </div>

<div class="row" style="padding: 10px;"> <div class="col-md-6"> <div class="form-inline"> <div class="form-group"> <input type="text" id="channel" class="form-control" value="" placeholder="Channel"/> </div> <div class="form-group"> <select id="sourceLanguage" class="form-control"> <option value="en">en</option> <option value="ar">ar</option> <option value="de" selected="selected">de</option> <option value="es">es</option> <option value="fr">fr</option> <option value="pt">pt</option> <option value="zh">zh</option> </select> </div> <div class="form-group"> <select id="targetLanguage" class="form-control"> <option value="en" selected="selected">en</option> <option value="ar">ar</option> <option value="de">de</option> <option value="es">es</option> <option value="fr">fr</option> <option value="pt">pt</option> <option value="zh">zh</option> </select> </div> <div class="form-group"> <button type="button" class="form-control" id="btn-go" onclick="connect()">Go</button> <button type="button" class="form-control" id="btn-stop" onclick="location.href='index.html';">Stop</button>

29

Page 34: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate を使用してチャットチャネルを翻訳する

<span id="status"></span> </div> </div> </div> <div class="col-md-6"> <div class="form-inline"> <div class="form-group"> <input type="checkbox" id="cbSpeak" value="Speak"> Speak Live Translation <input type="text" id="follow" class="form-control" value="" placeholder="follow"/> </div> </div> </div> </div>

<!--Chat Boxes--> <div class="row"> <!--Live Chat--> <div class="col-md-6"> <div class="panel panel-primary"> <div class="panel-heading panelHeading">Live Chat</div> <div id="livechatc" class="panel-body panelBody"> <div class="subscribe" id="livechat"></div> </div> </div> </div> <!--Live Chat--> <!--Translated Chat--> <div class="col-md-6"> <div class="panel panel-primary"> <div class="panel-heading panelHeading">Live Translation</div> <div id="livetranslationc" class="panel-body panelBody"> <div class="imageDetected" id="livetranslation"></div> </div> </div> </div> <!--Translated Chat--> </div>

<!--Send Message--> <div class="row"> <div class="col-md-11"> <input type="text" id="message" class="form-control"/> </div> <div class=" col-md-1"> <button type="button" class="form-control btn btn-default" id="btn-send" onclick="sendMessage()">Send</button> </div> </div> </div>

<!-- Latest compiled and minified JavaScript --> <!-- jQuery first, then Bootstrap JS --> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

<script src="aws-js-sdk/dist/aws-sdk-all.js"></script> <script src="http://cdn.tmijs.org/js/1.2.1/tmi.min.js" integrity="sha384-eE0n7sm1W7DOUI2Xh5I4qSpZTe6hupAO0ovLfqEy0yVJtGRBNfssdmjbJhEYm6Bw" crossorigin="anonymous"></script> <script> cred = {

30

Page 35: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate を使用してチャットチャネルを翻訳する

twitchUsername: "Twitch user name", twitchOAuthToken: "Twitch OAuth token", awsAccessKeyId: "access key", awsSecretAccessKey: "secret key" };

AWS.config.region = 'region'; ep = new AWS.Endpoint('endpoint');

AWS.config.credentials = new AWS.Credentials(cred.awsAccessKeyId, cred.awsSecretAccessKey); window.translator = new AWS.Translate({endpoint: ep, region: AWS.config.region});

/**************************Init and Connect to Chat****************************/ function connect(){ init();

//Twitch Client var options = { options: { debug: false }, connection: { cluster: "aws", reconnect: true }, identity: { username: cred.twitchUsername, password: cred.twitchOAuthToken }, channels: [con.channel] };

window.client = tmi.client(options);

window.client.connect();

//Attached Handlers window.client.on("chat", onChat); window.client.on("connecting", onConnecting); window.client.on("connected", onConnected);

//Disable UI Elements document.getElementById("sourceLanguage").disabled = true; document.getElementById("targetLanguage").disabled = true; document.getElementById("channel").disabled = true; document.getElementById("btn-go").disabled = true; }

function init(){ //Get UI Controls var lc = document.getElementById("livechat"); var lt = document.getElementById("livetranslation") var lcc = document.getElementById("livechatc"); var ltc = document.getElementById("livetranslationc") var cbspeak = document.getElementById("cbSpeak") var follow = document.getElementById("follow"); var sendMessage = document.getElementById("message");

//Cache values con = { channel: document.getElementById("channel").value, sourceLanguage: document.getElementById("sourceLanguage").value, targetLanguage: document.getElementById("targetLanguage").value, liveChatUI: lc, liveTranslationUI: lt,

31

Page 36: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate を使用してチャットチャネルを翻訳する

liveChatUIContainer: lcc, liveTranslationUIContainer: ltc, cbSpeak: cbspeak, follow: follow, sendMessage: sendMessage }

lc.innerHTML = ''; lt.innerHTML = '';

//Speaker var voiceId = "Joanna"; if(con.targetLanguage == "en") voiceId = "Joanna"; else if(con.targetLanguage == "de") voiceId = "Marlene"; else if(con.targetLanguage == "es") voiceId = "Conchita"; else if(con.targetLanguage == "fr") voiceId = "Celine"; else if(con.targetLanguage == "pt") voiceId = "Ines"; else voiceId = "Joanna"; window.audioPlayer = AudioPlayer(voiceId); } /**************************Init and Connect to Chat****************************/

/**************************Receive and Translate Chat****************************/ function onChat (channel, userstate, message, self) { // Don't listen to my own messages.. if (self) return;

//Translate if (message) { var username = userstate['username'];

var params = { Text: message, SourceLanguageCode: con.sourceLanguage, TargetLanguageCode: con.targetLanguage };

window.translator.translateText(params, function onIncomingMessageTranslate(err, data) { if (err) { console.log("Error calling Translate. " + err.message + err.stack); } if (data) { console.log("M: " + message); console.log("T: " + data.TranslatedText);

//Print original message in chat UI con.liveChatUI.innerHTML += '<strong>' + username + '</strong>: ' + message + '<br>';

//Print translation in translation UI con.liveTranslationUI.innerHTML += '<strong>' + username + '</strong>: ' + data.TranslatedText + '<br>';

//If speak translation in enabled, speak translated message if(con.cbSpeak.checked){ if(con.follow.value == "" || username == con.follow.value) audioPlayer.Speak(username + " says " + data.TranslatedText); }

32

Page 37: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate を使用してチャットチャネルを翻訳する

//Scroll chat and translated UI to bottom to keep focus on latest messages con.liveChatUIContainer.scrollTop = con.liveChatUIContainer.scrollHeight; con.liveTranslationUIContainer.scrollTop = con.liveTranslationUIContainer.scrollHeight; } }); } } /**************************Receive and Translate Chat****************************/

/**************************Client Connecting****************************/ function onConnecting (address, port) { document.getElementById("status").innerHTML = " [ Connecting...]" }

function onConnected (address, port) { document.getElementById("status").innerHTML = " [ Connected ]" window.audioPlayer.Speak("Connected to channel " + con.channel + ". You should now be getting live chat messages."); } /**************************Client Connecting****************************/

/**************************Send Message****************************/ function sendMessage(){ if(con.sendMessage.value){ message = con.sendMessage.value; var params = { Text: con.sendMessage.value, SourceLanguageCode: con.targetLanguage, TargetLanguageCode: con.sourceLanguage };

window.translator.translateText(params, function onSendMessageTranslate(err, data) { if (err) { console.log("Error calling Translate. " + err.message + err.stack); } if (data) { console.log("M: " + message); console.log("T: " + data.TranslatedText);

//Send message to chat window.client.action(con.channel, data.TranslatedText);

//Clear send message UI con.sendMessage.value = "";

//Print original message in Translated UI con.liveTranslationUI.innerHTML += '<strong> ME: </strong>: ' + message + '<br>';

//Print translated message in Chat UI con.liveChatUI.innerHTML += '<strong> ME: </strong>: ' + data.TranslatedText + '<br>';

//Scroll chat and translated UI to bottom to keep focus on latest messages con.liveChatUIContainer.scrollTop = con.liveChatUIContainer.scrollHeight; con.liveTranslationUIContainer.scrollTop = con.liveTranslationUIContainer.scrollHeight; } }); } }

33

Page 38: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate を使用してチャットチャネルを翻訳する

/**************************Send Message****************************/

/**************************Audio player****************************/ function AudioPlayer(voiceId) { var audioPlayer = document.createElement('audio'); audioPlayer.setAttribute("id", "audioPlayer"); document.body.appendChild(audioPlayer);

var isSpeaking = false;

var speaker = { self: this, playlist:[],

Speak: function (text) { //If currently speaking a message, add new message to the playlist if (isSpeaking) { this.playlist.push(text); } else { speakTextMessage(text).then(speakNextTextMessage) } } }

// Speak text message function speakTextMessage(text) { return new Promise(function (resolve, reject) { isSpeaking = true; getAudioStream(text).then(playAudioStream).then(resolve); }); }

// Speak next message in the list function speakNextTextMessage() { var pl = speaker.playlist; if (pl.length > 0) { var txt = pl[0]; pl.splice(0, 1); speakTextMessage(txt).then(speakNextTextMessage); } }

// Get synthesized speech from Amazon polly function getAudioStream(textMessage) { return new Promise(function (resolve, reject) { var polly = new AWS.Polly(); var params = { OutputFormat: 'mp3', Text: textMessage, VoiceId: voiceId } polly.synthesizeSpeech(params, function (err, data) { if (err) reject(err); else resolve(data.AudioStream); }); }); }

// Play audio stream function playAudioStream(audioStream) { return new Promise(function (resolve, reject) { var uInt8Array = new Uint8Array(audioStream); var arrayBuffer = uInt8Array.buffer; var blob = new Blob([arrayBuffer]);

34

Page 39: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate を DynamoDB に使用する

var url = URL.createObjectURL(blob); audioPlayer.src = url; audioPlayer.addEventListener("ended", function () { isSpeaking = false; resolve(); }); audioPlayer.play(); }); }

return speaker; } /**************************Audio player****************************/ </script></body></html>

Amazon Translate を Amazon DynamoDB に使用する

この例では、商品レビューを翻訳して Amazon DynamoDB に保存する方法を説明します。後で同じレビューをリクエストすると、Amazon Translate でそれを再度翻訳する必要はなく DynamoDB から返されます。

この例では、以下を実行します。

• AWS CloudFormation を使用して DynamoDB テーブルを作成し、翻訳と TranslateText (p. 97) オペレーションを呼び出す Lambda 関数を保存します。

• AWS Lambda コンソールを使用して関数をテストします。

の例を実行するには

1. example.py のコンテンツをコピーします。これは Python Lambda 関数 (p. 36)で、example.py というファイルにあります。example.py は TranslateText (p. 97) オペレーションを呼び出す Lambda 関数です。ファイルを example.zip という名前の zip アーカイブに圧縮します。関数を実行する AWS リージョンと同じリージョンにある S3 バケットに保存します。

2. template.yamlという名前の新しいファイルを作成します。AWS CloudFormation テンプレートコードをコピーします。これはファイルの AWS CloudFormation テンプレート (p. 38) で見つけることができます。AWS CloudFormation はこのテンプレートを使用してサンプルアプリケーションのリソースを作成します。BUCKET_NAME を example.zip を含む S3 バケットの名前に変更します。ファイルをローカルディレクトリに保存します。

3. AWS マネジメントコンソール にサインインして、https://console.aws.amazon.com/cloudformation でAWS CloudFormation コンソールを開きます。

4. [Create new stack] を選択します。5. [Upload a template to Amazon S3] を選択し、[Choose file] を選択します。ステップ 2 で作成した

template.yaml を選択して、[Next] を選択します。6. スタックの名前を入力し、[Next] を選択します。7. [Options] ページで、[Next] を選択します。8. [AWS CloudFormation によって IAM リソースが作成される場合があることを承認します] および

[AWS CloudFormation によって IAM リソースがカスタム名で作成される場合があることを承認します] を選択します。詳細については、AWS CloudFormation ユーザーガイドの「Controlling Accesswith AWS Identity and Access Management」を参照してください。

35

Page 40: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドコード例

9. [Create Change Set] を選択します。10. AWS CloudFormation によって変更セットが作成されたら、[実行] をクリックします。AWS

CloudFormation によってスタックが作成されるまで待ちます。11. AWS マネジメントコンソール にサインインし、https://console.aws.amazon.com/lambda/ にある

AWS Lambda コンソールを開きます。12. 新規関数を選択します。名前が TestTranslate-ReviewTranslate で始まるものです。13. 関数の詳細ページで、[Test] を選択します。14. [イベント名] に、「TestTranslate」と入力します。[Configure test event] で、以下の JSON と置

き換えます。

{ "review": "hello world", "target_language": "es", "source_language": "en", "review_id": "1"}

[Create] を選択します。15. [TestTranslate] が選択されていることを確認し、[Test] を選択します。テストが終了すると、次の

メッセージが表示されます。

コード例以下のコードを使用して例を作成します。

Python Lambda 関数Python Lambda 関数の内容を以下に示します。Lambda 関数は TranslateText オペレーションを呼び出して、レビュー、ソース言語、およびターゲット言語を渡し、翻訳されたレビューを取得します。このファイルを example.py として保存し、example.zip という .zip アーカイブに圧縮します。このファイルを、例を実行しているリージョンと同じリージョンにある S3 バケットに保存します。

import loggingimport jsonimport boto3import os

translate = boto3.client('translate')dynamodb = boto3.client('dynamodb')firehose = boto3.client('firehose')

TABLE_NAME = os.getenv('TABLE_NAME')

36

Page 41: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドコード例

logger = logging.getLogger()logger.setLevel(logging.INFO)

def lambda_handler(event, context):

logger.info(event)

if 'source_language' in event and 'target_language' in event and 'review' in event and 'review_id' in event: review_id = event['review_id'] source_language = event['source_language'] target_language = event['target_language'] review = event['review']

try: # The Lambda function queries the Amazon DynamoDB table to check whether # the review has already been translated. If the translated review # is already stored in Amazon DynamoDB, the function returns it. response = dynamodb.get_item( TableName=TABLE_NAME, Key={ 'review_id': { 'N': review_id, }, 'language': { 'S': target_language, }, } ) logger.info(response) if 'Item' in response: return response['Item']['review']['S'] except Exception as e: logger.error(response) raise Exception("[ErrorMessage]: " + str(e))

try: # The Lambda function calls the TranslateText operation and passes the # review, the source language, and the target language to get the # translated review. result = translate.translate_text(Text=review, SourceLanguageCode=source_language, TargetLanguageCode=target_language) logging.info("Translation output: " + str(result)) except Exception as e: logger.error(response) raise Exception("[ErrorMessage]: " + str(e))

try: # After the review is translated, the function stores it using # the Amazon DynamoDB putItem operation. Subsequent requests # for this translated review are returned from Amazon DynamoDB. response = dynamodb.put_item( TableName=TABLE_NAME, Item={ 'review_id': { 'N': review_id, }, 'language': { 'S': target_language, }, 'review': { 'S': result.get('TranslatedText') } } )

37

Page 42: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate を使用したウェブページの翻訳

logger.info(response) except Exception as e: logger.error(e) raise Exception("[ErrorMessage]: " + str(e)) return result.get('TranslatedText') else: logger.error(e) raise Exception("[ErrorMessage]: Invalid input ")

AWS CloudFormation テンプレート以下に示しているのは、Lambda 関数と DynamoDB テーブルを作成して設定するために AWSCloudFormation で使用するテンプレートファイルです。例の AWS CloudFormation スタックを作成するときにこのファイルを使用します。BUCKET_NAME を、example.zip ファイルを含む S3 バケットの名前に更新して、ローカルディレクトリに template.yaml として保存します。

AWSTemplateFormatVersion: '2010-09-09'Transform: 'AWS::Serverless-2016-10-31'Resources: ReviewTranslate: Type: 'AWS::Serverless::Function' Properties: Handler: example.lambda_handler Runtime: python2.7 CodeUri: Bucket: BUCKET_NAME Key: example.zip Policies: - AWSLambdaFullAccess - TranslateReadOnly Environment: Variables: TABLE_NAME: !Ref ReviewTable Tracing: "Active" ReviewTable: Type: 'AWS::DynamoDB::Table' Properties: AttributeDefinitions: - AttributeName: "review_id" AttributeType: "N" - AttributeName: "language" AttributeType: "S" KeySchema: - AttributeName: "review_id" KeyType: "HASH" - AttributeName: "language" KeyType: "RANGE" ProvisionedThroughput: ReadCapacityUnits: 5 WriteCapacityUnits: 5

Amazon Translate を使用したウェブページの翻訳Amazon Translate を使用して、ウェブページのコンテンツを翻訳できます。次の Java プログラムは、指定されたウェブページを英語からスペイン語に翻訳し、翻訳結果を含む HTML ファイルを作成します。このプログラムには 2 つの関数があります。

• ソースウェブページからデータを読み取る関数。この関数は、データを HTML 要素に分離してから、2番目の関数を呼び出して要素を翻訳します。ドキュメントの終了時に、HTML ファイルに結果が書き込まれます。

38

Page 43: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate を使用したウェブページの翻訳

• Amazon Translate サービスを呼び出し、HTML 要素のコンテンツを翻訳する関数です。

この例ではネストされた要素のないシンプルな HTML ページを使用します。

例を設定するには

1. AWS SDK for Java をインストールして設定します。SDK for Java をインストールする手順については、「AWS SDK for Java のセットアップ」を参照してください。

2. jsoup Java HTML パーサーをインストールします。手順については、「jsoup」を参照してください。3. この例を実行するための最小限必要なアクセス権限を持つ IAM ユーザーを作成します。IAM ユーザー

の作成方法について詳しくは、AWS Identity and Access Managementユーザーガイドの「AWS アカウント内での IAM ユーザーの作成」を参照してください。必要なアクセス許可ポリシーについては、「Amazon Translate アイデンティティベースのポリシー (p. 53)」を参照してください。

4. サンプルを実行するために必要な認証情報を設定します。手順については、AWS SDK for Java 開発者ガイドの「開発用の AWS 認証情報とリージョンのセットアップ」を参照してください。

5. Java IDE で新しいプロジェクトを作成し、ソースコードをコピーします。6. リージョンとエンドポイントを、Amazon Translate オペレーションを実行するリージョンに変更しま

す。Amazon Translate がサポートされるリージョンのリストについては、AWS 全般リファレンスの「AWS リージョンとエンドポイント」を参照してください。

package com.amazonaws.translateweb; import com.amazonaws.auth.AWSCredentialsProviderChain;import com.amazonaws.auth.EnvironmentVariableCredentialsProvider;import com.amazonaws.auth.SystemPropertiesCredentialsProvider;import com.amazonaws.auth.profile.ProfileCredentialsProvider;import com.amazonaws.client.builder.AwsClientBuilder;import com.amazonaws.services.translate.AmazonTranslate;import com.amazonaws.services.translate.AmazonTranslateClient;import com.amazonaws.services.translate.model.TranslateTextRequest;import com.amazonaws.services.translate.model.TranslateTextResult;import com.amazonaws.AmazonServiceException; import java.io.IOException;import java.io.PrintWriter; import org.jsoup.Jsoup;import org.jsoup.nodes.Document;import org.jsoup.nodes.Element; import org.jsoup.select.Elements; public class TranslateWebPage { public static void main(String[] args) throws InterruptedException { // Define the URL of the HTML content to translate String url = "http://example.com/source.html"; // Create credentials using a provider chain that will evaluate in order; // a) Any Java system properties // b) Any environment variables // c) Any profile file AWSCredentialsProviderChain DefaultAWSCredentialsProviderChain = new AWSCredentialsProviderChain( new SystemPropertiesCredentialsProvider(), new EnvironmentVariableCredentialsProvider(), new ProfileCredentialsProvider()

39

Page 44: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate を使用したウェブページの翻訳

); // Create an endpoint configuration for the Translate service AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration( "endpoint", "region"); // Create a client for the Translate service AmazonTranslate translate = AmazonTranslateClient.builder() .withCredentials(DefaultAWSCredentialsProviderChain) .withEndpointConfiguration(endpointConfiguration).build(); // Record the beginning of translating the HTML content at the url System.out.println("Translating URL: " + url); // Create an empty HTML document to store the parsed data Document doc; try { // Retrieve the HTML located at the URL doc = Jsoup.connect(url).get(); // Select all of the elements in the HTML Elements eles = doc.select("*"); // For each element for (Element ele : eles) { // Translate the element translateElement(ele, translate); // If you encounter service throttling when translating large web // pages, you can request a service limit increase. For details, // see https://aws.amazon.com/premiumsupport/knowledge-center/manage-service-limits/, // or you can throttle your requests by inserting a sleep statement. // Thread.sleep(1000); } // Configure an output file for the translated HTML String fname = "output HTML file name"; PrintWriter pw = new PrintWriter(fname, "UTF-8"); // Write our translated HTML to the output file pw.println(doc); pw.close(); // Record that the file has been saved System.out.println("Saved file "+fname); // Catch any exceptions in retrieving the HTML } catch (IOException e1) { e1.printStackTrace(); }} // This function is used to translate each individual element public static void translateElement(Element ele, AmazonTranslate translate) { // Check if the element has any text if (!ele.ownText().isEmpty()) { // Retrieve the text of the HTML element String text = ele.ownText();

40

Page 45: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate を使用して大きいドキュメントを翻訳する

// Now translate the element's text try { // Translate from English to Spanish TranslateTextRequest request = new TranslateTextRequest() .withText(text) .withSourceLanguageCode("en") .withTargetLanguageCode("es"); // Retrieve the result TranslateTextResult result = translate.translateText(request); // Record the original and translated text System.out.println("Original text: " + text + " - Translated text: "+ result.getTranslatedText()); // Update the HTML element with the translated text ele.text(result.getTranslatedText()); // Catch any translation errors } catch (AmazonServiceException e) { System.err.println(e.getErrorMessage()); System.exit(1); } } else { // We have found a non-text HTML element. No action required. } } }

Amazon Translate を使用して大きいドキュメントを翻訳する

大きいドキュメントをより小さく分割して、合計ドキュメントサイズをドキュメントサイズの制限未満に維持できます。ドキュメントサイズの制限の詳細については、「サービス制限 (p. 68)」を参照してください。次の Java プログラムは長いテキストドキュメントを個別のセンテンスに分割してから、各センテンスをソース言語からターゲット言語に翻訳します。プログラムには 2 つのセクションがあります。

• ソース文字列を個別のセンテンスに分割する SentenceSegmenter クラス。サンプルが JavaBreakIterator クラスを使用します。

• ソース文字列の各センテンスで Translate オペレーションを呼び出す main 関数。main 関数はAmazon Translate による認証も処理します。

例を設定するには

1. AWS SDK for Java をインストールして設定します。SDK for Java をインストールする手順については、「AWS SDK for Java のセットアップ」を参照してください。

2. この例を実行するための最小限必要なアクセス権限を持つ IAM ユーザーを作成します。IAM ユーザーの作成方法について詳しくは、AWS Identity and Access Managementユーザーガイドの「AWS アカウント内での IAM ユーザーの作成」を参照してください。必要なアクセス許可ポリシーについては、「Amazon Translate アイデンティティベースのポリシー (p. 53)」を参照してください。

3. サンプルを実行するために必要な認証情報を設定します。手順については、AWS SDK for Java 開発者ガイドの「開発用の AWS 認証情報とリージョンのセットアップ」を参照してください。

4. Java IDE で新しいプロジェクトを作成し、ソースコードをコピーします。

41

Page 46: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate を使用して大きいドキュメントを翻訳する

5. リージョンを、Amazon Translate オペレーションを実行するリージョンに変更します。AmazonTranslate がサポートされるリージョンのリストについては、AWS 全般リファレンスの「AWS リージョンとエンドポイント」を参照してください。

6. ソース言語とターゲット言語を翻訳する言語に変更します。7. サンプルを実行し、標準出力で翻訳されたテキストを確認します。

import com.amazonaws.auth.AWSCredentialsProviderChain;import com.amazonaws.auth.EnvironmentVariableCredentialsProvider;import com.amazonaws.auth.SystemPropertiesCredentialsProvider;import com.amazonaws.auth.profile.ProfileCredentialsProvider;import com.amazonaws.services.translate.AmazonTranslate;import com.amazonaws.services.translate.AmazonTranslateClient;import com.amazonaws.services.translate.model.TranslateTextRequest;import com.amazonaws.services.translate.model.TranslateTextResult;import java.text.BreakIterator;import java.util.ArrayList;import java.util.List;import java.util.Locale;

public class MultiSentenceTranslator {

public static void main(String[] args) { // Define the text to be translated here String region = "region"; String text = "Text to be translated";

String sourceLang = "source language"; String targetLang = "target language";

// Break text into sentences SentenceSegmenter sentenceSegmenter = new SentenceSegmenter(); List<String> sentences = new ArrayList<>(); try { sentences = sentenceSegmenter.segment(text, sourceLang); } catch (Exception e) { System.out.println(e); System.exit(1); }

// Create credentials using a provider chain that will evaluate in order; // a) Any Java system properties // b) Any environment variables // c) Any profile file AWSCredentialsProviderChain DefaultAWSCredentialsProviderChain = new AWSCredentialsProviderChain( new SystemPropertiesCredentialsProvider(), new EnvironmentVariableCredentialsProvider(), new ProfileCredentialsProvider() );

// Create an Amazon Translate client AmazonTranslate translate = AmazonTranslateClient.builder() .withCredentials(DefaultAWSCredentialsProviderChain) .withRegion(region) .build();

// Translate sentences and print the results to stdout for (String sentence : sentences) { TranslateTextRequest request = new TranslateTextRequest() .withText(sentence) .withSourceLanguageCode(sourceLang) .withTargetLanguageCode(targetLang); TranslateTextResult result = translate.translateText(request);

42

Page 47: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate で署名バージョン 4 を使用する

System.out.println("Original text: " + sentence); System.out.println("Translated text: " + result.getTranslatedText()); } }

}

class SentenceSegmenter { public List<String> segment(final String text, final String lang) throws Exception { List<String> res = new ArrayList<>(); BreakIterator sentenceIterator = BreakIterator.getSentenceInstance(new Locale(lang)); sentenceIterator.setText(text); int prevBoundary = sentenceIterator.first(); int curBoundary = sentenceIterator.next(); while (curBoundary != BreakIterator.DONE) { String sentence = text.substring(prevBoundary, curBoundary); res.add(sentence); prevBoundary = curBoundary; curBoundary = sentenceIterator.next(); } return res; }

}

Amazon Translate で署名バージョン 4 を使用するこの Python プログラムの例では、署名バージョン 4 を使用して Amazon Translate リクエストに認証情報を追加する方法を説明します。この例では、POST リクエストを作成し、翻訳するテキストがリクエストの本文 (ペイロード) に含まれている JSON 構造を作成して、Authorization ヘッダーで認証情報を渡します。署名バージョン 4 の詳細については、アマゾン ウェブ サービス全般のリファレンスの「署名バージョン 4 の署名プロセス」を参照してください。

セットアップこの例を実行するには、次の手順を実行します。

1. AWS Command Line Interface (AWS CLI) をインストールします。AWS SDK for Python (Boto)は、AWS CLI をインストールするときに含まれます。手順については、「ステップ 2: AWSCommand Line Interface (AWS CLI) を設定する (p. 8)」を参照してください。

2. この例を実行するための最小限必要なアクセス権限ポリシーを持つ AWS Identity and AccessManagement (IAM) ユーザーを作成します。IAM ユーザーの作成方法について詳しくは、AWSIdentity and Access Management ユーザーガイドの「AWS アカウント内での IAM ユーザーの作成」を参照してください。必要なアクセス許可ポリシーについては、「Amazon Translate アイデンティティベースのポリシー (p. 53)」を参照してください。ユーザーアクセスキー ID とシークレットアクセスキーを記録します。

3. アクセスキー ID とシークレットアクセスキーを、AWS_ACCESS_KEY andAWS_SECRET_ACCESS_KEY という名前の環境変数にそれぞれ指定します。ベストプラクティスとして、認証情報をコードに埋め込まないことをお勧めします。

4. コンピュータで新しいファイルを作成し、サンプルコード (次のセクションにあります) をコピーしてファイルに貼り付け、ファイルを拡張子 .py で保存します。

5. コードで、region を Amazon Translate TranslateText オペレーションを実行する AWS リージョンの名前に置き換えます。サポートされるリージョンのリストについては、AWS 全般リファレンスの「AWS リージョンとエンドポイント」を参照してください。

43

Page 48: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドコード

コードPython のプログラム例の完全なコードを以下に示します。

リクエストのエンドポイント URL や本文などのリクエスト値を作成すると、コードによって次の処理が実行されます。

1. Amazon Translate TranslateText オペレーションに対する正規リクエストを作成します。2. ハッシュする文字列を作成して署名を作成します。3. 署名を計算します。4. リクエストヘッダーに署名を追加します。5. リクエストを TranslateText オペレーションに送信します。

コンピュータでこの例を実行するには、Python ファイルにコードをコピーします。

# AWS Version 4 signing example

# Translate API (TranslateText)

# For more information about using Signature Version 4, see http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html.# This example makes a POST request to Amazon Translate and # passes the text to translate JSON in the body (payload) # of the request. Authentication information is passed in an # Authorization header.import sys, os, base64, datetime, hashlib, hmacimport requests # pip install requests

# ************* REQUEST VALUES *************method = 'POST'service = 'translate'region = 'region'host = service + '.' + region + '.amazonaws.com'endpoint = 'https://' + host + '/'

# POST requests use a content type header. For Amazon Translate,# the content is JSON.content_type = 'application/x-amz-json-1.1'# Amazon Translate requires an x-amz-target header that has this format:# AWSShineFrontendService_20170701.<operationName>.amz_target = 'AWSShineFrontendService_20170701.TranslateText'

# Pass request parameters for the TranslateText operation in a JSON block.request_parameters = '{'request_parameters += '"Text": "Hello world.",'request_parameters += '"SourceLanguageCode": "en",'request_parameters += '"TargetLanguageCode": "de"'request_parameters += '}'

# The following functions derive keys for the request. For more information, see# http://docs.aws.amazon.com/general/latest/gr/signature-v4-examples.html#signature-v4-examples-python.def sign(key, msg): return hmac.new(key, msg.encode("utf-8"), hashlib.sha256).digest()

def getSignatureKey(key, date_stamp, regionName, serviceName): kDate = sign(('AWS4' + key).encode('utf-8'), date_stamp) kRegion = sign(kDate, regionName) kService = sign(kRegion, serviceName) kSigning = sign(kService, 'aws4_request') return kSigning

44

Page 49: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドコード

# Python can read the AWS access key from environment variables or the configuration file. # In this example, keys are stored in environment variables. As a best practice, do not # embed credentials in code.access_key = os.environ.get('AWS_ACCESS_KEY_ID')secret_key = os.environ.get('AWS_SECRET_ACCESS_KEY')if access_key is None or secret_key is None: print 'No access key is available.' sys.exit()

# Create a timestamp for headers and the credential string.t = datetime.datetime.utcnow()amz_date = t.strftime('%Y%m%dT%H%M%SZ')date_stamp = t.strftime('%Y%m%d') # The date without time is used in the credential scope.

# ************* TASK 1: CREATE A CANONICAL REQUEST *************# For information about creating a canonical request, see http://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html.

# Step 1: Define the verb (GET, POST, etc.), which you have already done.

# Step 2: Create a canonical URI. A canonical URI is the part of the URI from domain to query. # string (use '/' if no path)canonical_uri = '/'

## Step 3: Create the canonical query string. In this example, request# parameters are passed in the body of the request and the query string# is blank.canonical_querystring = ''

# Step 4: Create the canonical headers. Header names must be trimmed,# lowercase, and sorted in code point order from low to high.# Note the trailing \n.canonical_headers = 'content-type:' + content_type + '\n' + 'host:' + host + '\n' + 'x-amz-date:' + amz_date + '\n' + 'x-amz-target:' + amz_target + '\n'

# Step 5: Create the list of signed headers by listing the headers# in the canonical_headers list, delimited with ";" and in alphabetical order.# Note: The request can include any headers. Canonical_headers and# signed_headers should contain headers to include in the hash of the# request. "Host" and "x-amz-date" headers are always required.# For Amazon Translate, content-type and x-amz-target are also required.signed_headers = 'content-type;host;x-amz-date;x-amz-target'

# Step 6: Create the payload hash. In this example, the request_parameters# variable contains the JSON request parameters.payload_hash = hashlib.sha256(request_parameters).hexdigest()

# Step 7: Combine the elements to create a canonical request.canonical_request = method + '\n' + canonical_uri + '\n' + canonical_querystring + '\n' + canonical_headers + '\n' + signed_headers + '\n' + payload_hash

# ************* TASK 2: CREATE THE STRING TO SIGN*************# Set the algorithm variable to match the hashing algorithm that you use, either SHA-256 (recommended) or SHA-1. # algorithm = 'AWS4-HMAC-SHA256'credential_scope = date_stamp + '/' + region + '/' + service + '/' + 'aws4_request'string_to_sign = algorithm + '\n' + amz_date + '\n' + credential_scope + '\n' + hashlib.sha256(canonical_request).hexdigest()

# ************* TASK 3: CALCULATE THE SIGNATURE *************

45

Page 50: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドコード

# Create the signing key using the getSignaturKey function defined above.signing_key = getSignatureKey(secret_key, date_stamp, region, service)

# Sign the string_to_sign using the signing_key.signature = hmac.new(signing_key, (string_to_sign).encode('utf-8'), hashlib.sha256).hexdigest()

# ************* TASK 4: ADD SIGNING INFORMATION TO THE REQUEST *************# Put the signature information in a header named Authorization.authorization_header = algorithm + ' ' + 'Credential=' + access_key + '/' + credential_scope + ', ' + 'SignedHeaders=' + signed_headers + ', ' + 'Signature=' + signature

# For Amazon Translate, the request can include any headers, but it must include "host," "x-amz-date,"# "x-amz-target," "content-type," and "Authorization" headers. Except for the authorization# header, the headers must be included in the canonical_headers and signed_headers values, as# noted earlier. Header order is not significant.# Note: The Python 'requests' library automatically adds the 'host' header.headers = {'Content-Type':content_type, 'X-Amz-Date':amz_date, 'X-Amz-Target':amz_target, 'Authorization':authorization_header}

# ************* TASK 5: SEND THE REQUEST *************print 'Request:\n\t' + request_parameters

response = requests.post(endpoint, data=request_parameters, headers=headers)print 'Response:\n\t' + response.text

46

Page 51: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドデータ保護

Amazon Translate でのセキュリティAWS では、クラウドのセキュリティが最優先事項です。AWS のお客様は、セキュリティを最も重視する組織の要件を満たすように構築されたデータセンターとネットワークアーキテクチャから利点を得られます。

セキュリティは、AWS とお客様の間の共有責任です。共有責任モデルでは、これをクラウドのセキュリティおよびクラウド内のセキュリティとして説明しています。

• クラウドのセキュリティ – AWS は、AWS クラウド内で AWS サービスを実行するインフラストラクチャを保護する責任を担います。また、AWS は、使用するサービスを安全に提供します。AWS コンプライアンスプログラムの一環として、サードパーティーの監査が定期的にセキュリティの有効性をテストおよび検証しています。Amazon Translate に適用するコンプライアンスプログラムの詳細については、「コンプライアンスプログラムによる AWS 対象範囲内のサービス」を参照してください。

• クラウド内のセキュリティ – お客様の責任はお客様が使用する AWS のサービスによって決まります。また、お客様は、お客様のデータの機密性、企業の要件、および適用可能な法律および規制などの他の要因についても責任を担います。

このトピックは、AWS を使用する際に責任共有モデルを適用する方法を理解するのに役立ちます。以下のトピックでは、セキュリティおよびコンプライアンスの目的を達成するために AWS を設定する方法を示します。また、AWS リソースのモニタリングや保護に役立つ他の AWS のサービスの使用方法についても説明します。

トピック• Amazon Translate でのデータ保護 (p. 47)• Amazon Translate の Identity and Access Management (p. 48)• Amazon Translate のモニタリング (p. 60)• Amazon Translate のコンプライアンス検証 (p. 66)• Amazon Translate の耐障害性 (p. 67)• Amazon Translate のインフラストラクチャセキュリティ (p. 67)

Amazon Translate でのデータ保護Amazon Translate は、データ保護の規制やガイドラインを含む AWS 責任共有モデルに準拠しています。AWS は、AWS のすべてのサービスを実行するグローバルなインフラストラクチャを保護する責任を担います。また、AWS は、カスタマーコンテンツおよび個人データを取り扱うためのセキュリティ構成の統制など、このインフラストラクチャ上でホストされるデータ管理を維持します。データ管理者または処理者として機能する、AWS のお客様および APN パートナーは、AWS クラウドに保存された個人データに対する責任を担います。

データ保護目的の場合、AWS アカウント認証情報を保護して IAM (AWS Identity and AccessManagement) で個々のユーザーアカウントをセットアップし、そのユーザーに各自の職務を果たすために必要なアクセス許可のみが付与されるようにすることをお勧めします。また、以下の方法でデータを保護することをお勧めします。

• 各アカウントで多要素認証 (MFA) を使用します。• SSL/TLS を使用して AWS リソースと通信します。• AWS CloudTrail で API とユーザーアクティビティログをセットアップします。

47

Page 52: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド保管時の暗号化

• AWS 暗号化ソリューションを、AWS サービス内のすべてのデフォルトのセキュリティ管理と一緒に使用します。

• Amazon Macie などの高度なマネージドセキュリティサービスを使用します。これにより、AmazonSimple Storage Service (Amazon S3) に保存される個人データの検出と保護が支援されます。

顧客のアカウント番号などの機密の識別情報は、[名前] フィールドなどの自由形式のフィールドに配置しないことを強くお勧めします。これは、コンソール、API、AWS CLI、または AWS SDK で AmazonTranslate または他の AWS サービスを使用する場合も同様です。Amazon Translate または他のサービスに入力したデータはすべて、診断ログの内容として取得される可能性があります。外部サーバーへの URLを指定するときは、そのサーバーへのリクエストを検証するための認証情報を URL に含めないでください。

データ保護の詳細については、AWS セキュリティブログのブログ投稿「AWS の責任共有モデルとGDPR」を参照してください。

トピック• 保管時の暗号化 (p. 48)• キーの管理 (p. 48)

保管時の暗号化Amazon Translate では、S3 バケットに配置された翻訳内容のサーバー側の暗号化に、デフォルトのAmazon S3 キー (SSE-S3) が使用されます。

Amazon Translate では、デフォルトキーで暗号化された Amazon Elastic Block Store (Amazon EBS) ボリュームが使用されます。

キーの管理デフォルトの Amazon S3 キーは AWS によって管理されます。お客様が提供する AWS Key ManagementService (AWS KMS) キーを管理するのは、お客様の責任です。

Amazon Translate の Identity and AccessManagement

AWS Identity and Access Management (IAM) は、管理者が AWS リソースへのアクセスを安全にコントロールするために役立つ AWS のサービスです。IAM 管理者は、Amazon Translate リソースを使用するために認証 (サインイン) および承認 (アクセス許可を持つ) される者を制御します。IAM は、追加料金なしで使用できる AWS のサービスです。

トピック• 対象者 (p. 49)• アイデンティティを使用した認証 (p. 49)• ポリシーを使用したアクセスの管理 (p. 51)• Amazon Translate と IAM の連携 (p. 52)• Amazon Translate アイデンティティベースのポリシーの例 (p. 54)• ユーザーに自分のアクセス許可の表示を許可 (p. 57)• Amazon Translate でのアイデンティティとアクセスに関するトラブルシューティング (p. 58)• Amazon Translate API のアクセス権限: アクション、リソース、条件リファレンス (p. 60)

48

Page 53: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド対象者

対象者AWS Identity and Access Management (IAM) の用途は、Amazon Translate で行う作業によって異なります。

サービスユーザー – ジョブを実行するために Amazon Translate サービスを使用する場合は、管理者が必要なアクセス許可と認証情報を用意します。作業を実行するためにさらに多くの Amazon Translate 機能を使用するとき、追加のアクセス許可が必要になる場合があります。アクセスの管理方法を理解すると、管理者から適切なアクセス許可をリクエストするのに役に立ちます。Amazon Translate の機能にアクセスできない場合は、「Amazon Translate でのアイデンティティとアクセスに関するトラブルシューティング (p. 58)」を参照してください。

サービス管理者 – 社内の Amazon Translate リソースを担当している場合は、おそらく Amazon Translateへのフルアクセスがあります。従業員がどの Amazon Translate 機能とリソースアクセスする必要があるかを決定するのは管理者の仕事です。その後で、サービスユーザーのアクセス許可を変更するために、IAM 管理者にリクエストを送信する必要があります。IAM の基本概念については、このページの情報を確認します。お客様の会社で Amazon Translate の IAM を利用する方法の詳細については、「AmazonTranslate と IAM の連携 (p. 52)」を参照して ください。

IAM 管理者 – IAM 管理者は、Amazon Translate へのアクセスを管理するポリシーの作成方法の詳細について確認する場合があります。IAM で使用できる Amazon Translate アイデンティティベースのポリシーの例を表示するには、「Amazon Translate アイデンティティベースのポリシーの例 (p. 54)」を参照してください。

アイデンティティを使用した認証認証は、アイデンティティ認証情報を使用して AWS にサインインする方法です。AWS マネジメントコンソール を使用するサインインの詳細については、IAM ユーザーガイド の「IAM コンソールとサインインページ」を参照してください。

AWS アカウントのルートユーザー、IAM ユーザーとして、または IAM ロールを引き受けて、認証されている (AWS にサインインしている) 必要があります。会社のシングルサインオン認証を使用することも、Google や Facebook を使用してサインインすることもできます。このような場合、管理者は以前にIAM ロールを使用して ID フェデレーションを設定しました。他の会社の認証情報を使用して AWS にアクセスした場合、ロールを間接的に割り当てられています。

AWS マネジメントコンソール へ直接サインインするには、ルートユーザー E メールまたは IAM ユーザー名とパスワードを使用します。ルートユーザー または IAM を使用して AWS にプログラム的にアクセスできます。AWS では、SDK とコマンドラインツールを提供して、お客様の認証情報を使用して、リクエストに暗号で署名できます。AWS ツールを使用しない場合は、リクエストに自分で署名する必要があります。これには、インバウンド API リクエストを認証するためのプロトコル、署名バージョン 4 を使用します。リクエストの認証の詳細については、AWS General Referenceの「署名バージョン 4 の署名プロセス」を参照してください。

使用する認証方法を問わず、追加のセキュリティ情報の提供を要求される場合もあります。たとえば、AWS では多要素認証 (MFA) を使用してアカウントのセキュリティを高めることを推奨しています。詳細については、IAM ユーザーガイドの「AWS のデバイスに多要素認証 (MFA) を使用」を参照してください。

AWS アカウントのルートユーザーAWS アカウントを初めて作成する場合は、このアカウントのすべての AWS サービスとリソースに対して完全なアクセス権限を持つシングルサインインアイデンティティで始めます。このアイデンティティはAWS アカウント ルートユーザー と呼ばれ、アカウントの作成に使用した E メールアドレスとパスワードでのサインインによりアクセスします。強くお勧めしているのは、日常的なタスクには、それが管理者タスクであっても、ルートユーザーを使用しないことです。代わりに、最初の IAM ユーザーを作成するため

49

Page 54: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドアイデンティティを使用した認証

だけに ルートユーザー を使用するというベストプラクティスに従います。その後、ルートユーザー認証情報を安全な場所に保管し、それらを使用して少数のアカウントおよびサービス管理タスクのみを実行します。

IAM ユーザーとグループIAM ユーザーは、単一のユーザーまたはアプリケーションに特定のアクセス許可がある AWS アカウント内のアイデンティティです。IAM ユーザーは、ユーザー名とパスワード、アクセスキーのセットなど、長期的な認証情報を持つことができます。アクセスキーを生成する方法の詳細については、IAM ユーザーガイド の「IAM ユーザーのアクセスキーの管理」を参照してください。IAM ユーザーにアクセスキーを生成するとき、必ずキーペアを表示して安全に保存してください。後になって、シークレットアクセスキーを回復することはできません。新しいアクセスキーペアを生成する必要があります。

IAM グループは、IAM ユーザーのコレクションを指定するアイデンティティです。グループとしてサインインすることはできません。グループを使用して、一度に複数のユーザーに対してアクセス許可を指定できます。多数の組のユーザーがある場合、グループを使用すると管理が容易になります。たとえば、IAMAdmin という名前のグループを設定して、そのグループに IAM リソースを管理するアクセス許可を与えることができます。

ユーザーは、ロールとは異なります。ユーザーは 1 人の特定の人またはアプリケーションに一意に関連付けられますが、ロールはそれを必要とする任意の人が引き受けるようになっています。ユーザーには永続的な長期の認証情報がありますが、ロールでは一時的な認証情報が利用できます。詳細については、IAMユーザーガイド の「IAM ユーザーの作成が適している場合 (ロールではなく)」を参照してください。

IAM ロールIAM ロールは、特定のアクセス許可を持つ、AWS アカウント内のアイデンティティです。これは IAMユーザーに似ていますが、特定のユーザーに関連付けられていません。ロールを切り替えて、AWS マネジメントコンソール で IAM ロールを一時的に引き受けることができます。ロールを引き受けるには、AWSCLI または AWS API オペレーションを呼び出すか、カスタム URL を使用します。ロールを使用する方法の詳細については、IAM ユーザーガイド の「IAM ロールの使用」を参照してください。

IAM ロールと一時的な認証情報は、次の状況で役立ちます。

• 一時的な IAM ユーザーアクセス許可 – IAM ユーザーは、特定のタスクに対して複数の異なるアクセス許可を一時的に IAM ロールで引き受けることができます。

• フェデレーティッドユーザーアクセス – IAM ユーザーを作成する代わりに、AWS Directory Service、エンタープライズユーザーディレクトリ、またはウェブ ID プロバイダーに既存のアイデンティティを使用できます。このようなユーザーはフェデレーティッドユーザーと呼ばれます。AWS では、ID プロバイダーを通じてアクセスがリクエストされたとき、フェデレーティッドユーザーにロールを割り当てます。フェデレーティッドユーザーの詳細については、IAM ユーザーガイドの「フェデレーティッドユーザーとロール」を参照してください。

• クロスアカウントアクセス – IAM ロールを使用して、自分のアカウントのリソースにアクセスすることを別のアカウントの信頼済みプリンシパルに許可できます。ロールは、クロスアカウントアクセスを許可する主な方法です。ただし、一部の AWS のサービスでは、(ロールをプロキシとして使用する代わりに) リソースにポリシーを直接アタッチできます。クロスアカウントアクセスでのロールとリソースベースのポリシーの違いの詳細については、IAM ユーザーガイド の「IAM ロールとリソースベースのポリシーとの相違点」を参照してください。

• AWS サービスアクセス – サービスロールは、サービスがお客様に代わってお客様のアカウントでアクションを実行するために引き受ける IAM ロールです。一部の AWS のサービス環境を設定するときに、サービスが引き受けるロールを定義する必要があります。このサービスロールには、サービスが必要とする AWS のリソースにサービスがアクセスするために必要なすべてのアクセス権限を含める必要があります。サービスロールはサービスによって異なりますが、多くのサービスロールでは、そのサービスの文書化された要件を満たしている限り、アクセス権限を選択することができます。サービスロールは、お客様のアカウント内のみでアクセスを提供します。他のアカウントのサービスへのアクセス権を付与するためにサービスロールを使用することはできません。IAM 内部からロールを作成、修正、削除できます。たとえば、Amazon Redshift がお客様に代わって Amazon S3 バケットにアクセスし、バケッ

50

Page 55: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドポリシーを使用したアクセスの管理

トからデータを Amazon Redshift クラスターにロードすることを許可するロールを作成できます。詳細については、IAM ユーザーガイドのAWS サービスにアクセス権限を委任するロールの作成を参照してください。

• Amazon EC2で実行されているアプリケーション – IAM ロールを使用して、EC2 インスタンスで実行され、AWS CLI または AWS API リクエストを作成しているアプリケーションの一時的な認証情報を管理できます。これは、EC2 インスタンス内でのアクセスキーの保存に推奨されます。AWS ロールを EC2インスタンスに割り当て、そのすべてのアプリケーションで使用できるようにするには、インスタンスにアタッチされたインスタンスプロファイルを作成します。インスタンスプロファイルにはロールが含まれ、EC2 インスタンスで実行されるプログラムは一時認証情報を取得することができます。詳細については、IAM ユーザーガイドの「Amazon EC2 インスタンスで実行されるアプリケーションに IAM ロールを使用してアクセス権限を付与する」を参照してください。

IAM ロールを使用するべきかどうかについては、IAM ユーザーガイド の「IAM ロール (ユーザーではない)の作成が適している場合」を参照してください。

ポリシーを使用したアクセスの管理AWS でアクセスをコントロールするには、ポリシーを作成して IAM アイデンティティや AWS リソースにアタッチします。ポリシーは AWS のオブジェクトであり、アイデンティティやリソースに関連付けて、これらのアクセス許可を定義します。AWS は、エンティティ (ルートユーザー、IAM ユーザーまたはIAM ロール) によってリクエストが行われると、それらのポリシーを評価します。ポリシーでのアクセス許可により、リクエストが許可されるか拒否されるかが決まります。大半のポリシーは JSON ドキュメントとして AWS に保存されます。JSON ポリシードキュメントの構造と内容の詳細については、IAM ユーザーガイド の「JSON ポリシー概要」を参照してください。

IAM 管理者は、ポリシーを使用して、AWS リソースへのアクセスを許可するユーザーと、これらのリソースで実行できるアクションを指定できます。すべての IAM エンティティ (ユーザーまたはロール) は、アクセス許可のない状態からスタートします。言い換えると、デフォルト設定では、ユーザーは何もできず、自分のパスワードを変更することすらできません。何かを実行するアクセス許可をユーザーに付与するには、管理者がユーザーにアクセス許可ポリシーをアタッチする必要があります。また、管理者は、必要なアクセス許可があるグループにユーザーを追加できます。管理者がグループにアクセス許可を付与すると、そのグループ内のすべてのユーザーにこれらのアクセス許可が付与されます。

IAM ポリシーは、オペレーションの実行方法を問わず、アクションのアクセス許可を定義します。たとえば、iam:GetRole アクションを許可するポリシーがあるとします。このポリシーがあるユーザーは、AWS マネジメントコンソール、AWS CLI、または AWS API からロールの情報を取得できます。

アイデンティティベースのポリシーアイデンティティベースのポリシーは、IAM ユーザー、ロール、グループなどのアイデンティティにJSON ドキュメントとしてアタッチできるアクセス許可ポリシーです。これらのポリシーは、アイデンティティが実行できるアクション、リソース、および条件を制御します。アイデンティティベースのポリシーを作成する方法については、IAM ユーザーガイド の「IAM ポリシー の 作成」を参照してください 。

アイデンティティベースのポリシーは、さらにインラインポリシーまたは管理ポリシーに分類できます。インラインポリシーは、単一のユーザー、グループ、またはロールに直接埋め込まれています。管理ポリシーは、AWS アカウント内の複数のユーザー、グループ、およびロールにアタッチできるスタンドアロンポリシーです。管理ポリシーには、AWS 管理ポリシーとカスタマー管理ポリシーが含まれます。管理ポリシーまたはインラインポリシーのいずれかを選択する方法については、IAM ユーザーガイド の「管理ポリシーとインラインポリシーの比較」を参照してください。

リソースベースのポリシーリソースベースのポリシーは、Amazon S3 バケットなどのリソースにアタッチする JSON ポリシードキュメントです。サービス管理者は、これらのポリシーを使用して、特定のプリンシパル (アカウントメンバー、ユーザー、またはロール) がそのリソースに対して実行する条件およびアクションを定義するこ

51

Page 56: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate と IAM の連携

とができます。リソースベースのポリシーはインラインポリシーです。マネージド型のリソースベースのポリシーはありません。

アクセスコントロールリスト (ACL)アクセスコントロールポリシー (ACL) は、どのプリンシパル (アカウントメンバー、ユーザー、またはロール) がリソースにアクセスするためのアクセス許可を持つかを制御します。ACL は、リソースベースのポリシーと似ていますが、JSON ポリシードキュメント形式を使用しない唯一のポリシータイプです。ACL をサポートするサービスの例としては、Amazon S3、AWS WAF、Amazon VPC などがあります。ACL の詳細については、『Amazon Simple Storage Service 開発者ガイド』の「アクセスコントロールリスト (ACL) の概要」を参照してください。

その他のポリシータイプAWS では、別のあまり一般的ではないポリシータイプもサポートしています。これらのポリシータイプでは、より一般的なポリシータイプで付与された最大のアクセス許可を設定できます。

• アクセス許可の境界 – アクセス許可の境界は、アイデンティティベースのポリシーが IAM エンティティ(IAM ユーザーまたはロール) に付与できるアクセス許可の上限を設定する高度な機能です。エンティティのアクセス許可の境界を設定できます。結果として得られるアクセス許可は、エンティティの IDベースのポリシーとそのアクセス許可の境界の共通部分です。Principal フィールドでユーザーまたはロールを指定するリソースベースのポリシーは、アクセス許可の境界では制限されません。これらのポリシーのいずれかを明示的に拒否した場合、その許可は無効になります。アクセス許可の境界の詳細については、IAM ユーザーガイド の「IAM エンティティのアクセス許可の境界」を参照してください。

• サービスコントロールポリシー (SCP) – SCP は、AWS Organizations で 組織や組織単位 (OU) に最大権限を指定する JSON ポリシーです。AWS Organizations は、お客様のビジネスが所有する複数の AWSアカウントをグループ化し、一元的に管理するサービスです。組織内のすべての機能を有効にすると、サービス制御ポリシー (SCP) を一部またはすべてのアカウントに適用できます。SCP はメンバーアカウントのエンティティに対するアクセス許可を制限します (各 AWS アカウントのルートユーザー など)。組織 および SCP の詳細については、AWS Organizations ユーザーガイド の「SCP の動作」を参照してください。

• セッションポリシー – セッションポリシーは、ロールまたはフェデレーティッドユーザーの一時セッションをプログラムで作成する際にパラメータとして渡す高度なポリシーです。結果として得られるセッションのアクセス許可は、ユーザーまたはロールの ID ベースのポリシーとセッションポリシーの共通部分です。また、リソースベースのポリシーからアクセス許可が派生する場合もあります。これらのポリシーのいずれかを明示的に拒否した場合、その許可は無効になります。詳細については、IAM ユーザーガイド の「セッションポリシー」を参照してください。

複数のポリシータイプ1 つのリクエストに複数のタイプのポリシーが適用されると、結果として作成されるアクセス許可を理解するのがさらに複雑になります。複数のポリシータイプが関連するとき、リクエストを許可するかどうかを AWS が決定する方法の詳細については、IAM ユーザーガイド の「ポリシーの評価ロジック」を参照してください。

Amazon Translate と IAM の連携Amazon Translate オペレーションおよびリソースへのアクセスは、AWS Identity and AccessManagement で管理できます。Amazon Translate へのアクセスを管理するために AWS Identity andAccess Management (IAM) を使用する前に、Amazon Translate でどの IAM 機能が使用できるかを理解しておく必要があります。Amazon Translate およびその他の AWS のサービスが IAM と連携する方法の概要を理解するには、IAM ユーザーガイド の「AWS と連携する IAM サービス」を参照してください。

トピック• Amazon Translate アイデンティティベースのポリシー (p. 53)

52

Page 57: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate と IAM の連携

• Amazon Translate リソースベースのポリシー (p. 54)• Amazon Translate タグに基づいた承認 (p. 54)• Amazon Translate IAM ロール (p. 54)

Amazon Translate アイデンティティベースのポリシーIAM アイデンティティベースのポリシーでは、許可または拒否されたアクションとリソースを指定でき、さらにアクションが許可または拒否された条件を指定できます。Amazon Translate は、特定のアクション、リソース、および条件キーをサポートします。JSON ポリシーで使用するすべての要素については、IAM ユーザーガイド の「IAM JSON ポリシーエレメントのリファレンス」を参照してください 。

アクションIAM アイデンティティベースのポリシーの Action エレメントは、そのポリシーにより許可または拒否される特定のアクションについて説明します。ポリシーアクションの名前は通常、関連する AWS API オペレーションと同じです。このアクションは、関連付けられたオペレーションを実行するためのアクセス許可を付与するポリシーで使用されます。

Amazon Translate のポリシーアクションは、アクションの前にプレフィックス translate: を使用します。たとえば、Amazon Translate TranslateText API オペレーションで翻訳を実行する権限をユーザーに付与するには、管理者としてログインし、そのユーザーのポリシーに translate:TranslateTextアクションを含めます。ポリシーステートメントには、Action 要素あるいは NotAction 要素を含める必要があります。Amazon Translate は、このサービスで実行できるタスクを説明する独自の一連のアクションを定義します。Amazon Translate のアクションの一覧を表示するには、IAM ユーザーガイド の「Actions Defined by Amazon Translate」を参照してください。

単一のステートメントに複数のアクションを指定するには、次のようにコンマで区切ります。

"Action": [ "translate:action1", "translate:action2"

リソースAmazon Translate では、ポリシーでリソースの Amazon リソースネーム (ARN) を指定することはできません。

条件キーAmazon Translate にはサービス固有条件キーがありませんが、いくつかのグローバル条件キーの使用がサポートされています。すべての AWS グローバル条件キーを確認するには、IAM ユーザーガイド の「AWSグローバル条件コンテキストキー」を参照してください 。

Condition エレメント (または Condition ブロック) を使用すると、ステートメントが有効な条件を指定できます。Conditionエレメントはオプションです。イコールや以下などの条件演算子を使用する条件式を構築して、リクエスト内に値のあるポリシーの条件に一致させることができます。

1 つのステートメントに複数の Condition エレメントを指定する場合、または 1 つの Condition エレメントに複数のキーを指定する場合、AWS が論理 AND 演算を使用してそれらを評価します。単一の条件キーに複数の値を指定する場合、AWS が論理 OR 演算を使用して条件を評価します。ステートメントのアクセス許可が付与される前にすべての条件が満たされる必要があります。

条件を指定する際にプレースホルダー変数も使用できます。たとえば、IAM ユーザー名でタグ付けされている場合のみ、リソースにアクセスする IAM ユーザーアクセス許可を付与できます。詳細については、IAM ユーザーガイド の「IAM ポリシーエレメント: 変数およびタグ」を参照してください。

53

Page 58: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドアイデンティティベースのポリシーの例

Amazon Translate アイデンティティベースのポリシーの例については、「Amazon Translate アイデンティティベースのポリシーの例 (p. 54)」を参照してください。

Amazon Translate リソースベースのポリシーAmazon Translate では、リソースベースのポリシーはサポートされていません。

Amazon Translate タグに基づいた承認Amazon Translate は、リソースのタグ付けやタグに基づいたアクセスの制御をサポートしていません。

Amazon Translate IAM ロールIAM ロールは、特定のアクセス許可を持つ、AWS アカウント内のエンティティです。

Amazon Translate を使用した一時的な認証情報の使用一時的な認証情報を使用して、フェデレーションでサインイン、IAM ロールを引き受ける、またはクロスアカウントロールを引き受けることができます。一時的なセキュリティ認証情報を取得するには、AssumeRole または GetFederationToken などの AWS Security Token Service (AWS STS) API オペレーションを呼び出します。

Amazon Translate では、一時認証情報の使用をサポートしています。

サービスにリンクされたロールサービスにリンクされたロールによって、AWS サービスが他のサービスのリソースにアクセスして自動的にアクションを完了できます。サービスにリンクされたロールは、IAM アカウント内に表示され、サービスによって所有されます。IAM 管理者は、サービスにリンクされたロールのアクセス許可を表示できますが、編集することはできません。

Amazon Translate はサービスにリンクされたロールをサポートしていません。

Amazon Translate アイデンティティベースのポリシーの例デフォルトでは、IAM ユーザーおよびロールには、Amazon Translate リソースを作成または変更するアクセス許可がありません。また、AWS マネジメントコンソール、AWS CLI、または AWS API を使用してタスクを実行することもできません。IAM 管理者は、ユーザーとロールに必要な、特定のリソースで特定の API オペレーションを実行するアクセス許可をユーザーとロールに付与する IAM ポリシーを作成する必要があります。続いて、管理者はそれらのアクセス権限が必要な IAM ユーザーまたはグループにそのポリシーをアタッチします。

JSON ポリシードキュメントの以下の例を使用して、IAM アイデンティティベースのポリシーを作成する方法については、IAM ユーザーガイドの「[JSON] タブでのポリシーの作成」を参照してください。

トピック• アイデンティティベースのポリシーのベストプラクティス (p. 54)• Amazon Translate コンソールの使用 (p. 55)• カスタム用語でカスタマー管理キーを使用するためのアクセス許可 (p. 56)

アイデンティティベースのポリシーのベストプラクティスアイデンティティベースのポリシーは非常に強力です。アカウント内で、Amazon Translate リソースを作成、アクセス、または削除できるかどうかを決定します。これらのアクションを実行すると、AWS アカウ

54

Page 59: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドアイデンティティベースのポリシーの例

ントに追加料金が発生する可能性があります。アイデンティティベースのポリシーを作成または編集するときは、以下のガイドラインと推奨事項に従います。

• AWS 管理ポリシーの使用を開始する – Amazon Translate の使用をすばやく開始するには、AWS 管理ポリシーを使用して、従業員に必要なアクセス許可を付与します。これらのポリシーはアカウントですでに有効になっており、AWS によって管理および更新されています。詳細については、IAM ユーザーガイド の「AWS 管理ポリシーを使用したアクセス許可の使用開始」を参照してください 。

• 最小権限を付与する – カスタムポリシーを作成するときは、タスクを実行するために必要なアクセス許可のみを付与します。最小限のアクセス権限から開始し、必要に応じて追加のアクセス権限を付与します。この方法は、寛容なアクセス権限で始め、後でそれらを強化しようとするよりも安全です。詳細については、IAM ユーザーガイド の「最小権限を付与する」を参照してください。

• 機密性の高いオペレーションに MFA を有効にする – 追加セキュリティとして、機密性の高リソースまたは API オペレーションにアクセスするために IAM ユーザーに対して、多要素認証 (MFA) の使用を要求します。詳細については、IAM ユーザーガイドの「AWS のデバイスに 多要素認証 (MFA) を使用」を参照してください。

• 追加セキュリティに対するポリシー条件を使用する – 実行可能な範囲内で、アイデンティティベースのポリシーがリソースにアクセスできる条件を定義します。たとえば、要求が発生しなければならない許容 IP アドレスの範囲を指定するための条件を記述できます。指定された日付または時間範囲内でのみリクエストを許可する条件を書くことも、SSL や MFA の使用を要求することもできます。ポリシー要素の詳細については、IAM ユーザーガイド の「IAM JSON ポリシー要素: 条件」を参照してください。

Amazon Translate コンソールの使用Amazon Translate コンソールにアクセスするには、一連の最小限のアクセス許可が必要です。これらのアクセス許可により、AWS アカウントの Amazon Translate リソースの詳細をリストおよび表示できます。最小限必要なアクセス許可よりも制限されたアイデンティティベースのポリシーを作成すると、そのポリシーをアタッチしたエンティティ (IAM ユーザーまたはロール) に対してはコンソールが意図したとおりに機能しません。

これらのエンティティが Amazon Translate コンソールを使用できるように、エンティティに次の AWS 管理対象ポリシーもアタッチします。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "translate:*", "comprehend:DetectDominantLanguage", "cloudwatch:GetMetricStatistics", "cloudwatch:ListMetrics" ], "Resource": "*"

} ]}

このポリシーには 4 つのステートメントがあります。1 つ目は TranslateText オペレーションを使用するアクセス許可が付与されます。2 つ目は Amazon Comprehend DetectDominantLanguage オペレーションに自動言語検出を有効にするアクセス許可が付与されます。最後の 2 つのアクセス許可では、メトリクスのサポートを提供するアクセス許可を Amazon CloudWatch に付与します。

AWS CLI または AWS API のみを呼び出すユーザーには、最小限のコンソールアクセス許可を付与する必要はありません。代わりに、実行しようとしている API オペレーションに一致するアクションのみへのアクセスが許可されます。詳細については、IAM ユーザーガイド の「ユーザーへのアクセス許可の追加」を参照してください。

55

Page 60: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドアイデンティティベースのポリシーの例

カスタム用語でカスタマー管理キーを使用するためのアクセス許可Amazon Translate カスタム用語で AWS Key Management Service (AWS KMS) カスタマー管理キー(CMK) を使用する場合、AWS KMS キーポリシーに追加のアクセス許可が必要になる場合があります。

AWS KMS CMK を使用して ImportTerminology オペレーションを呼び出すには、既存の AWS KMSキーポリシーに以下のアクセス許可を追加します。

{ "Id": "key-consolepolicy-3", "Version": "2012-10-17", "Statement": [ { "Sid": "Allow access for use with Amazon Translate", "Effect": "Allow", "Principal": { "AWS": "IAM USER OR ROLE ARN" }, "Action": [ "kms:CreateGrant", "kms:DescribeKey", "kms:GenerateDataKey", "kms:RetireGrant" ], "Resource": "*" } ]}

KMS CMK でインポートされたカスタム用語に対して GetTerminology オペレーションを呼び出すには、AWS KMS キーポリシーに以下のアクセス許可を追加します。

{ "Id": "key-consolepolicy-3", "Version": "2012-10-17", "Statement": [ { "Sid": "Allow access for use with Amazon Translate", "Effect": "Allow", "Principal": { "AWS": "IAM USER OR ROLE ARN" }, "Action": [ "kms:Decrypt" ], "Resource": "*" } ]}

AWS KMS CMK でインポートされたカスタム用語に対して ListTerminologies またはDeleteTermionlogy オペレーションを呼び出すために、特別な AWS KMS のアクセス許可は必要ありません。

すべてのカスタム用語オペレーションで CMK を使用するには、AWS KMS キーポリシーに以下のアクセス許可を追加します。

{ "Id": "key-consolepolicy-3",

56

Page 61: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドユーザーに自分のアクセス許可の表示を許可

"Version": "2012-10-17", "Statement": [ { "Sid": "Allow access for use with Amazon Translate", "Effect": "Allow", "Principal": { "AWS": "IAM USER OR ROLE ARN" }, "Action": [ "kms:CreateGrant", "kms:DescribeKey", "kms:GenerateDataKey", "kms:RetireGrant", "kms:Decrypt" ], "Resource": "*" } ]}

Amazon Translate API アクションとそれらが適用されるリソースについては、「Amazon Translate API のアクセス権限: アクション、リソース、条件リファレンス (p. 60)」を参照してください。

ユーザーに自分のアクセス許可の表示を許可この例は

この例では、ユーザー ID にアタッチされたインラインおよび管理ポリシーの表示を IAM ユーザーに許可するポリシーを作成する方法を示します。このポリシーには、コンソールで、または AWS CLI か AWSAPI を使用してプログラム的に、このアクションを完了するアクセス許可が含まれています。

{ "Version": "2012-10-17", "Statement": [ { "Sid": "ViewOwnUserInfo", "Effect": "Allow", "Action": [ "iam:GetUserPolicy", "iam:ListGroupsForUser", "iam:ListAttachedUserPolicies", "iam:ListUserPolicies", "iam:GetUser" ], "Resource": [ "arn:aws:iam::*:user/${aws:username}" ] }, { "Sid": "NavigateInConsole", "Effect": "Allow", "Action": [ "iam:GetGroupPolicy", "iam:GetPolicyVersion", "iam:GetPolicy", "iam:ListAttachedGroupPolicies", "iam:ListGroupPolicies", "iam:ListPolicyVersions", "iam:ListPolicies", "iam:ListUsers" ], "Resource": "*" } ]

57

Page 62: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドトラブルシューティング

}

Amazon Translate でのアイデンティティとアクセスに関するトラブルシューティング次の情報は、Amazon Translate と AWS Identity and Access Management (IAM) の使用に伴って発生する可能性がある一般的な問題の診断や修復に役立ちます。

トピック• Amazon Translate でアクションを実行する権限がない (p. 58)• iam:PassRole を実行する権限がない (p. 58)• マイアクセスキーを表示したい (p. 59)• 管理者として Amazon Translate へのアクセスを他のユーザーに許可したい (p. 59)• 自分の AWS アカウント以外のユーザーに Amazon Translate リソースへのアクセスを許可した

い (p. 59)

Amazon Translate でアクションを実行する権限がないAWS マネジメントコンソール から、アクションを実行する権限がないと通知された場合は、管理者に問い合わせてサポートを依頼してください。お客様のユーザー名とパスワードを発行したのが、担当の管理者です。

たとえば、mateojackson IAM ユーザーがコンソールを使用してテキストを翻訳しようとするときに、translate:TranslateText アクセス許可がない場合に次のエラーが発生します。

User: arn:aws:iam::123456789012:user/mateojackson is not authorized to perform: translate:TranslateText

Mateo は、translate:TranslateText アクションを使用するために、ポリシーの更新を管理者に依頼します。

iam:PassRole を実行する権限がないiam:PassRole アクションを実行する権限がないというエラーが表示された場合、管理者に問い合わせ、サポートを依頼する必要があります。お客様のユーザー名とパスワードを発行したのが、担当の管理者です。Amazon Translate にロールを渡すことができるようにポリシーを更新するよう、管理者に依頼します。

一部の AWS サービスでは、新しいサービスロールまたはサービスにリンクされたロールを作成せずに、既存のロールをサービスに渡すことができます。そのためには、サービスにロールを渡すアクセス許可が必要です。

以下の例のエラーは、marymajor という IAM ユーザーがコンソールを使用して Amazon Translate でアクションを実行しようする場合に発生します。ただし、アクションでは、サービスロールによって付与されたアクセス許可がサービスにある必要があります。メアリーには、ロールをサービスに渡すアクセス許可がありません。

User: arn:aws:iam::123456789012:user/marymajor is not authorized to perform: iam:PassRole

この場合、メアリーは担当の管理者に iam:PassRole アクションを実行できるようにポリシーの更新を依頼します。

58

Page 63: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドトラブルシューティング

マイアクセスキーを表示したいIAM ユーザーアクセスキーを作成した後は、いつでもアクセスキー ID を表示できます。ただし、シークレットアクセスキーをもう一度表示することはできません。シークレットアクセスキーを紛失した場合は、新しいキーペアを作成する必要があります。

アクセスキーは、アクセスキー ID (例: AKIAIOSFODNN7EXAMPLE) とシークレットアクセスキー (例:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY) の 2 つの部分から構成されます。ユーザー名とパスワードと同様に、リクエストを認証するために、アクセスキー ID とシークレットアクセスキーの両方を使用する必要があります。ユーザー名とパスワードと同様に、アクセスキーをしっかり管理してください。

Important

正規ユーザー ID を確認するためであっても、アクセスキーをサードパーティーに提供しないでください。提供すると、第三者がアカウントへの永続的アクセスを取得する場合があります。

アクセスキーペアを作成する場合、アクセスキー ID とシークレットアクセスキーを安全な場所に保存するように求めるプロンプトが表示されます。このシークレットアクセスキーは、作成時にのみ使用できます。シークレットアクセスキーを紛失した場合、新しいアクセスキーを IAM ユーザーに追加する必要があります。最大 2 つのアクセスキーを持つことができます。すでに 2 つある場合は、新しいキーペアを作成する前に、いずれかを削除する必要があります。手順を表示するには、IAM ユーザーガイド の「アクセスキーの管理 」を参照してください。

管理者として Amazon Translate へのアクセスを他のユーザーに許可したいAmazon Translate へのアクセスを他のユーザーに許可するには、アクセスを必要とする人またはアプリケーションの IAM エンティティ (ユーザーまたはロール) を作成する必要があります。ユーザーは、このエンティティの認証情報を使用して AWS にアクセスします。次に、Amazon Translate の適切なアクセス許可を付与するポリシーを、そのエンティティにアタッチする必要があります。

すぐに開始するには、IAM ユーザーガイド の「IAM が委任した最初のユーザーおよびグループの作成」を参照してください 。

自分の AWS アカウント以外のユーザーに Amazon Translate リソースへのアクセスを許可したい他のアカウントのユーザーや組織外のユーザーが、リソースへのアクセスに使用できるロールを作成できます。ロールを引き受けるように信頼されたユーザーを指定することができます。リソースベースのポリシーまたはアクセスコントロールリスト (ACL) をサポートするサービスの場合、それらのポリシーを使用して、リソースへのアクセスを付与できます。

詳細については、以下を参照してください。

• Amazon Translate でこれらの機能がサポートされるかどうかを確認するには、「Amazon Translate とIAM の連携 (p. 52)」を参照してください。

• 所有している AWS アカウント間でリソースへのアクセスを付与する方法については、IAM ユーザーガイド の「所有している別の AWS アカウントへのアクセスを IAM ユーザーに許可」を参照してください。

• サードパーティーの AWS アカウントにリソースへのアクセスを提供する方法については、IAM ユーザーガイド の「第三者が所有する AWS アカウントへのアクセス権を付与する」を参照してください 。

• ID フェデレーションを介してアクセスを提供する方法については、IAM ユーザーガイド の「外部で認証されたユーザー (ID フェデレーション) へのアクセスの許可」を参照して ください 。

• クロスアカウントアクセスでのロールとリソースベースのポリシーの使用の違いの詳細については、IAM ユーザーガイド の「IAM ロールとリソースベースのポリシーとの相違点」を参照してください。

59

Page 64: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate API の権限リファレンス

Amazon Translate API のアクセス権限: アクション、リソース、条件リファレンスIAM アイデンティティ (アイデンティティベースのポリシー) にアタッチできるアクセス権限ポリシーを作成するときに、以下の表をリファレンスとして使用します。この表は、各 Amazon Translate API オペレーション、権限を付与できる対象のアクション、およびアクセス権限を付与できる AWS リソースを示しています。ポリシーの Action フィールドでアクションを指定し、ポリシーの Resource フィールドでリソースの値を指定します。

条件を表現するには、Amazon Translate ポリシーで AWS 全体の条件キーを使用できます。AWS 全体を対象とするキーの完全なリストについては、『IAM ユーザーガイド』の「利用可能なキー」を参照してください。

Note

アクションを指定するには、translate: プレフィックスに続けて API オペレーション名を使用します (例: translate:TranslateText)。

Amazon Translate のモニタリングモニタリングは、Amazon Translate およびソリューションの信頼性、可用性、およびパフォーマンスを維持する上で重要な部分です。AWS では、Amazon Translate のモニタリングに使用できるさまざまなツールを提供しています。こうしたツールをいくつか設定することで、ソリューションのモニタリングをカスタマイズできます。モニタリングタスクをできるだけ自動化することをお勧めします。

Amazon Translate はソリューションでもっとも重要なメトリクスを表示する事前設定済みのグラフを提供します。各グラフはソリューションのパフォーマンス概要を示しています。ソリューションパフォーマンスの経時的な違いを見るためには、グラフで表示する時間範囲を変更できます。

また、Amazon CloudWatch を使用して Amazon Translate をモニタリングすることもできます。CloudWatch を使用すると、ソリューションの特定のメトリクスのモニタリングを自動化できます。メトリクスが設定したしきい値の外にある場合は通知が届きます。CloudWatch API を使用して、ご自分のニーズに合わせたカスタムモニタリングアプリケーションを作成できます。詳細については、AmazonCloudWatch ユーザーガイドの「Amazon CloudWatchとは」を参照してください。

次の表は Amazon Translate が提供する事前設定済みのグラフをそれぞれ説明したものです。

グラフ 説明

成功したリクエストカウント

指定した期間中に成功した Amazon Translate へのリクエスト数です。

60

Page 65: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドモニタリング

グラフ 説明

調整済みリクエストカウント

指定した期間中に調整した Amazon Translate へのリクエスト数です。この情報を使用してアプリケーションが Amazon Translate にリクエストを送信するのが早すぎるか判断します。

平均応答時間

Amazon Translate が指定期間中にリクエストを処理した平均時間です。

文字数カウント

指定した指定期間中に Amazon Translate へ送信した文字数の合計です。この合計数が請求されます。

ユーザーエラーカウント

指定した期間中に発生したユーザーエラーの数です。ユーザーエラーは、HTTP エラーコード 400~499 の範囲内です。

61

Page 66: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドCloudWatch によるモニタリング

グラフ 説明

システムエラーカウント

指定した期間中に発生したシステムエラーの数です。システムエラーは、HTTP エラーコード 500~599 の範囲内です。

Amazon Translate のモニタリングAmazon CloudWatch では、アカウントの個別の Amazon Translate オペレーションまたはグローバルなAmazon Translate メトリクスのメトリクスを取得できます。メトリクスを使用すると、Amazon Translateソリューションの状態をトラッキングし、定義されているしきい値を 1 つ以上のメトリクスが超えた場合に通知するようにアラームをセットアップできます。たとえば、指定期間中に Amazon Translate に送信されたリクエスト数をモニタリングして、リクエストのレイテンシーを確認し、エラー数がしきい値を超えた場合はアラームを生成できます。

Amazon Translate の CloudWatch メトリクスについてAmazon Translate オペレーションのメトリクスを取得するには、以下の情報を指定する必要があります。

• メトリクスディメンション。ディメンションは、メトリクスを識別するための名前と値のペアのセットです。Amazon Translate には 2 つのディメンションがあります。• Operation

• Language pair

• メトリクス名 (SuccessfulRequestCount、RequestCharacters など)。メトリクスの一覧については、「Amazon Translate の CloudWatch メトリクス (p. 65)」を参照してください。

Amazon Translate のメトリクスは、AWS マネジメントコンソール、AWS CLI、CloudWatch API のいずれかを使用して取得できます。CloudWatch API は、いずれかの Amazon AWS Software Development Kit(SDK) または CloudWatch API ツールで使用できます。

以下の表は、CloudWatch メトリクスの一般的な利用方法をいくつか示しています。ここで紹介するのは開始するための提案事項です。すべてを網羅しているわけではありません。

目的 このメトリクスをモニタリング

成功したリクエストの数をトラッキングします SuccessfulRequestCount のメトリクスの sum統計

アプリケーションが最大しきい値に到達した場合に通知します

ThrottledCount のメトリクスの sum 統計

アプリケーションの応答時間を検索します ResponseTime のメトリクスの average 統計

アプリケーションのエラー数を見つけます ServerErrorCount と UserErrorCount のメトリクスの sum 統計をモニタリングします。

62

Page 67: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAWS CloudTrail を使用した Amazon

Translate API コールのログ作成

目的 このメトリクスをモニタリング

請求可能な文字の数を検索します CharacterCount のメトリクスの sum 統計

CloudWatch で Amazon Translate をモニタリングするには、CloudWatch への適切なアクセス権限が必要です。詳細については、Amazon CloudWatch ユーザーガイドの「Amazon CloudWatch に対する認証とアクセスコントロール」を参照してください。

Amazon Translate メトリクスの表示CloudWatch コンソールで Amazon Translate メトリクスを表示する

メトリクスを表示するには (CloudWatch コンソール)

1. AWS マネジメントコンソール にサインインした後、https://console.aws.amazon.com/cloudwatch/ にある CloudWatch コンソールを開きます。

2. [Metrics] で、[All Metrics]、[AWS/Translate] の順に選択します。3. ディメンションを選択して、メトリクスの名前を選び [Add to graph] を選択します。4. 日付範囲の値を選択します。指定した日付範囲のメトリクスカウントがグラフに表示されます。

AWS CloudTrail を使用した Amazon Translate APIコールのログ作成Amazon Translate は、IAM ユーザー、IAM ロール、または Amazon Translate の AWS サービスによって実行されるアクションを記録するサービス AWS CloudTrail と統合されています。CloudTrail では、イベントとして Amazon Translate に対するすべての API コールをキャプチャします。これには、AmazonTranslate コンソールからの呼び出し、および Amazon Translate API オペレーションのコード呼び出しが含まれます。CloudTrail 証跡を作成する場合は、Amazon Translate のイベントなど、CloudTrail イベントの、Amazon Simple Storage Service (Amazon S3) バケットへの継続的な配信を有効にすることができます。証跡を設定しない場合でも、CloudTrail コンソールの [Event history (イベント履歴)] で最新のイベントを表示できます。CloudTrail によって収集された情報を使用して、リクエストの作成元の IP アドレス、リクエストの実行者、リクエストの実行日時などの詳細を調べて、Amazon Translate に対してどのようなリクエストが行われたかを判断できます。

CloudTrail の詳細については、「AWS CloudTrail User Guide」を参照してください。

トピック• CloudTrail 内の Amazon Translate 情報 (p. 63)• Amazon Translate ログファイルエントリの概要 (p. 64)

CloudTrail 内の Amazon Translate 情報CloudTrail は、アカウント作成時に AWS アカウントで有効になります。Amazon Translate でアクティビティが発生すると、そのアクティビティは [Event history (イベント履歴)] の AWS の他のサービスのイベントとともに CloudTrail イベントに記録されます。最近のイベントは、AWS アカウントで表示、検索、ダウンロードできます。詳細については、「CloudTrail イベント履歴でのイベントの表示」を参照してください。

Amazon Translateのイベントなど、AWS アカウントのイベントの継続的な記録については、証跡を作成します。証跡により、CloudTrail はログファイルを Amazon S3 バケットに配信できます。デフォルトで

63

Page 68: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAWS CloudTrail を使用した Amazon

Translate API コールのログ作成

は、コンソールで作成した証跡がすべての AWS リージョンに適用されます。証跡では、AWS パーティションのすべてのリージョンからのイベントがログに記録され、指定した S3 バケットにログファイルが配信されます。その他の AWS のサービスを設定して、CloudTrail ログで収集されたデータに基づき、詳細な分析やアクティビティを行うことができます。詳細については、以下を参照してください。

• 証跡を作成するための概要• CloudTrail でサポートされるサービスと統合• CloudTrail の Amazon SNS 通知の設定• 「複数のリージョンから CloudTrail ログファイルを受け取る」と「複数のアカウントから CloudTrail ロ

グファイルを受け取る」

すべての Amazon Translate アクションは CloudTrail でログに記録されます。これらのアクションは API リファレンスセクションで説明されています。たとえば、、DeleteTerminology、ImportTerminology、TranslateText の各アクションを呼び出すと、CloudTrail ログファイルにエントリが生成されます。

各イベントまたはログエントリには、リクエストの生成者に関する情報が含まれます。この情報は以下のことを確認するのに役立ちます。

• リクエストが、ルートと AWS Identity and Access Management (IAM) ユーザー認証情報のどちらを使用して送信されたか

• リクエストが、ロールとフェデレーティッドユーザーのどちらの一時的なセキュリティ認証情報を使用して送信されたか

• リクエストが、別の AWS サービスによって送信されたかどうか

詳細については、「CloudTrail userIdentity 要素」を参照してください。

Amazon Translate ログファイルエントリの概要証跡は、指定した Amazon S3 バケットにイベントをログファイルとして配信できる設定です。CloudTrailログファイルには、1 つ以上のログエントリが含まれます。イベントは任意の送信元からの単一のリクエストを表し、リクエストされたアクション、アクションの日時、リクエストのパラメータなどに関する情報が含まれます。CloudTrail ログファイルは、パブリック API コールの順序付けられたスタックトレースではないため、特定の順序では表示されません。

以下の例は、TranslateText アクションの CloudTrail ログエントリを示しています。

{ "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "AIDACKCEVSQ6C2EXAMPLE", "arn": "arn:aws:iam::111122223333:user/Administrator", "accountId": "111122223333", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "Administrator" }, "eventTime": "2019-09-03T20:32:50Z", "eventSource": "translate.amazonaws.com", "eventName": "TranslateText", "awsRegion": "us-west-2", "sourceIPAddress": "192.0.2.0", "userAgent": "aws-cli/1.16.207 Python/3.4.7 Linux/4.9.184-0.1.ac.235.83.329.metal1.x86_64 botocore/1.12.197", "requestParameters": { "text": "HIDDEN_DUE_TO_SECURITY_REASONS", "sourceLanguageCode": "en",

64

Page 69: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAmazon Translate の CloudWatch

メトリクスとディメンション

"targetLanguageCode": "fr" }, "responseElements": { "translatedText": "HIDDEN_DUE_TO_SECURITY_REASONS", "sourceLanguageCode": "en", "targetLanguageCode": "fr" }, "requestID": "f56da956-284e-4983-b6fc-59befa20e2bf", "eventID": "1dc75278-84d7-4bb2-861a-493d08d67391", "eventType": "AwsApiCall", "recipientAccountId": "111122223333"}

Amazon Translate の CloudWatch メトリクスとディメンションソリューションのパフォーマンスをモニタリングするには、Amazon CloudWatch のメトリクスおよびAmazon Translate のディメンションを使用します。

Amazon Translate の CloudWatch メトリクス

メトリクス 説明

CharacterCount リクエスト内の請求可能な文字の数を検索します。

有効なディメンション: 言語ペア、オペレーション

有効な統計: 平均、最大、平均、合計

単位: 個

ResponseTime リクエストに応答するまでにかかった時間です。

有効なディメンション: 言語ペア、オペレーション

有効な統計: データサンプル、平均

単位: データサンプル、カウントです。平均統計、ミリ秒です。

ServerErrorCount サーバーエラーの数。サーバーエラーの HTTP レスポンスコード範囲は500〜599 です。

有効なディメンション: オペレーション

有効な統計: 合計、平均

単位: 個

SuccessfulRequestCount 成功した翻訳リクエストの数です。成功したリクエストのレスポンスコードは 200〜299 です。

有効なディメンション: オペレーション

有効な統計: 合計、平均

単位: 個

ThrottledCount スロットリングリクエスト件名の数です。ThrottledCount を使用して、アプリケーションが Amazon Translate にリクエストを送信している

65

Page 70: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドコンプライアンス検証

メトリクス 説明のが、アカウントでの受信設定よりも早いか判断します。詳細については、アマゾン ウェブ サービス全般のリファレンス の「Amazon Translateの制限」を参照してください。

有効なディメンション: オペレーション

有効な統計: 合計、平均

単位: 個

UserErrorCount 発生したユーザーエラーの数です。ユーザーエラーの HTTP レスポンスコード範囲は 400〜499 です。

有効なディメンション: オペレーション

有効な統計: 合計、平均

単位: 個

Amazon Translate の CloudWatch ディメンション次のディメンションを使用して Amazon Translate メトリクスをフィルタできます。メトリクスはソース言語とターゲット言語でグループ化されます。

ディメンション 説明

LanguagePair 特定の言語だけを含むようにメトリクスを制限します。

Operation 特定のオペレーションを使用するものだけにメトリクスを制限します。

Amazon Translate のコンプライアンス検証サードパーティーの監査者は、複数の Amazon Translate コンプライアンスプログラムの一環として AWSのセキュリティとコンプライアンスを評価します。このプログラムには、PCI、FedRAMP、HIPAA などがあります。サードパーティーの監査レポートをダウンロードするには、AWS Artifact を使用します。詳細については、「AWS Artifact のレポートのダウンロード」を参照してください。

Amazon Translate サービスを使用する際のお客様のコンプライアンス責任は、データの機密性、企業のコンプライアンス目的、適用法規や規則によって決まります。AWS ではコンプライアンスに役立つ以下のリソースを用意しています。

• セキュリティおよびコンプライアンスのクイックスタートガイド – これらのデプロイメントガイドでは、アーキテクチャ上の考慮事項について説明し、セキュリティとコンプライアンスに重点を置いたベースライン環境を AWS にデプロイするための手順を説明します。

• HIPAA のセキュリティとコンプライアンスに関するホワイトペーパーを作成する – このホワイトペーパーでは、企業が AWS を使用して HIPAA 準拠のアプリケーションを作成する方法について説明します。

• AWS コンプライアンスのリソース – このワークブックとガイドのコレクションは、お客様の業界や場所に適用される場合があります。

• AWS Config – この AWS サービスでは、自社プラクティス、業界ガイドライン、および規制に対するリソースの設定の準拠状態を評価します。

66

Page 71: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド耐障害性

• AWS Security Hub – この AWS のサービスは、AWS 内でのお客様のセキュリティ状態を総合的に把握するためのもので、セキュリティ業界における標準やベストプラクティスを遵守できているか確認するのに役立ちます。

特定のコンプライアンスプログラムの範囲内の AWS サービスのリストについては、「コンプライアンスプログラムによる AWS 対象範囲内のサービス」を参照してください。一般的な情報については、「AWSコンプライアンスプログラム」を参照してください。

Amazon Translate の耐障害性AWS のグローバルインフラストラクチャは AWS リージョンとアベイラビリティーゾーンを中心として構築されます。AWS リージョンには、低レイテンシー、高いスループット、そして高度の冗長ネットワークで接続されている複数の物理的に独立・隔離されたアベイラビリティーゾーンがあります。アベイラビリティーゾーンでは、アベイラビリティーゾーン間で中断することなく自動的にフェイルオーバーするアプリケーションとデータベースを設計および運用することができます。アベイラビリティーゾーンは、従来の単一または複数のデータセンターインフラストラクチャよりも可用性、耐障害性、および拡張性が優れています。

AWS リージョンとアベイラビリティーゾーンの詳細については、「AWS グローバルインフラストラクチャ」を参照してください。

Amazon Translate のインフラストラクチャセキュリティ

マネージド型サービスとして、Amazon Translate は、ホワイトペーパー「Amazon Web Services: AWS セキュリティプロセスの概要」に記載されている AWS グローバルネットワークセキュリティの手順で保護されています。

ネットワーク経由で Amazon Translate にアクセスするには、AWS 公開の API コールを使用します。クライアントで Transport Layer Security (TLS) 1.0 以降がサポートされている必要があります。TLS 1.2 以降をお勧めします。また、Ephemeral Diffie-Hellman (DHE) や Elliptic Curve Ephemeral Diffie-Hellman(ECDHE) などの Perfect Forward Secrecy (PFS) を使用した暗号スイートもクライアントでサポートされている必要があります。これらのモードは、Java 7 以降など、最近のほとんどのシステムでサポートされています。

また、リクエストは、アクセスキー ID と、AWS Identity and Access Management (IAM) プリンシパルに関連付けられているシークレットのアクセスキーを使用して署名する必要があります。または、AWSSecurity Token Service (AWS STS) を使用して、一時的なセキュリティ認証情報を生成し、リクエストに署名することもできます。

67

Page 72: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドサポートされている AWS リージョン

ガイドラインと制限次のセクションには、Amazon Translate のガイドラインと制限に関する情報が含まれています。

トピック• サポートされている AWS リージョン (p. 68)• コンプライアンス (p. 68)• スロットリング (p. 68)• ガイドライン (p. 68)• サービス制限 (p. 68)

サポートされている AWS リージョンAmazon Translate がサポートされている AWS リージョンの一覧については、アマゾン ウェブ サービス全般のリファレンスの「AWS の製品およびサービス一覧 (リージョン別)」または「AWS リージョンとエンドポイント」を参照してください。

コンプライアンスAmazon Translate コンプライアンスプログラムの詳細については、「AWS コンプライアンス」、「AWSコンプライアンスプログラム」、および「コンプライアンスプログラムによる AWS 対象範囲内のサービス」を参照してください。

スロットリングAmazon Translate のスロットリングまたは制限引き上げのリクエストの詳細については、アマゾン ウェブ サービス全般のリファレンスの「Amazon Translate の制限」を参照してください。

ガイドラインAmazon Translate では、分析モデルの品質を継続的に向上させるため、お客様のデータを保存する場合があります。詳細については、Amazon Translate のよくある質問を参照してください。

AWS サポートにお問い合わせいただくと、お客様のデータを削除するとともに、お客様のアカウントに関連付けられているデータが今後保存されないようリクエストできます。ただし、お客様のデータを削除すると、翻訳の改善に役立つ独自のトレーニングデータも削除される可能性があるため、翻訳の品質が低下することがあります。

サービス制限Amazon Translate には次のサービス制約事項があります。

68

Page 73: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドサービス制限

説明 制限

一般的な制限事項  

文字エンコーディング UTF-8

ドキュメントサイズ (UTF-8 文字) 5,000 バイト

カスタム用語の制限  

カスタム用語ファイルサイズ 10 MB

カスタム用語ファイルあたりのターゲット言語の最大数 10

AWS アカウント、AWS リージョンあたりのカスタム用語の最大数 100

1 カスタム用語あたりのソーステキストとターゲットテキストの最大長

200 バイト

*Amazon Translate では、用語ソースファイルで一致した最初の 256 用語が使用されます。この制限は、TranslateText リクエストで使用されるすべての用語に適用されます。現時点では、TranslateText リクエストごとに最大 1 つの用語ファイルを使用できます。

69

Page 74: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド

Amazon Translate のドキュメント履歴

次の表は、Amazon Translate の今回のリリースの内容をまとめたものです。

• ドキュメントの最新更新日: 2019 年 11 月 25 日

update-history-change update-history-description update-history-date

新しい言語 Amazon Translate では、翻訳対象の新しい言語として、アフリカーンス語、アルバニア語、アムハラ語、アゼルバイジャン語、ベンガル語、ボスニア語、ブルガリア語、カナダフランス語、クロアチア語、ダリ語、エストニア語、グルジア語、ハウサ語、ラトビア語、パシュト語、セルビア語、スロバキア語、スロベニア語、ソマリア語、スワヒリ語、タガログ語、タミル語が追加されました。Amazon Translate が直接翻訳できる言語の組み合わせの一覧については、「サポートされている言語」を参照してください。

November 25, 2019

新しいリージョン Amazon Translate では、アジアパシフィック (香港)、アジアパシフィック (シドニー)、欧州 (ロンドン)、欧州 (パリ)、欧州 (ストックホルム)、米国西部 (北カリフォルニア) の各リージョンのサポートが追加されました。AmazonTranslate でサポートされている AWS リージョンの完全な一覧については、アマゾン ウェブ サービス全般のリファレンスの「AWS の製品およびサービス一覧 (リージョン別)」または「AWS リージョンとエンドポイント」を参照してください。

November 25, 2019

新しい言語 Amazon Translate では、翻訳可能な言語として、ギリシャ語、ハンガリー語、ルーマニア語、タイ語、ウクライナ語、ウルドゥー語、およびベトナム語が追加されました。Amazon Translate が直接翻訳できる言語の組み合わせの一覧については、「サポートされている言語」を参照してください。

October 3, 2019

70

Page 75: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド

新機能 Amazon Translate で FedRAMPコンプライアンスが追加されました。詳細については、「コンプライアンス」を参照してください。

July 31, 2019

新機能 Amazon Translate で SOC コンプライアンスが追加されました。詳細については、「コンプライアンス」を参照してください。

May 30, 2019

新しいリージョン Amazon Translate では、アジアパシフィック (ムンバイ)、アジアパシフィック (シンガポール)、アジアパシフィック (東京)、およびカナダ (中部) の各リージョンのサポートが追加されました。Amazon Translate でサポートされている AWS リージョンの完全な一覧については、アマゾンウェブ サービス全般のリファレンスの「AWS の製品およびサービス一覧 (リージョン別)」または「AWS リージョンとエンドポイント」を参照してください。

May 8, 2019

新しい言語 Amazon Translate では、翻訳対象の新しい言語として、ヒンディー語、マレー語、ノルウェー語、ペルシャ語が追加されました。Amazon Translate が直接翻訳できる言語の組み合わせの一覧については、「サポートされている言語」を参照してください。

May 6, 2019

新しいリージョン Amazon Translate では、欧州(フランクフルト) およびアジアパシフィック (ソウル) リージョンのサポートが追加されました。Amazon Translate でサポートされている AWS リージョンの完全な一覧については、アマゾンウェブ サービス全般のリファレンスの「AWS の製品およびサービス一覧 (リージョン別)」または「AWS リージョンとエンドポイント」を参照してください。

February 28, 2019

新機能 Amazon Translate が PCI コンプライアンスを追加しました。詳細については、「コンプライアンス」を参照してください。

December 12, 2018

71

Page 76: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド

新機能 Amazon Translate では、翻訳中により高度な制御を可能にするため、4 つの新しい API とカスタム用語機能が追加されました。翻訳リクエストでカスタム用語を使用すると、ブランド名、キャラクター名、モデル名、およびその他の独自コンテンツを、標準的な翻訳やコンテキストとは無関係に、毎回目的どおりに翻訳することができます。詳細については、カスタム用語を参照してください。

November 27, 2018

新しい言語 Amazon Translate では、デンマーク語、オランダ語、フィンランド語、ヘブライ語、インドネシア語、韓国語、ポーランド語、スウェーデン語でドキュメントを翻訳できるようになりました。Amazon Translate はサポートされていない言語のペアの数を大幅に減らして、直接翻訳を継続的に強化しています。AmazonTranslate が直接翻訳できる言語の組み合わせについては、「サポートされている言語」を参照してください。

November 20, 2018

新機能 Amazon Translate は、英語以外のサポート対象言語間の直接翻訳を追加しています。AmazonTranslate が直接翻訳できる言語の組み合わせについては、「サポートされている言語」を参照してください。

October 29, 2018

新機能 Amazon Translate で HIPAA への準拠が追加されました。詳細については、「コンプライアンス」を参照してください。

October 25, 2018

新機能 Amazon Translate では、翻訳に新しい複数の言語が追加されました。それらの言語は、繁体字中国語、チェコ語、イタリア語、日本語、ロシア語、トルコ語です。Amazon Translate がサポートする言語のリストについては、「サポートされている言語」を参照してください。

July 17, 2018

新機能 Amazon Translate はソース言語の自動検出をサポートします。詳細については、「AmazonTranslate の仕組み」を参照してください。

April 4, 2018

72

Page 77: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド

新規ガイド (p. 70) これは『Amazon Translate 開発者ガイド』の最初のリリースです。

November 29, 2017

73

Page 78: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドHTTP ヘッダー

API リファレンスこのセクションには、API リファレンスドキュメントが含まれています。

HTTP ヘッダー通常の HTTP ヘッダーに加えて、Amazon Translate オペレーションには必須のヘッダーがあります。

ヘッダー 値 説明

Content-Type: application/x-amz-json-1.1 要求内容の形式として JSON を指定します。また、JSON バージョンを指定します。

X-Amz-Date: <Date> Authorization ヘッダー内の署名を作成するときに使用される日付。形式は ISO 8601 basicの YYYYMMDD'T'HHMMSS'Z'でなければなりません。たとえば、20180820T184626Z はAmazon Translate の x-amz-dateとして有効な日時です。認証ヘッダーの使用の詳細については、「Amazon Translate で署名バージョン 4 を使用する」を参照してください。

X-Amz-Target: AWSShineFrontendService_20170701.<operation>ターゲットの Amazon Translateオペレーションです。たとえば、AWSShineFrontendService_20170701.TranslateTextを使用して TranslateText オペレーションを呼び出します。

ActionsThe following actions are supported:

• DeleteTerminology (p. 75)• DescribeTextTranslationJob (p. 77)• GetTerminology (p. 79)• ImportTerminology (p. 82)• ListTerminologies (p. 85)• ListTextTranslationJobs (p. 88)• StartTextTranslationJob (p. 91)• StopTextTranslationJob (p. 95)• TranslateText (p. 97)

74

Page 79: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドDeleteTerminology

DeleteTerminologyA synchronous action that deletes a custom terminology.

Request Syntax{ "Name": "string"}

Request ParametersFor information about the parameters that are common to all actions, see Common Parameters (p. 115).

The request accepts the following data in JSON format.

Name (p. 75)

The name of the custom terminology being deleted.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: ^([A-Za-z0-9-]_?)+$

Required: Yes

Response ElementsIf the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

ErrorsFor information about the errors that are common to all actions, see Common Errors (p. 114).

InternalServerException

An internal server error occurred. Retry your request.

HTTP Status Code: 500ResourceNotFoundException

The resource you are looking for has not been found. Review the resource you're looking for and see ifa different resource will accomplish your needs before retrying the revised request.

HTTP Status Code: 400TooManyRequestsException

You have made too many requests within a short period of time. Wait for a short time and then try yourrequest again.

HTTP Status Code: 400

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

75

Page 81: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドDescribeTextTranslationJob

DescribeTextTranslationJobGets the properties associated with an asycnhronous batch translation job including name, ID, status,source and target languages, input/output S3 buckets, and so on.

Request Syntax{ "JobId": "string"}

Request ParametersFor information about the parameters that are common to all actions, see Common Parameters (p. 115).

The request accepts the following data in JSON format.

JobId (p. 77)

The identifier that Amazon Translate generated for the job. The StartTextTranslationJob (p. 91)operation returns this identifier in its response.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 32.

Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-%@]*)$

Required: Yes

Response Syntax{ "TextTranslationJobProperties": { "DataAccessRoleArn": "string", "EndTime": number, "InputDataConfig": { "ContentType": "string", "S3Uri": "string" }, "JobDetails": { "DocumentsWithErrorsCount": number, "InputDocumentsCount": number, "TranslatedDocumentsCount": number }, "JobId": "string", "JobName": "string", "JobStatus": "string", "Message": "string", "OutputDataConfig": { "S3Uri": "string" }, "SourceLanguageCode": "string", "SubmittedTime": number, "TargetLanguageCodes": [ "string" ], "TerminologyNames": [ "string" ] }}

77

Page 82: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドDescribeTextTranslationJob

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

TextTranslationJobProperties (p. 77)

An object that contains the properties associated with an asynchronous batch translation job.

Type: TextTranslationJobProperties (p. 112) object

ErrorsFor information about the errors that are common to all actions, see Common Errors (p. 114).

InternalServerException

An internal server error occurred. Retry your request.

HTTP Status Code: 500ResourceNotFoundException

The resource you are looking for has not been found. Review the resource you're looking for and see ifa different resource will accomplish your needs before retrying the revised request.

HTTP Status Code: 400TooManyRequestsException

You have made too many requests within a short period of time. Wait for a short time and then try yourrequest again.

HTTP Status Code: 400

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V2

78

Page 83: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドGetTerminology

GetTerminologyRetrieves a custom terminology.

Request Syntax{ "Name": "string", "TerminologyDataFormat": "string"}

Request ParametersFor information about the parameters that are common to all actions, see Common Parameters (p. 115).

The request accepts the following data in JSON format.

Name (p. 79)

The name of the custom terminology being retrieved.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: ^([A-Za-z0-9-]_?)+$

Required: YesTerminologyDataFormat (p. 79)

The data format of the custom terminology being retrieved, either CSV or TMX.

Type: String

Valid Values: CSV | TMX

Required: Yes

Response Syntax{ "TerminologyDataLocation": { "Location": "string", "RepositoryType": "string" }, "TerminologyProperties": { "Arn": "string", "CreatedAt": number, "Description": "string", "EncryptionKey": { "Id": "string", "Type": "string" }, "LastUpdatedAt": number, "Name": "string", "SizeBytes": number, "SourceLanguageCode": "string", "TargetLanguageCodes": [ "string" ],

79

Page 84: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドGetTerminology

"TermCount": number }}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

TerminologyDataLocation (p. 79)

The data location of the custom terminology being retrieved. The custom terminology file is returned ina presigned url that has a 30 minute expiration.

Type: TerminologyDataLocation (p. 108) objectTerminologyProperties (p. 79)

The properties of the custom terminology being retrieved.

Type: TerminologyProperties (p. 109) object

ErrorsFor information about the errors that are common to all actions, see Common Errors (p. 114).

InternalServerException

An internal server error occurred. Retry your request.

HTTP Status Code: 500InvalidParameterValueException

The value of the parameter is invalid. Review the value of the parameter you are using to correct it, andthen retry your operation.

HTTP Status Code: 400ResourceNotFoundException

The resource you are looking for has not been found. Review the resource you're looking for and see ifa different resource will accomplish your needs before retrying the revised request.

HTTP Status Code: 400TooManyRequestsException

You have made too many requests within a short period of time. Wait for a short time and then try yourrequest again.

HTTP Status Code: 400

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET

80

Page 86: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドImportTerminology

ImportTerminologyCreates or updates a custom terminology, depending on whether or not one already exists for thegiven terminology name. Importing a terminology with the same name as an existing one will mergethe terminologies based on the chosen merge strategy. Currently, the only supported merge strategy isOVERWRITE, and so the imported terminology will overwrite an existing terminology of the same name.

If you import a terminology that overwrites an existing one, the new terminology take up to 10 minutes tofully propagate and be available for use in a translation due to cache policies with the DataPlane servicethat performs the translations.

Request Syntax{ "Description": "string", "EncryptionKey": { "Id": "string", "Type": "string" }, "MergeStrategy": "string", "Name": "string", "TerminologyData": { "File": blob, "Format": "string" }}

Request ParametersFor information about the parameters that are common to all actions, see Common Parameters (p. 115).

The request accepts the following data in JSON format.

Description (p. 82)

The description of the custom terminology being imported.

Type: String

Length Constraints: Maximum length of 256.

Pattern: [\P{M}\p{M}]{0,256}

Required: NoEncryptionKey (p. 82)

The encryption key for the custom terminology being imported.

Type: EncryptionKey (p. 102) object

Required: NoMergeStrategy (p. 82)

The merge strategy of the custom terminology being imported. Currently, only the OVERWRITE mergestrategy is supported. In this case, the imported terminology will overwrite an existing terminology ofthe same name.

Type: String

82

Page 87: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドImportTerminology

Valid Values: OVERWRITE

Required: YesName (p. 82)

The name of the custom terminology being imported.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: ^([A-Za-z0-9-]_?)+$

Required: YesTerminologyData (p. 82)

The terminology data for the custom terminology being imported.

Type: TerminologyData (p. 107) object

Required: Yes

Response Syntax

{ "TerminologyProperties": { "Arn": "string", "CreatedAt": number, "Description": "string", "EncryptionKey": { "Id": "string", "Type": "string" }, "LastUpdatedAt": number, "Name": "string", "SizeBytes": number, "SourceLanguageCode": "string", "TargetLanguageCodes": [ "string" ], "TermCount": number }}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

TerminologyProperties (p. 83)

The properties of the custom terminology being imported.

Type: TerminologyProperties (p. 109) object

ErrorsFor information about the errors that are common to all actions, see Common Errors (p. 114).

83

Page 88: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドImportTerminology

InternalServerException

An internal server error occurred. Retry your request.

HTTP Status Code: 500InvalidParameterValueException

The value of the parameter is invalid. Review the value of the parameter you are using to correct it, andthen retry your operation.

HTTP Status Code: 400LimitExceededException

The specified limit has been exceeded. Review your request and retry it with a quantity below thestated limit.

HTTP Status Code: 400TooManyRequestsException

You have made too many requests within a short period of time. Wait for a short time and then try yourrequest again.

HTTP Status Code: 400

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V2

84

Page 89: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドListTerminologies

ListTerminologiesProvides a list of custom terminologies associated with your account.

Request Syntax{ "MaxResults": number, "NextToken": "string"}

Request ParametersFor information about the parameters that are common to all actions, see Common Parameters (p. 115).

The request accepts the following data in JSON format.

MaxResults (p. 85)

The maximum number of custom terminologies returned per list request.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 500.

Required: NoNextToken (p. 85)

If the result of the request to ListTerminologies was truncated, include the NextToken to fetch the nextgroup of custom terminologies.

Type: String

Length Constraints: Maximum length of 8192.

Pattern: \p{ASCII}{0,8192}

Required: No

Response Syntax{ "NextToken": "string", "TerminologyPropertiesList": [ { "Arn": "string", "CreatedAt": number, "Description": "string", "EncryptionKey": { "Id": "string", "Type": "string" }, "LastUpdatedAt": number, "Name": "string", "SizeBytes": number, "SourceLanguageCode": "string", "TargetLanguageCodes": [ "string" ], "TermCount": number

85

Page 90: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドListTerminologies

} ]}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

NextToken (p. 85)

If the response to the ListTerminologies was truncated, the NextToken fetches the next group ofcustom terminologies.

Type: String

Length Constraints: Maximum length of 8192.

Pattern: \p{ASCII}{0,8192}TerminologyPropertiesList (p. 85)

The properties list of the custom terminologies returned on the list request.

Type: Array of TerminologyProperties (p. 109) objects

ErrorsFor information about the errors that are common to all actions, see Common Errors (p. 114).

InternalServerException

An internal server error occurred. Retry your request.

HTTP Status Code: 500InvalidParameterValueException

The value of the parameter is invalid. Review the value of the parameter you are using to correct it, andthen retry your operation.

HTTP Status Code: 400TooManyRequestsException

You have made too many requests within a short period of time. Wait for a short time and then try yourrequest again.

HTTP Status Code: 400

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go

86

Page 92: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドListTextTranslationJobs

ListTextTranslationJobsGets a list of the batch translation jobs that you have submitted.

Request Syntax{ "Filter": { "JobName": "string", "JobStatus": "string", "SubmittedAfterTime": number, "SubmittedBeforeTime": number }, "MaxResults": number, "NextToken": "string"}

Request ParametersFor information about the parameters that are common to all actions, see Common Parameters (p. 115).

The request accepts the following data in JSON format.

Filter (p. 88)

The parameters that specify which batch translation jobs to retrieve. Filters include job name, jobstatus, and submission time. You can only set one filter at a time.

Type: TextTranslationJobFilter (p. 111) object

Required: NoMaxResults (p. 88)

The maximum number of results to return in each page. The default value is 100.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 500.

Required: NoNextToken (p. 88)

The token to request the next page of results.

Type: String

Length Constraints: Maximum length of 8192.

Pattern: \p{ASCII}{0,8192}

Required: No

Response Syntax{ "NextToken": "string", "TextTranslationJobPropertiesList": [ {

88

Page 93: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドListTextTranslationJobs

"DataAccessRoleArn": "string", "EndTime": number, "InputDataConfig": { "ContentType": "string", "S3Uri": "string" }, "JobDetails": { "DocumentsWithErrorsCount": number, "InputDocumentsCount": number, "TranslatedDocumentsCount": number }, "JobId": "string", "JobName": "string", "JobStatus": "string", "Message": "string", "OutputDataConfig": { "S3Uri": "string" }, "SourceLanguageCode": "string", "SubmittedTime": number, "TargetLanguageCodes": [ "string" ], "TerminologyNames": [ "string" ] } ]}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

NextToken (p. 88)

The token to use to retreive the next page of results. This value is null when there are no moreresults to return.

Type: String

Length Constraints: Maximum length of 8192.

Pattern: \p{ASCII}{0,8192}TextTranslationJobPropertiesList (p. 88)

A list containing the properties of each job that is returned.

Type: Array of TextTranslationJobProperties (p. 112) objects

ErrorsFor information about the errors that are common to all actions, see Common Errors (p. 114).

InternalServerException

An internal server error occurred. Retry your request.

HTTP Status Code: 500InvalidFilterException

The filter specified for the operation is invalid. Specify a different filter.

89

Page 94: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドListTextTranslationJobs

HTTP Status Code: 400InvalidRequestException

The request that you made is invalid. Check your request to determine why it's invalid and then retrythe request.

HTTP Status Code: 400TooManyRequestsException

You have made too many requests within a short period of time. Wait for a short time and then try yourrequest again.

HTTP Status Code: 400

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V2

90

Page 95: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドStartTextTranslationJob

StartTextTranslationJobStarts an asynchronous batch translation job. Batch translation jobs can be used to translate large volumesof text across multiple documents at once. For more information, see ???.

Batch translation jobs can be described with the DescribeTextTranslationJob (p. 77) operation, listed withthe ListTextTranslationJobs (p. 88) operation, and stopped with the StopTextTranslationJob (p. 95)operation.

Note

Amazon Translate does not support batch translation of multiple source languages at once.

Request Syntax{ "ClientToken": "string", "DataAccessRoleArn": "string", "InputDataConfig": { "ContentType": "string", "S3Uri": "string" }, "JobName": "string", "OutputDataConfig": { "S3Uri": "string" }, "SourceLanguageCode": "string", "TargetLanguageCodes": [ "string" ], "TerminologyNames": [ "string" ]}

Request ParametersFor information about the parameters that are common to all actions, see Common Parameters (p. 115).

The request accepts the following data in JSON format.

ClientToken (p. 91)

The client token of the EC2 instance calling the request. This token is auto-generated when using theAmazon Translate SDK. Otherwise, use the DescribeInstances EC2 operation to retreive an instance'sclient token. For more information, see Client Tokens in the EC2 User Guide.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Pattern: ^[a-zA-Z0-9-]+$

Required: YesDataAccessRoleArn (p. 91)

The Amazon Resource Name (ARN) of an AWS Identity Access and Management (IAM) role thatgrants Amazon Translate read access to your input data. For more nformation, see Amazon Translateの Identity and Access Management (p. 48).

Type: String

Length Constraints: Minimum length of 20. Maximum length of 2048.

91

Page 96: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドStartTextTranslationJob

Pattern: arn:aws(-[^:]+)?:iam::[0-9]{12}:role/.+

Required: YesInputDataConfig (p. 91)

Specifies the format and S3 location of the input documents for the translation job.

Type: InputDataConfig (p. 103) object

Required: YesJobName (p. 91)

The name of the batch translation job to be performed.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-%@]*)$

Required: NoOutputDataConfig (p. 91)

Specifies the S3 folder to which your job output will be saved.

Type: OutputDataConfig (p. 105) object

Required: YesSourceLanguageCode (p. 91)

The language code of the input language. For a list of language codes, see サポートされている言語と言語コード (p. 1).

Amazon Translate does not automatically detect a source language during batch translation jobs.

Type: String

Length Constraints: Minimum length of 2. Maximum length of 5.

Required: YesTargetLanguageCodes (p. 91)

The language code of the output language.

Type: Array of strings

Array Members: Fixed number of 1 item.

Length Constraints: Minimum length of 2. Maximum length of 5.

Required: YesTerminologyNames (p. 91)

The name of the terminology to use in the batch translation job. For a list of available terminologies,use the ListTerminologies (p. 85) operation.

Type: Array of strings

Length Constraints: Minimum length of 1. Maximum length of 256.

92

Page 97: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドStartTextTranslationJob

Pattern: ^([A-Za-z0-9-]_?)+$

Required: No

Response Syntax

{ "JobId": "string", "JobStatus": "string"}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

JobId (p. 93)

The identifier generated for the job. To get the status of a job, use this ID with theDescribeTextTranslationJob (p. 77) operation.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 32.

Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-%@]*)$JobStatus (p. 93)

The status of the job. Possible values include:• SUBMITTED - The job has been received and is queued for processing.• IN_PROGRESS - Amazon Translate is processing the job.• COMPLETED - The job was successfully completed and the output is available.• COMPLETED_WITH_ERROR - The job was completed with errors. The errors can be analyzed in the

job's output.• FAILED - The job did not complete. To get details, use the DescribeTextTranslationJob (p. 77)

operation.• STOP_REQUESTED - The user who started the job has requested that it be stopped.• STOPPED - The job has been stopped.

Type: String

Valid Values: SUBMITTED | IN_PROGRESS | COMPLETED | COMPLETED_WITH_ERROR |FAILED | STOP_REQUESTED | STOPPED

ErrorsFor information about the errors that are common to all actions, see Common Errors (p. 114).

InternalServerException

An internal server error occurred. Retry your request.

HTTP Status Code: 500

93

Page 98: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドStartTextTranslationJob

InvalidRequestException

The request that you made is invalid. Check your request to determine why it's invalid and then retrythe request.

HTTP Status Code: 400ResourceNotFoundException

The resource you are looking for has not been found. Review the resource you're looking for and see ifa different resource will accomplish your needs before retrying the revised request.

HTTP Status Code: 400TooManyRequestsException

You have made too many requests within a short period of time. Wait for a short time and then try yourrequest again.

HTTP Status Code: 400UnsupportedLanguagePairException

Amazon Translate does not support translation from the language of the source text into the requestedtarget language. For more information, see 例外処理 (p. 5).

HTTP Status Code: 400

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V2

94

Page 99: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドStopTextTranslationJob

StopTextTranslationJobStops an asynchronous batch translation job that is in progress.

If the job's state is IN_PROGRESS, the job will be marked for termination and put into the STOP_REQUESTEDstate. If the job completes before it can be stopped, it is put into the COMPLETED state. Otherwise, the job isput into the STOPPED state.

Asynchronous batch translation jobs are started with the StartTextTranslationJob (p. 91) operation. Youcan use the DescribeTextTranslationJob (p. 77) or ListTextTranslationJobs (p. 88) operations to get a batchtranslation job's JobId.

Request Syntax{ "JobId": "string"}

Request ParametersFor information about the parameters that are common to all actions, see Common Parameters (p. 115).

The request accepts the following data in JSON format.

JobId (p. 95)

The job ID of the job to be stopped.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 32.

Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-%@]*)$

Required: Yes

Response Syntax{ "JobId": "string", "JobStatus": "string"}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

JobId (p. 95)

The job ID of the stopped batch translation job.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 32.

95

Page 100: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドStopTextTranslationJob

Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-%@]*)$JobStatus (p. 95)

The status of the designated job. Upon successful completion, the job's status will be STOPPED.

Type: String

Valid Values: SUBMITTED | IN_PROGRESS | COMPLETED | COMPLETED_WITH_ERROR |FAILED | STOP_REQUESTED | STOPPED

ErrorsFor information about the errors that are common to all actions, see Common Errors (p. 114).

InternalServerException

An internal server error occurred. Retry your request.

HTTP Status Code: 500ResourceNotFoundException

The resource you are looking for has not been found. Review the resource you're looking for and see ifa different resource will accomplish your needs before retrying the revised request.

HTTP Status Code: 400TooManyRequestsException

You have made too many requests within a short period of time. Wait for a short time and then try yourrequest again.

HTTP Status Code: 400

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V2

96

Page 101: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドTranslateText

TranslateTextTranslates input text from the source language to the target language. For a list of available languages andlanguage codes, see サポートされている言語と言語コード (p. 1).

Request Syntax

{ "SourceLanguageCode": "string", "TargetLanguageCode": "string", "TerminologyNames": [ "string" ], "Text": "string"}

Request ParametersFor information about the parameters that are common to all actions, see Common Parameters (p. 115).

The request accepts the following data in JSON format.

SourceLanguageCode (p. 97)

The language code for the language of the source text. The language must be a language supportedby Amazon Translate. For a list of language codes, see サポートされている言語と言語コード (p. 1).

To have Amazon Translate determine the source language of your text, you can specify auto in theSourceLanguageCode field. If you specify auto, Amazon Translate will call Amazon Comprehend todetermine the source language.

Type: String

Length Constraints: Minimum length of 2. Maximum length of 5.

Required: YesTargetLanguageCode (p. 97)

The language code requested for the language of the target text. The language must be a languagesupported by Amazon Translate.

Type: String

Length Constraints: Minimum length of 2. Maximum length of 5.

Required: YesTerminologyNames (p. 97)

The name of the terminology list file to be used in the TranslateText request. You can use 1terminology list at most in a TranslateText request. Terminology lists can contain a maximum of256 terms.

Type: Array of strings

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: ^([A-Za-z0-9-]_?)+$

Required: No

97

Page 102: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドTranslateText

Text (p. 97)

The text to translate. The text string can be a maximum of 5,000 bytes long. Depending on yourcharacter set, this may be fewer than 5,000 characters.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 5000.

Pattern: [\P{M}\p{M}]{1,5000}

Required: Yes

Response Syntax

{ "AppliedTerminologies": [ { "Name": "string", "Terms": [ { "SourceText": "string", "TargetText": "string" } ] } ], "SourceLanguageCode": "string", "TargetLanguageCode": "string", "TranslatedText": "string"}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

AppliedTerminologies (p. 98)

The names of the custom terminologies applied to the input text by Amazon Translate for the translatedtext response.

Type: Array of AppliedTerminology (p. 101) objectsSourceLanguageCode (p. 98)

The language code for the language of the source text.

Type: String

Length Constraints: Minimum length of 2. Maximum length of 5.TargetLanguageCode (p. 98)

The language code for the language of the target text.

Type: String

Length Constraints: Minimum length of 2. Maximum length of 5.

98

Page 103: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドTranslateText

TranslatedText (p. 98)

The translated text.

Type: String

Length Constraints: Maximum length of 10000.

Pattern: [\P{M}\p{M}]{0,10000}

ErrorsFor information about the errors that are common to all actions, see Common Errors (p. 114).

DetectedLanguageLowConfidenceException

The confidence that Amazon Comprehend accurately detected the source language is low. If a lowconfidence level is acceptable for your application, you can use the language in the exception to callAmazon Translate again. For more information, see the DetectDominantLanguage operation in theAmazon Comprehend Developer Guide.

HTTP Status Code: 400InternalServerException

An internal server error occurred. Retry your request.

HTTP Status Code: 500InvalidRequestException

The request that you made is invalid. Check your request to determine why it's invalid and then retrythe request.

HTTP Status Code: 400ResourceNotFoundException

The resource you are looking for has not been found. Review the resource you're looking for and see ifa different resource will accomplish your needs before retrying the revised request.

HTTP Status Code: 400ServiceUnavailableException

The Amazon Translate service is temporarily unavailable. Please wait a bit and then retry your request.

HTTP Status Code: 500TextSizeLimitExceededException

The size of the text you submitted exceeds the size limit. Reduce the size of the text or use a smallerdocument and then retry your request.

HTTP Status Code: 400TooManyRequestsException

You have made too many requests within a short period of time. Wait for a short time and then try yourrequest again.

HTTP Status Code: 400

99

Page 104: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドData Types

UnsupportedLanguagePairException

Amazon Translate does not support translation from the language of the source text into the requestedtarget language. For more information, see 例外処理 (p. 5).

HTTP Status Code: 400

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V2

Data TypesThe following data types are supported:

• AppliedTerminology (p. 101)• EncryptionKey (p. 102)• InputDataConfig (p. 103)• JobDetails (p. 104)• OutputDataConfig (p. 105)• Term (p. 106)• TerminologyData (p. 107)• TerminologyDataLocation (p. 108)• TerminologyProperties (p. 109)• TextTranslationJobFilter (p. 111)• TextTranslationJobProperties (p. 112)

100

Page 105: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドAppliedTerminology

AppliedTerminologyThe custom terminology applied to the input text by Amazon Translate for the translated text response.This is optional in the response and will only be present if you specified terminology input in the request.Currently, only one terminology can be applied per TranslateText request.

ContentsName

The name of the custom terminology applied to the input text by Amazon Translate for the translatedtext response.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: ^([A-Za-z0-9-]_?)+$

Required: NoTerms

The specific terms of the custom terminology applied to the input text by Amazon Translate for thetranslated text response. A maximum of 250 terms will be returned, and the specific terms applied willbe the first 250 terms in the source text.

Type: Array of Term (p. 106) objects

Required: No

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V2

101

Page 106: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドEncryptionKey

EncryptionKeyThe encryption key used to encrypt the custom terminologies used by Amazon Translate.

ContentsId

The Amazon Resource Name (ARN) of the encryption key being used to encrypt the customterminology.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 400.

Pattern: (arn:aws((-us-gov)|(-iso)|(-iso-b)|(-cn))?:kms:)?([a-z]{2}-[a-z]+(-[a-z]+)?-\d:)?(\d{12}:)?(((key/)?[a-zA-Z0-9-_]+)|(alias/[a-zA-Z0-9:/_-]+))

Required: YesType

The type of encryption key used by Amazon Translate to encrypt custom terminologies.

Type: String

Valid Values: KMS

Required: Yes

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V2

102

Page 107: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドInputDataConfig

InputDataConfigThe input configuration properties for requesting a batch translation job.

ContentsContentType

The multipurpose internet mail extension (MIME) type of the input files. Valid values are text/plainfor plaintext files and text/html for HTML files.

Type: String

Length Constraints: Maximum length of 256.

Pattern: ^[-\w.]+\/[-\w.+]+$

Required: YesS3Uri

The URI of the AWS S3 folder that contains the input file. The folder must be in the same Region asthe API endpoint you are calling.

Type: String

Length Constraints: Maximum length of 1024.

Pattern: s3://[a-z0-9][\.\-a-z0-9]{1,61}[a-z0-9](/.*)?

Required: Yes

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V2

103

Page 108: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドJobDetails

JobDetailsThe number of documents successfully and unsuccessfully processed during a translation job.

ContentsDocumentsWithErrorsCount

The number of documents that could not be processed during a translation job.

Type: Integer

Required: NoInputDocumentsCount

The number of documents used as input in a translation job.

Type: Integer

Required: NoTranslatedDocumentsCount

The number of documents successfully processed during a translation job.

Type: Integer

Required: No

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V2

104

Page 109: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドOutputDataConfig

OutputDataConfigThe output configuration properties for a batch translation job.

ContentsS3Uri

The URI of the S3 folder that contains a translation job's output file. The folder must be in the sameRegion as the API endpoint that you are calling.

Type: String

Length Constraints: Maximum length of 1024.

Pattern: s3://[a-z0-9][\.\-a-z0-9]{1,61}[a-z0-9](/.*)?

Required: Yes

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V2

105

Page 110: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドTerm

TermThe term being translated by the custom terminology.

ContentsSourceText

The source text of the term being translated by the custom terminology.

Type: String

Length Constraints: Maximum length of 10000.

Pattern: [\P{M}\p{M}]{0,10000}

Required: NoTargetText

The target text of the term being translated by the custom terminology.

Type: String

Length Constraints: Maximum length of 10000.

Pattern: [\P{M}\p{M}]{0,10000}

Required: No

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V2

106

Page 111: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドTerminologyData

TerminologyDataThe data associated with the custom terminology.

ContentsFile

The file containing the custom terminology data. Your version of the AWS SDK performs a Base64-encoding on this field before sending a request to the AWS service. Users of the SDK should notperform Base64-encoding themselves.

Type: Base64-encoded binary data object

Length Constraints: Maximum length of 10485760.

Required: YesFormat

The data format of the custom terminology. Either CSV or TMX.

Type: String

Valid Values: CSV | TMX

Required: Yes

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V2

107

Page 112: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドTerminologyDataLocation

TerminologyDataLocationThe location of the custom terminology data.

ContentsLocation

The location of the custom terminology data.

Type: String

Length Constraints: Maximum length of 10000.

Pattern: [\P{M}\p{M}]{0,10000}

Required: YesRepositoryType

The repository type for the custom terminology data.

Type: String

Length Constraints: Maximum length of 10000.

Pattern: [\P{M}\p{M}]{0,10000}

Required: Yes

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V2

108

Page 113: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドTerminologyProperties

TerminologyPropertiesThe properties of the custom terminology.

ContentsArn

The Amazon Resource Name (ARN) of the custom terminology.

Type: String

Pattern: ^arn:aws((-us-gov)|(-iso)|(-iso-b)|(-cn))?:translate:[a-zA-Z0-9-]+:[0-9]{12}:terminology/.+?/.+?$

Required: NoCreatedAt

The time at which the custom terminology was created, based on the timestamp.

Type: Timestamp

Required: NoDescription

The description of the custom terminology properties.

Type: String

Length Constraints: Maximum length of 256.

Pattern: [\P{M}\p{M}]{0,256}

Required: NoEncryptionKey

The encryption key for the custom terminology.

Type: EncryptionKey (p. 102) object

Required: NoLastUpdatedAt

The time at which the custom terminology was last update, based on the timestamp.

Type: Timestamp

Required: NoName

The name of the custom terminology.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: ^([A-Za-z0-9-]_?)+$

Required: No

109

Page 114: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドTerminologyProperties

SizeBytes

The size of the file used when importing a custom terminology.

Type: Integer

Required: NoSourceLanguageCode

The language code for the source text of the translation request for which the custom terminology isbeing used.

Type: String

Length Constraints: Minimum length of 2. Maximum length of 5.

Required: NoTargetLanguageCodes

The language codes for the target languages available with the custom terminology file. All possibletarget languages are returned in array.

Type: Array of strings

Length Constraints: Minimum length of 2. Maximum length of 5.

Required: NoTermCount

The number of terms included in the custom terminology.

Type: Integer

Required: No

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V2

110

Page 115: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドTextTranslationJobFilter

TextTranslationJobFilterProvides information for filtering a list of translation jobs. For more information, seeListTextTranslationJobs (p. 88).

ContentsJobName

Filters the list of jobs by name.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-%@]*)$

Required: NoJobStatus

Filters the list of jobs based by job status.

Type: String

Valid Values: SUBMITTED | IN_PROGRESS | COMPLETED | COMPLETED_WITH_ERROR |FAILED | STOP_REQUESTED | STOPPED

Required: NoSubmittedAfterTime

Filters the list of jobs based on the time that the job was submitted for processing and returns only thejobs submitted after the specified time. Jobs are returned in descending order, newest to oldest.

Type: Timestamp

Required: NoSubmittedBeforeTime

Filters the list of jobs based on the time that the job was submitted for processing and returns only thejobs submitted before the specified time. Jobs are returned in ascending order, oldest to newest.

Type: Timestamp

Required: No

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V2

111

Page 116: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドTextTranslationJobProperties

TextTranslationJobPropertiesProvides information about a translation job.

ContentsDataAccessRoleArn

The Amazon Resource Name (ARN) of an AWS Identity Access and Management (IAM) role thatgranted Amazon Translate read access to the job's input data.

Type: String

Length Constraints: Minimum length of 20. Maximum length of 2048.

Pattern: arn:aws(-[^:]+)?:iam::[0-9]{12}:role/.+

Required: NoEndTime

The time at which the translation job ended.

Type: Timestamp

Required: NoInputDataConfig

The input configuration properties that were specified when the job was requested.

Type: InputDataConfig (p. 103) object

Required: NoJobDetails

The number of documents successfully and unsuccessfully processed during the translation job.

Type: JobDetails (p. 104) object

Required: NoJobId

The ID of the translation job.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 32.

Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-%@]*)$

Required: NoJobName

The user-defined name of the translation job.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-%@]*)$

112

Page 117: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドTextTranslationJobProperties

Required: NoJobStatus

The status of the translation job.

Type: String

Valid Values: SUBMITTED | IN_PROGRESS | COMPLETED | COMPLETED_WITH_ERROR |FAILED | STOP_REQUESTED | STOPPED

Required: NoMessage

An explanation of any errors that may have occured during the translation job.

Type: String

Required: NoOutputDataConfig

The output configuration properties that were specified when the job was requested.

Type: OutputDataConfig (p. 105) object

Required: NoSourceLanguageCode

The language code of the language of the source text. The language must be a language supported byAmazon Translate.

Type: String

Length Constraints: Minimum length of 2. Maximum length of 5.

Required: NoSubmittedTime

The time at which the translation job was submitted.

Type: Timestamp

Required: NoTargetLanguageCodes

The language code of the language of the target text. The language must be a language supported byAmazon Translate.

Type: Array of strings

Array Members: Fixed number of 1 item.

Length Constraints: Minimum length of 2. Maximum length of 5.

Required: NoTerminologyNames

A list containing the names of the terminologies applied to a translation job. Only one terminology canbe applied per StartTextTranslationJob (p. 91) request at this time.

Type: Array of strings

113

Page 118: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドCommon Errors

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: ^([A-Za-z0-9-]_?)+$

Required: No

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V2

Common ErrorsThis section lists the errors common to the API actions of all AWS services. For errors specific to an APIaction for this service, see the topic for that API action.

AccessDeniedException

You do not have sufficient access to perform this action.

HTTP Status Code: 400IncompleteSignature

The request signature does not conform to AWS standards.

HTTP Status Code: 400InternalFailure

The request processing has failed because of an unknown error, exception or failure.

HTTP Status Code: 500InvalidAction

The action or operation requested is invalid. Verify that the action is typed correctly.

HTTP Status Code: 400InvalidClientTokenId

The X.509 certificate or AWS access key ID provided does not exist in our records.

HTTP Status Code: 403InvalidParameterCombination

Parameters that must not be used together were used together.

HTTP Status Code: 400InvalidParameterValue

An invalid or out-of-range value was supplied for the input parameter.

HTTP Status Code: 400

114

Page 119: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドCommon Parameters

InvalidQueryParameter

The AWS query string is malformed or does not adhere to AWS standards.

HTTP Status Code: 400MalformedQueryString

The query string contains a syntax error.

HTTP Status Code: 404MissingAction

The request is missing an action or a required parameter.

HTTP Status Code: 400MissingAuthenticationToken

The request must contain either a valid (registered) AWS access key ID or X.509 certificate.

HTTP Status Code: 403MissingParameter

A required parameter for the specified action is not supplied.

HTTP Status Code: 400OptInRequired

The AWS access key ID needs a subscription for the service.

HTTP Status Code: 403RequestExpired

The request reached the service more than 15 minutes after the date stamp on the request or morethan 15 minutes after the request expiration date (such as for pre-signed URLs), or the date stamp onthe request is more than 15 minutes in the future.

HTTP Status Code: 400ServiceUnavailable

The request has failed due to a temporary failure of the server.

HTTP Status Code: 503ThrottlingException

The request was denied due to request throttling.

HTTP Status Code: 400ValidationError

The input fails to satisfy the constraints specified by an AWS service.

HTTP Status Code: 400

Common ParametersThe following list contains the parameters that all actions use for signing Signature Version 4 requests witha query string. Any action-specific parameters are listed in the topic for that action. For more information

115

Page 120: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドCommon Parameters

about Signature Version 4, see Signature Version 4 Signing Process in the Amazon Web Services GeneralReference.

Action

The action to be performed.

Type: string

Required: YesVersion

The API version that the request is written for, expressed in the format YYYY-MM-DD.

Type: string

Required: YesX-Amz-Algorithm

The hash algorithm that you used to create the request signature.

Condition: Specify this parameter when you include authentication information in a query string insteadof in the HTTP authorization header.

Type: string

Valid Values: AWS4-HMAC-SHA256

Required: ConditionalX-Amz-Credential

The credential scope value, which is a string that includes your access key, the date, the region youare targeting, the service you are requesting, and a termination string ("aws4_request"). The value isexpressed in the following format: access_key/YYYYMMDD/region/service/aws4_request.

For more information, see Task 2: Create a String to Sign for Signature Version 4 in the Amazon WebServices General Reference.

Condition: Specify this parameter when you include authentication information in a query string insteadof in the HTTP authorization header.

Type: string

Required: ConditionalX-Amz-Date

The date that is used to create the signature. The format must be ISO 8601 basic format(YYYYMMDD'T'HHMMSS'Z'). For example, the following date time is a valid X-Amz-Date value:20120325T120000Z.

Condition: X-Amz-Date is optional for all requests; it can be used to override the date used for signingrequests. If the Date header is specified in the ISO 8601 basic format, X-Amz-Date is not required.When X-Amz-Date is used, it always overrides the value of the Date header. For more information, seeHandling Dates in Signature Version 4 in the Amazon Web Services General Reference.

Type: string

Required: Conditional

116

Page 121: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイドCommon Parameters

X-Amz-Security-Token

The temporary security token that was obtained through a call to AWS Security Token Service (AWSSTS). For a list of services that support temporary security credentials from AWS Security TokenService, go to AWS Services That Work with IAM in the IAM User Guide.

Condition: If you're using temporary security credentials from the AWS Security Token Service, youmust include the security token.

Type: string

Required: ConditionalX-Amz-Signature

Specifies the hex-encoded signature that was calculated from the string to sign and the derived signingkey.

Condition: Specify this parameter when you include authentication information in a query string insteadof in the HTTP authorization header.

Type: string

Required: ConditionalX-Amz-SignedHeaders

Specifies all the HTTP headers that were included as part of the canonical request. For moreinformation about specifying signed headers, see Task 1: Create a Canonical Request For SignatureVersion 4 in the Amazon Web Services General Reference.

Condition: Specify this parameter when you include authentication information in a query string insteadof in the HTTP authorization header.

Type: string

Required: Conditional

117

Page 122: Amazon Translate - 開発者ガイド · Amazon Translate 開発者ガイド サポートされている言語と言語コード Amazon Translate とは Amazon Translate は高度な機械学習テクノロジーを使用して、高品質の翻訳をオンデマンドで提供するテ

Amazon Translate 開発者ガイド

AWS の用語集最新の AWS の用語については、『AWS General Reference』の「AWS の用語集」を参照してください。

118