Package ai.djl.modality.nlp.preprocess
Class TextTerminator
- java.lang.Object
-
- ai.djl.modality.nlp.preprocess.TextTerminator
-
- All Implemented Interfaces:
TextProcessor
public class TextTerminator extends java.lang.Object implements TextProcessor
ATextProcessor
that adds a beginning of string and end of string token.
-
-
Constructor Summary
Constructors Constructor Description TextTerminator()
Constructs a defaultTextTerminator
.TextTerminator(boolean addBosToken, boolean addEosToken)
Constructs aTextTerminator
using the default tokens.TextTerminator(boolean addBosToken, boolean addEosToken, java.lang.String bosToken, java.lang.String eosToken)
Constructs aTextTerminator
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.String>
preprocess(java.util.List<java.lang.String> tokens)
Applies the preprocessing defined to the given input tokens.
-
-
-
Constructor Detail
-
TextTerminator
public TextTerminator()
Constructs a defaultTextTerminator
.
-
TextTerminator
public TextTerminator(boolean addBosToken, boolean addEosToken)
Constructs aTextTerminator
using the default tokens.- Parameters:
addBosToken
- true to add a beginning of text tokenaddEosToken
- true to add an end of text token
-
TextTerminator
public TextTerminator(boolean addBosToken, boolean addEosToken, java.lang.String bosToken, java.lang.String eosToken)
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 Detail
-
preprocess
public java.util.List<java.lang.String> preprocess(java.util.List<java.lang.String> tokens)
Applies the preprocessing defined to the given input tokens.- Specified by:
preprocess
in interfaceTextProcessor
- Parameters:
tokens
- the tokens created after the input text is tokenized- Returns:
- the preprocessed tokens
-
-