Package ai.djl.modality.nlp.preprocess
Class TextCleaner
java.lang.Object
ai.djl.modality.nlp.preprocess.TextCleaner
- All Implemented Interfaces:
TextProcessor
Applies remove or replace of certain characters based on condition.
-
Constructor Summary
ConstructorsConstructorDescriptionTextCleaner
(Function<Character, Boolean> condition) Remove a character if it meets the condition supplied.TextCleaner
(Function<Character, Boolean> condition, char replace) Replace a character if it meets the condition supplied. -
Method Summary
Modifier and TypeMethodDescriptionpreprocess
(List<String> tokens) Applies the preprocessing defined to the given input tokens.
-
Constructor Details
-
TextCleaner
Remove a character if it meets the condition supplied.- Parameters:
condition
- lambda function that defines whether a character meets condition
-
TextCleaner
Replace a character if it meets the condition supplied.- Parameters:
condition
- lambda function that defines whether a character meets conditionreplace
- the character to replace
-
-
Method Details
-
preprocess
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
-