Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/tokenizers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,8 @@ class SplitPreTokenizer extends PreTokenizer {

if (this.config.invert) {
return text.match(this.pattern) || [];
} else if (this.config.behavior?.toLowerCase() === 'removed') {
return text.split(this.pattern).filter(x => x);
} else {
return regexSplit(text, this.pattern);
}
Expand Down
10 changes: 10 additions & 0 deletions tests/models/roberta/tokenization.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,4 +691,14 @@ export const TEST_CONFIG = {
decoded: "<s> \tH\u00e4LLo!how \n Are yoU? </s>",
},
},

// Split tokenizer with behavior="Removed" and invert=false
"onnx-community/camembertv2-base": {
SIMPLE: {
text: BASE_TEST_STRINGS.SIMPLE,
tokens: ['How', 'are', 'you', 'doi', '##ng', '?'],
ids: [1, 14473, 9556, 10577, 6471, 9274, 38, 2],
decoded: "[CLS] How are you doing? [SEP]",
}
},
};
Loading