Support and Documentation

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. It returns text from the article's headline, subheadline, and body fields.

public class ArticleAutoTaggableAugmentation extends Augmentation<Article> implements AutoTaggable {

    @Override
    public String getAutoTaggableText() {

        Article article = getOriginalObject();
        return Optional.ofNullable(article.getHeadline()).orElse("") + " "
                + Optional.ofNullable(article.getSubHeadline()).orElse("") + " "
                + Optional.ofNullable(article.getBody())
                        .filter(RichTextBody.class::isInstance)
                        .map(body -> ((RichTextBody) body).getRichText())
                        .map(text -> text.replace("<br/>", " "))
                        .map(RichTextUtils::stripRichTextElements)
                        .map(RichTextUtils::richTextToPlainText)
                        .orElse("");
     }
}