Skip to content

Commit

Permalink
Add test case to token split
Browse files Browse the repository at this point in the history
  • Loading branch information
jiongjiongli committed Dec 29, 2024
1 parent 52a3820 commit 6d8eb68
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/tokenization/test_tokenization_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,18 @@ def test_decoding_skip_special_tokens(self):
decoded_sent = tokenizer.decode(pad_id, skip_special_tokens=False)
self.assertEqual(decoded_sent, "[PAD]")

@require_tokenizers
def test_split_tokens(self):
for tokenizer_class in [BertTokenizer, BertTokenizerFast]:
with self.subTest(f"{tokenizer_class}"):
tokenizer = tokenizer_class.from_pretrained("google-bert/bert-base-cased")
tokenizer.add_tokens(["red", "e"])

# test split tokens
sentence = "read"
output_tokens = tokenizer.tokenize(sentence)
self.assertEqual(output_tokens, ["r", "e", "ad"])

@require_torch
def test_padding_accepts_tensors_pt(self):
import torch
Expand Down

0 comments on commit 6d8eb68

Please sign in to comment.