Translate

We mainly check whether commands can be executed using AWS Cloud9.
If you would like to provide example commands, please submit them using the form below.
Please also provide corrections if the command examples have mistake.

Suggest
The proposed content may be modified. Please be aware of this before making any suggestions.


Determine the language of the text

text="時は金なり"
aws comprehend detect-dominant-language \
--text "$text"

output

{
    "Languages": [
        {
            "LanguageCode": "ja",
            "Score": 1.0
        }
    ]
}

by ton

Determine the language of the text and translate it to English

text="時は金なり"
lang=$(aws comprehend detect-dominant-language \
--text "$text" \
--query 'Languages[0].LanguageCode' \
--output text)
aws translate translate-text \
--source-language-code $lang \
--target-language-code "en" \
--text "$text" \
--query 'TranslatedText'

output

"Time is money"

by ton


Run a translation job on an Excel file in an S3 bucket

aws translate start-text-translation-job \
--input-data-config ContentType=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,S3Uri=s3://my-s3-bucket/input/ \
--output-data-config S3Uri=s3://my-s3-bucket/output/ \
--data-access-role-arn arn:aws:iam::111122223333:role/my-iam-role \
--source-language-code en \
--target-language-codes es it \
--job-name my-translation-job

output

{
    "JobId": "4446f95f20c88a4b347449d3671fbe3d",
    "JobStatus": "SUBMITTED"
}

by anonymous

Check the job status

aws translate describe-text-translation-job \
--job-id 4446f95f20c88a4b347449d3671fbe3d

output

{
    "TextTranslationJobProperties": {
        "JobId": "4446f95f20c88a4b347449d3671fbe3d",
        "JobName": "my-translation-job",
        "JobStatus": "COMPLETED",
        "JobDetails": {
            "TranslatedDocumentsCount": 0,
            "DocumentsWithErrorsCount": 0,
            "InputDocumentsCount": 1
        },
        "SourceLanguageCode": "en",
        "TargetLanguageCodes": [
            "es", 
            "it" 
        ],
        "SubmittedTime": 1598661012.468,
        "InputDataConfig": {
            "S3Uri": "s3://my-s3-bucket/input/",
            "ContentType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
        },
        "OutputDataConfig": {
            "S3Uri": "s3://my-s3-bucket/output/111122223333-TranslateText-4446f95f20c88a4b347449d3671fbe3d/"
        },
        "DataAccessRoleArn": "arn:aws:iam::111122223333:role/my-iam-role"
    }
}

by anonymous

タイトルとURLをコピーしました