mirror of
https://github.com/mii443/tokenizers.git
synced 2025-08-22 16:25:30 +00:00
Bump derive_builder from 0.9 to 0.12 (#1129)
This commit is contained in:
@ -120,7 +120,7 @@ fn template_processing(mut cx: FunctionContext) -> JsResult<JsPostProcessor> {
|
|||||||
if let Some(pair) = pair {
|
if let Some(pair) = pair {
|
||||||
builder.try_pair(pair).map_err(Error)?;
|
builder.try_pair(pair).map_err(Error)?;
|
||||||
}
|
}
|
||||||
let processor = builder.build().map_err(Error)?;
|
let processor = builder.build().map_err(|e| Error(e.to_string()))?;
|
||||||
|
|
||||||
let mut js_processor = JsPostProcessor::new::<_, JsPostProcessor, _>(&mut cx, vec![])?;
|
let mut js_processor = JsPostProcessor::new::<_, JsPostProcessor, _>(&mut cx, vec![])?;
|
||||||
let guard = cx.lock();
|
let guard = cx.lock();
|
||||||
|
@ -405,7 +405,9 @@ impl PyTemplateProcessing {
|
|||||||
if let Some(sp) = special_tokens {
|
if let Some(sp) = special_tokens {
|
||||||
builder.special_tokens(sp);
|
builder.special_tokens(sp);
|
||||||
}
|
}
|
||||||
let processor = builder.build().map_err(exceptions::PyValueError::new_err)?;
|
let processor = builder
|
||||||
|
.build()
|
||||||
|
.map_err(|e| exceptions::PyValueError::new_err(e.to_string()))?;
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
PyTemplateProcessing {},
|
PyTemplateProcessing {},
|
||||||
|
@ -55,7 +55,7 @@ unicode-segmentation = "1.6"
|
|||||||
indicatif = {version = "0.15", optional = true}
|
indicatif = {version = "0.15", optional = true}
|
||||||
itertools = "0.9"
|
itertools = "0.9"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
derive_builder = "0.9"
|
derive_builder = "0.12"
|
||||||
spm_precompiled = "0.1"
|
spm_precompiled = "0.1"
|
||||||
dirs = "3.0"
|
dirs = "3.0"
|
||||||
reqwest = { version = "0.11", optional = true }
|
reqwest = { version = "0.11", optional = true }
|
||||||
|
@ -350,6 +350,18 @@ pub struct TemplateProcessing {
|
|||||||
special_tokens: Tokens,
|
special_tokens: Tokens,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<&str> for TemplateProcessingBuilderError {
|
||||||
|
fn from(e: &str) -> Self {
|
||||||
|
e.to_string().into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq for TemplateProcessingBuilderError {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.to_string() == other.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// We use this custom deserializer to provided the values for `added_single`
|
/// We use this custom deserializer to provided the values for `added_single`
|
||||||
/// and `added_pair` during deserialization, while not having to serialize them
|
/// and `added_pair` during deserialization, while not having to serialize them
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
@ -1074,4 +1086,18 @@ mod tests {
|
|||||||
Err("Template for `pair` must use both sequences".into())
|
Err("Template for `pair` must use both sequences".into())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn expect_wrong_error_message() {
|
||||||
|
let processor = TemplateProcessing::builder()
|
||||||
|
.try_single("$0")
|
||||||
|
.unwrap()
|
||||||
|
.try_pair("$0 $1")
|
||||||
|
.unwrap()
|
||||||
|
.build();
|
||||||
|
assert_ne!(
|
||||||
|
processor,
|
||||||
|
Err("Expect the left side error message to be different from the right side!".into())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user