CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-pulumi--aws

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources with infrastructure-as-code.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

comprehend.mddocs/services/

Amazon Comprehend

Amazon Comprehend is a natural language processing (NLP) service that uses machine learning to find insights and relationships in text.

Package

import * as aws from "@pulumi/aws";

Overview

Amazon Comprehend provides pre-trained and custom ML models for text analysis.

Key Features

Sentiment Analysis

Determine positive, negative, neutral, or mixed sentiment.

const sentimentRole = new aws.iam.Role("comprehend-role", {
    assumeRolePolicy: JSON.stringify({
        Version: "2012-10-17",
        Statement: [{
            Action: "sts:AssumeRole",
            Effect: "Allow",
            Principal: {
                Service: "comprehend.amazonaws.com",
            },
        }],
    }),
});

const sentimentPolicy = new aws.iam.Policy("comprehend-s3", {
    policy: JSON.stringify({
        Version: "2012-10-17",
        Statement: [{
            Effect: "Allow",
            Action: [
                "s3:GetObject",
                "s3:ListBucket",
                "s3:PutObject",
            ],
            Resource: [
                bucket.arn,
                pulumi.interpolate`${bucket.arn}/*`,
            ],
        }],
    }),
});

new aws.iam.RolePolicyAttachment("attach", {
    role: sentimentRole.name,
    policyArn: sentimentPolicy.arn,
});

Entity Recognition

Identify people, places, organizations, dates, and more.

Key Phrase Extraction

Extract key phrases and topics from text.

Language Detection

Detect the dominant language in text.

Custom Classification

Train custom models for document classification.

const documentClassifierRole = new aws.iam.Role("classifier-role", {
    assumeRolePolicy: JSON.stringify({
        Version: "2012-10-17",
        Statement: [{
            Action: "sts:AssumeRole",
            Effect: "Allow",
            Principal: {
                Service: "comprehend.amazonaws.com",
            },
        }],
    }),
});

Custom Entity Recognition

Train models to recognize custom entities specific to your domain.

Common Patterns

Lambda Integration

const comprehendLambda = new aws.lambda.Function("text-analysis", {
    runtime: "python3.11",
    handler: "index.handler",
    role: lambdaRole.arn,
    code: new pulumi.asset.AssetArchive({
        "index.py": new pulumi.asset.StringAsset(`
import boto3
import json

comprehend = boto3.client('comprehend')

def handler(event, context):
    text = event['text']
    
    # Detect sentiment
    sentiment = comprehend.detect_sentiment(
        Text=text,
        LanguageCode='en'
    )
    
    # Extract entities
    entities = comprehend.detect_entities(
        Text=text,
        LanguageCode='en'
    )
    
    return {
        'sentiment': sentiment,
        'entities': entities
    }
        `),
    }),
});

Batch Analysis

Process large volumes of documents.

const batchRole = new aws.iam.Role("batch-role", {
    assumeRolePolicy: JSON.stringify({
        Version: "2012-10-17",
        Statement: [{
            Action: "sts:AssumeRole",
            Effect: "Allow",
            Principal: {
                Service: "comprehend.amazonaws.com",
            },
        }],
    }),
});

Use Cases

  • Customer Feedback Analysis: Analyze reviews and feedback
  • Social Media Monitoring: Track brand sentiment
  • Document Classification: Categorize support tickets
  • Content Moderation: Detect inappropriate content
  • Medical Text Analysis: Extract medical entities (Comprehend Medical)

Related Services

  • S3 - Store documents for analysis
  • Lambda - Real-time text analysis
  • Kinesis - Stream text processing
  • SageMaker - Custom ML models

Install with Tessl CLI

npx tessl i tessl/npm-pulumi--aws

docs

index.md

quickstart.md

README.md

tile.json