Sentiment analysis#

1raise SystemExit("Stop right there!");
An exception has occurred, use %tb to see the full traceback.

SystemExit: Stop right there!
1# import the AWS SDK for python (boto3) -
2# http://boto3.readthedocs.io/en/latest/
3import boto3
4
5# import json module to serialize JSON -
6# https://docs.python.org/3.6/library/json.html
7import json
1# instantiate a new comprehend client
2comprehend = boto3.client(service_name="comprehend")
 1# provide a text string to analyze
 2english_string = (
 3    "One minute I''m just another rabbit and happy about it, "
 4    "next minute *whazaam*, I''m thinking. That''s a major drawback "
 5    "if you''re looking for happiness as a rabbit, let me tell you. "
 6    "You want grass and sex, not thoughts like 'What's it all about, "
 7    "when you get right down to it?'"
 8)
 9
10print("Calling DetectSentiment")
11# json.dumps() writes JSON data to a Python string
12print("english_string results:")
13print(
14    json.dumps(
15        comprehend.detect_sentiment(Text=english_string, LanguageCode="en"),
16        sort_keys=True,
17        indent=4,
18    )
19)
20print("End of DetectSentiment\n")
Calling DetectSentiment
english_string results:
{
    "ResponseMetadata": {
        "HTTPHeaders": {
            "content-length": "161",
            "content-type": "application/x-amz-json-1.1",
            "date": "Mon, 28 Mar 2022 01:45:38 GMT",
            "x-amzn-requestid": "dc1f4a9c-7443-4f63-aba5-88b5032bbf58"
        },
        "HTTPStatusCode": 200,
        "RequestId": "dc1f4a9c-7443-4f63-aba5-88b5032bbf58",
        "RetryAttempts": 0
    },
    "Sentiment": "MIXED",
    "SentimentScore": {
        "Mixed": 0.6543833017349243,
        "Negative": 0.27250298857688904,
        "Neutral": 0.044997189193964005,
        "Positive": 0.028116533532738686
    }
}
End of DetectSentiment