:doc:`Comprehend <../../comprehend>` / Client / detect_sentiment

****************
detect_sentiment
****************



.. py:method:: Comprehend.Client.detect_sentiment(**kwargs)

  

  Inspects text and returns an inference of the prevailing sentiment ( ``POSITIVE``, ``NEUTRAL``, ``MIXED``, or ``NEGATIVE``).

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/comprehend-2017-11-27/DetectSentiment>`_  


  **Request Syntax**
  ::

    response = client.detect_sentiment(
        Text='string',
        LanguageCode='en'|'es'|'fr'|'de'|'it'|'pt'|'ar'|'hi'|'ja'|'ko'|'zh'|'zh-TW'
    )
    
  :type Text: string
  :param Text: **[REQUIRED]** 

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

    

  
  :type LanguageCode: string
  :param LanguageCode: **[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.

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'Sentiment': 'POSITIVE'|'NEGATIVE'|'NEUTRAL'|'MIXED',
          'SentimentScore': {
              'Positive': ...,
              'Negative': ...,
              'Neutral': ...,
              'Mixed': ...
          }
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **Sentiment** *(string) --* 

        The inferred sentiment that Amazon Comprehend has the highest level of confidence in.

        
      

      - **SentimentScore** *(dict) --* 

        An object that lists the sentiments, and their corresponding confidence levels.

        
        

        - **Positive** *(float) --* 

          The level of confidence that Amazon Comprehend has in the accuracy of its detection of the ``POSITIVE`` sentiment.

          
        

        - **Negative** *(float) --* 

          The level of confidence that Amazon Comprehend has in the accuracy of its detection of the ``NEGATIVE`` sentiment.

          
        

        - **Neutral** *(float) --* 

          The level of confidence that Amazon Comprehend has in the accuracy of its detection of the ``NEUTRAL`` sentiment.

          
        

        - **Mixed** *(float) --* 

          The level of confidence that Amazon Comprehend has in the accuracy of its detection of the ``MIXED`` sentiment.

          
    
  
  **Exceptions**
  
  *   :py:class:`Comprehend.Client.exceptions.InvalidRequestException`

  
  *   :py:class:`Comprehend.Client.exceptions.TextSizeLimitExceededException`

  
  *   :py:class:`Comprehend.Client.exceptions.UnsupportedLanguageException`

  
  *   :py:class:`Comprehend.Client.exceptions.InternalServerException`

  