Comprehend

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

Determine the language of the text and analyze the syntax

text="Time is money"
lang=$(aws comprehend detect-dominant-language \
--text "$text" \
--query 'Languages[0].LanguageCode' \
--output text)
aws comprehend detect-syntax \
--language-code $lang \
--text "$text"

output

{
    "SyntaxTokens": [
        {
            "TokenId": 1,
            "Text": "Time",
            "BeginOffset": 0,
            "EndOffset": 4,
            "PartOfSpeech": {
                "Tag": "NOUN",
                "Score": 1.0
            }
        },
        {
            "TokenId": 2,
            "Text": "is",
            "BeginOffset": 5,
            "EndOffset": 7,
            "PartOfSpeech": {
                "Tag": "VERB",
                "Score": 1.0
            }
        },
        {
            "TokenId": 3,
            "Text": "money",
            "BeginOffset": 8,
            "EndOffset": 13,
            "PartOfSpeech": {
                "Tag": "NOUN",
                "Score": 1.0
            }
        }
    ]
}

by anonymous

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