Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6cf1db8

Browse files
committed
test
1 parent afe8d19 commit 6cf1db8

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎tests/utils/test_tokenization_utils.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,21 @@ def test_push_to_hub_dynamic_tokenizer_with_both_slow_and_fast_classes(self):
198198
self.assertEqual(tokenizer.__class__.__name__, "CustomTokenizerFast")
199199

200200

201+
@require_tokenizers
202+
class TokenizersBackendTest(unittest.TestCase):
203+
def test_clean_up_tokenization_spaces(self):
204+
tokenizer = GPT2TokenizerFast.from_pretrained("openai-community/gpt2")
205+
206+
text_with_artifacts = "Hello , how are you ? I 'm here ."
207+
token_ids = tokenizer.encode(text_with_artifacts)
208+
209+
decoded_no_cleanup = tokenizer.decode(token_ids, clean_up_tokenization_spaces=False)
210+
self.assertEqual(decoded_no_cleanup, "Hello , how are you ? I 'm here .")
211+
212+
decoded_with_cleanup = tokenizer.decode(token_ids, clean_up_tokenization_spaces=True)
213+
self.assertEqual(decoded_with_cleanup, "Hello, how are you? I'm here.")
214+
215+
201216
class TrieTest(unittest.TestCase):
202217
def test_trie(self):
203218
trie = Trie()

0 commit comments

Comments
 (0)