def test_amazon_comprehend_sentiment_request_model_create_sentiment_request():
    model = AmazonComprehendSentimentRequestModel(aws_access_key='',
                                                  aws_secret_access_key='',
                                                  region_name='us-east-1',
                                                  language_code='en')
    request = model.build()
    assert isinstance(request, AmazonComprehendSentimentRequest)
Exemple #2
0
def test_amazon_comprehend_sentiment_request(cassettes_path):
    with vcr.use_cassette(str(cassettes_path /
                              'amazon_comprehend_sentiment.yaml'),
                          mode='once',
                          filter_headers=['authorization']):
        model = AmazonComprehendSentimentRequestModel(
            aws_access_key=os.environ.get('AWS_ACCESS_KEY', ''),
            aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', ''),
            region_name='us-east-1',
            language_code='en')
        response = model.send(text='I am very sad.')
        assert 'Sentiment' in response
def test_amazon_pipeline(cassettes_path):
    with vcr.use_cassette(str(cassettes_path /
                              'amazon_comprehend_sentiment.yaml'),
                          mode='once',
                          filter_headers=['authorization']):
        model = AmazonComprehendSentimentRequestModel(
            aws_access_key=os.environ.get('AWS_ACCESS_KEY', ''),
            aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', ''),
            region_name='us-east-1',
            language_code='en')
        template = AmazonComprehendSentimentTemplate()
        post_processor = PostProcessor({})
        labels = pipeline(text='I am very sad.',
                          request_model=model,
                          mapping_template=template,
                          post_processing=post_processor)
        labels = labels.dict()
        assert isinstance(labels, list)
        assert len(labels) == 1
        assert 'label' in labels[0]