Extending AutoTag support

Developers perform this task.

Brightspot ships with AutoTag support for the Article and Blog Post content types. To extend AutoTag to other content types, create an Augmentation of that type, implementing the AutoTaggable interface. This interface requires overriding the getAutoTaggableText() method to return the text submitted to Amazon Comprehend.

The following snippet implements AutoTaggable. In this example, Brightspot submits text from the headline, subheadline, and body fields.

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/>", " "))