Skip to content

Commit 776e311

Browse files
committed
CountVectorizerValidParams: serde for split_regex
1 parent d3d14fc commit 776e311

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

algorithms/linfa-preprocessing/src/countgrams/hyperparams.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ impl SerdeRegex {
3535
}
3636

3737
fn as_re(&self) -> &Regex {
38-
use std::ops::Deref;
39-
&self.0.deref()
38+
&self.0
4039
}
4140
}
4241

@@ -68,6 +67,7 @@ impl SerdeRegex {
6867
pub struct CountVectorizerValidParams {
6968
convert_to_lowercase: bool,
7069
split_regex_expr: String,
70+
#[cfg_attr(feature = "serde", serde(skip, default = "OnceLock::new"))]
7171
split_regex: OnceLock<SerdeRegex>,
7272
n_gram_range: (usize, usize),
7373
normalize: bool,
@@ -95,7 +95,7 @@ impl CountVectorizerValidParams {
9595
pub fn split_regex(&self) -> &Regex {
9696
self.split_regex
9797
.get()
98-
.expect("Regex not initialized")
98+
.expect("Regex not initialized; call `check_ref()` first")
9999
.as_re()
100100
}
101101

@@ -124,7 +124,7 @@ impl CountVectorizerValidParams {
124124
#[derive(Clone, Debug)]
125125
pub struct CountVectorizerParams(CountVectorizerValidParams);
126126

127-
impl std::default::Default for CountVectorizerParams {
127+
impl Default for CountVectorizerParams {
128128
fn default() -> Self {
129129
Self(CountVectorizerValidParams {
130130
convert_to_lowercase: true,

0 commit comments

Comments
 (0)