mirror of
https://github.com/mii443/tokenizers.git
synced 2025-08-23 16:49:27 +00:00
fix error display
This commit is contained in:
@ -15,7 +15,7 @@ impl std::error::Error for Error {}
|
|||||||
impl fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
MissingUnkToken => write!(
|
Error::MissingUnkToken => write!(
|
||||||
fmt,
|
fmt,
|
||||||
"WordPiece error: Missing [UNK] token from the vocabulary"
|
"WordPiece error: Missing [UNK] token from the vocabulary"
|
||||||
),
|
),
|
||||||
@ -158,3 +158,13 @@ impl Model for WordPiece {
|
|||||||
self.vocab_r.get(&id).map(|token| token.clone())
|
self.vocab_r.get(&id).map(|token| token.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_display() {
|
||||||
|
assert!(format!("{}", Error::MissingUnkToken).contains("Missing [UNK] token"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user