Class TextTruncator

java.lang.Object
ai.djl.modality.nlp.preprocess.TextTruncator
All Implemented Interfaces:
TextProcessor

public class TextTruncator extends Object implements TextProcessor
TextProcessor that truncates text to a maximum size.
  • Constructor Details

    • TextTruncator

      public TextTruncator(int maxSize)
      Constructs a TextTruncator.
      Parameters:
      maxSize - the size to limit the text to
  • Method Details

    • preprocess

      public List<String> preprocess(List<String> tokens)
      Applies the preprocessing defined to the given input tokens.
      Specified by:
      preprocess in interface TextProcessor
      Parameters:
      tokens - the tokens created after the input text is tokenized
      Returns:
      the preprocessed tokens