It seems that it can be done with Amazon Comprehend.
See Detect Sentiment https://docs.aws.amazon.com/comprehend/latest/dg/API_DetectSentiment.html
I'll try it in Python this time, so I'll see the one for Python. https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/comprehend.html#Comprehend.Client.detect_sentiment
At the top is what to import. https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/comprehend.html
The code looks like this.
import boto3
client = boto3.client('comprehend')
response = client.detect_sentiment(
Text='The postponement of the Tokyo Olympics is just like the world of Akira.',
LanguageCode='ja'
)
print(response)
The result looks like this.
{'Sentiment': 'NEUTRAL', 'SentimentScore': {'Positive': 0.12571793794631958, 'Negative': 0.006899271160364151, 'Neutral': 0.8673694729804993, 'Mixed': 1.3250895790406503e-05}, 'ResponseMetadata': {'RequestId': 'e458bcfd-c85e-4314-bb01-f11b8e72ec8f', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': 'e458bcfd-c85e-4314-bb01-f11b8e72ec8f', 'content-type': 'application/x-amz-json-1.1', 'content-length': '164', 'date': 'Fri, 27 Mar 2020 04:44:21 GMT'}, 'RetryAttempts': 0}}
Recommended Posts