detect_key_phrases

detect_key_phrases(**kwargs)

Detects the key noun phrases found in the text.

See also: AWS API Documentation

Request Syntax

response = client.detect_key_phrases(
    Text='string',
    LanguageCode='en'|'es'|'fr'|'de'|'it'|'pt'|'ar'|'hi'|'ja'|'ko'|'zh'|'zh-TW'
)
Parameters
  • Text (string) --

    [REQUIRED]

    A UTF-8 text string. The string must contain less than 100 KB of UTF-8 encoded characters.

  • LanguageCode (string) --

    [REQUIRED]

    The language of the input documents. You can specify any of the primary languages supported by Amazon Comprehend. All documents must be in the same language.

Return type

dict

Returns

Response Syntax

{
    'KeyPhrases': [
        {
            'Score': ...,
            'Text': 'string',
            'BeginOffset': 123,
            'EndOffset': 123
        },
    ]
}

Response Structure

  • (dict) --

    • KeyPhrases (list) --

      A collection of key phrases that Amazon Comprehend identified in the input text. For each key phrase, the response provides the text of the key phrase, where the key phrase begins and ends, and the level of confidence that Amazon Comprehend has in the accuracy of the detection.

      • (dict) --

        Describes a key noun phrase.

        • Score (float) --

          The level of confidence that Amazon Comprehend has in the accuracy of the detection.

        • Text (string) --

          The text of a key noun phrase.

        • BeginOffset (integer) --

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

        • EndOffset (integer) --

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

Exceptions

  • Comprehend.Client.exceptions.InvalidRequestException
  • Comprehend.Client.exceptions.TextSizeLimitExceededException
  • Comprehend.Client.exceptions.UnsupportedLanguageException
  • Comprehend.Client.exceptions.InternalServerException