Comprehend / Client / detect_syntax

detect_syntax#

Comprehend.Client.detect_syntax(**kwargs)#

Inspects text for syntax and the part of speech of words in the document. For more information, see Syntax in the Comprehend Developer Guide.

See also: AWS API Documentation

Request Syntax

response = client.detect_syntax(
    Text='string',
    LanguageCode='en'|'es'|'fr'|'de'|'it'|'pt'
)
Parameters:
  • Text (string) –

    [REQUIRED]

    A UTF-8 string. The maximum string size is 5 KB.

  • LanguageCode (string) –

    [REQUIRED]

    The language code of the input documents. You can specify any of the following languages supported by Amazon Comprehend: German (“de”), English (“en”), Spanish (“es”), French (“fr”), Italian (“it”), or Portuguese (“pt”).

Return type:

dict

Returns:

Response Syntax

{
    'SyntaxTokens': [
        {
            'TokenId': 123,
            'Text': 'string',
            'BeginOffset': 123,
            'EndOffset': 123,
            'PartOfSpeech': {
                'Tag': 'ADJ'|'ADP'|'ADV'|'AUX'|'CONJ'|'CCONJ'|'DET'|'INTJ'|'NOUN'|'NUM'|'O'|'PART'|'PRON'|'PROPN'|'PUNCT'|'SCONJ'|'SYM'|'VERB',
                'Score': ...
            }
        },
    ]
}

Response Structure

  • (dict) –

    • SyntaxTokens (list) –

      A collection of syntax tokens describing the text. For each token, the response provides the text, the token type, where the text begins and ends, and the level of confidence that Amazon Comprehend has that the token is correct. For a list of token types, see Syntax in the Comprehend Developer Guide.

      • (dict) –

        Represents a work in the input text that was recognized and assigned a part of speech. There is one syntax token record for each word in the source text.

        • TokenId (integer) –

          A unique identifier for a token.

        • Text (string) –

          The word that was recognized in the source text.

        • BeginOffset (integer) –

          The zero-based offset from the beginning of the source text to the first character in the word.

        • EndOffset (integer) –

          The zero-based offset from the beginning of the source text to the last character in the word.

        • PartOfSpeech (dict) –

          Provides the part of speech label and the confidence level that Amazon Comprehend has that the part of speech was correctly identified. For more information, see Syntax in the Comprehend Developer Guide.

          • Tag (string) –

            Identifies the part of speech that the token represents.

          • Score (float) –

            The confidence that Amazon Comprehend has that the part of speech was correctly identified.

Exceptions