Extending AutoTag Support

Developers perform this task.

Currently AutoTag supports Articles and Blog Posts. To extend this functionality to additional content types, a developer must create an Augmentation of that type, implementing the AutoTaggable interface.

When implementing AutoTaggable, override the getAutoTaggableText() method to return the appropriate text to be submitted to the Amazon Comprehend service.

The following example shows the ArticleAutoTaggableAugmentation implementation. Note that text from the article’s headline, subheadline, and body fields are returned.

public class ArticleAutoTaggableAugmentation extends Augmentation<Article> implements AutoTaggable {
    public String getAutoTaggableText() {
        Article article = getOriginalObject();
        return Optional.ofNullable(article.getHeadline()).orElse("") + " "
                + Optional.ofNullable(article.getSubHeadline()).orElse("") + " "
                + Optional.ofNullable(article.getBody())
                        .map(body -> ((RichTextBody) body).getRichText())
                        .map(text -> text.replace("<br/>", " "))