mirror of
https://github.com/mii443/tokenizers.git
synced 2025-09-02 23:39:14 +00:00
Adding Replace
to decoder (to undo the Replace Normalizer for (#1195)
Metaspace split).
This commit is contained in:
@ -3,7 +3,17 @@ import pickle
|
||||
|
||||
import pytest
|
||||
|
||||
from tokenizers.decoders import CTC, BPEDecoder, ByteLevel, Decoder, Metaspace, Sequence, WordPiece, ByteFallback
|
||||
from tokenizers.decoders import (
|
||||
CTC,
|
||||
BPEDecoder,
|
||||
ByteLevel,
|
||||
Decoder,
|
||||
Metaspace,
|
||||
Sequence,
|
||||
WordPiece,
|
||||
ByteFallback,
|
||||
Replace,
|
||||
)
|
||||
|
||||
|
||||
class TestByteLevel:
|
||||
@ -24,6 +34,18 @@ class TestByteLevel:
|
||||
assert isinstance(reloaded, ByteLevel)
|
||||
|
||||
|
||||
class TestReplace:
|
||||
def test_instantiate(self):
|
||||
assert Replace("_", " ") is not None
|
||||
assert isinstance(Replace("_", " "), Decoder)
|
||||
assert isinstance(Replace("_", " "), Replace)
|
||||
# assert isinstance(pickle.loads(pickle.dumps(Replace("_", " "))), Replace)
|
||||
|
||||
def test_decoding(self):
|
||||
decoder = Replace("_", " ")
|
||||
assert decoder.decode(["My", "_name", "_is", "_John"]) == "My name is John"
|
||||
|
||||
|
||||
class TestWordPiece:
|
||||
def test_instantiate(self):
|
||||
assert WordPiece() is not None
|
||||
|
Reference in New Issue
Block a user