mirror of
https://github.com/mii443/tokenizers.git
synced 2025-08-22 16:25:30 +00:00
Python - Improve AddedToken repr
This commit is contained in:
@ -74,9 +74,17 @@ impl PyObjectProtocol for AddedToken {
|
||||
}
|
||||
|
||||
fn __repr__(&self) -> PyResult<String> {
|
||||
let bool_to_python = |p| match p {
|
||||
true => "True",
|
||||
false => "False",
|
||||
};
|
||||
|
||||
Ok(format!(
|
||||
"AddedToken(\"{}\", rstrip={}, lstrip={}, single_word={})",
|
||||
self.token.content, self.token.rstrip, self.token.lstrip, self.token.single_word
|
||||
self.token.content,
|
||||
bool_to_python(self.token.rstrip),
|
||||
bool_to_python(self.token.lstrip),
|
||||
bool_to_python(self.token.single_word)
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ class TestAddedToken:
|
||||
assert str(added_token) == "<mask>"
|
||||
assert (
|
||||
repr(added_token)
|
||||
== 'AddedToken("<mask>", rstrip=false, lstrip=false, single_word=false)'
|
||||
== 'AddedToken("<mask>", rstrip=False, lstrip=False, single_word=False)'
|
||||
)
|
||||
assert added_token.rstrip == False
|
||||
assert added_token.lstrip == False
|
||||
|
Reference in New Issue
Block a user