Package ai.djl.modality.nlp.preprocess
Class TextTerminator
java.lang.Object
ai.djl.modality.nlp.preprocess.TextTerminator
- All Implemented Interfaces:
TextProcessor
A
TextProcessor that adds a beginning of string and end of string token.-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a defaultTextTerminator.TextTerminator(boolean addBosToken, boolean addEosToken) Constructs aTextTerminatorusing the default tokens.TextTerminator(boolean addBosToken, boolean addEosToken, String bosToken, String eosToken) Constructs aTextTerminator. -
Method Summary
Modifier and TypeMethodDescriptionpreprocess(List<String> tokens) Applies the preprocessing defined to the given input tokens.
-
Constructor Details
-
TextTerminator
public TextTerminator()Constructs a defaultTextTerminator. -
TextTerminator
public TextTerminator(boolean addBosToken, boolean addEosToken) Constructs aTextTerminatorusing the default tokens.- Parameters:
addBosToken- true to add a beginning of text tokenaddEosToken- true to add an end of text token
-
TextTerminator
Constructs aTextTerminator.- Parameters:
addBosToken- true to add a beginning of text tokenaddEosToken- true to add an end of text tokenbosToken- the token to add to the beginning of the texteosToken- the token to add to the end of the text
-
-
Method Details
-
preprocess
Applies the preprocessing defined to the given input tokens.- Specified by:
preprocessin interfaceTextProcessor- Parameters:
tokens- the tokens created after the input text is tokenized- Returns:
- the preprocessed tokens
-