#[derive(Clone, Debug, Default)]
pub struct SegmentOptions {
pub auto_cjk: bool,
pub all_mod: bool,
pub node_novel_mode: bool,
pub nomod: bool,
pub nodict: bool,
pub options_do_segment: DoSegmentOptions,
pub max_chunk_count: Option<usize>,
pub min_chunk_count: Option<usize>,
pub disable_modules: Vec<String>,
}
#[derive(Clone, Debug, Default)]
pub struct DoSegmentOptions {
pub simple: Option<bool>,
pub strip_punctuation: Option<bool>,
pub convert_synonym: Option<bool>,
pub strip_stopword: Option<bool>,
pub strip_space: Option<bool>,
pub disable_modules: Vec<String>,
}
impl DoSegmentOptions {
pub fn convert_synonym() -> Self {
Self {
convert_synonym: Some(true),
..Default::default()
}
}
pub fn merge(&self, over: &Self) -> Self {
Self {
simple: over.simple.or(self.simple),
strip_punctuation: over.strip_punctuation.or(self.strip_punctuation),
convert_synonym: over.convert_synonym.or(self.convert_synonym),
strip_stopword: over.strip_stopword.or(self.strip_stopword),
strip_space: over.strip_space.or(self.strip_space),
disable_modules: if over.disable_modules.is_empty() {
self.disable_modules.clone()
} else {
over.disable_modules.clone()
},
}
}
pub fn simple_flag(&self) -> bool {
self.simple.unwrap_or(false)
}
pub fn strip_punctuation_flag(&self) -> bool {
self.strip_punctuation.unwrap_or(false)
}
pub fn convert_synonym_flag(&self) -> bool {
self.convert_synonym.unwrap_or(false)
}
pub fn strip_stopword_flag(&self) -> bool {
self.strip_stopword.unwrap_or(false)
}
pub fn strip_space_flag(&self) -> bool {
self.strip_space.unwrap_or(false)
}
}