Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
blueshen committed Jun 25, 2023
1 parent b150276 commit 4d41648
Show file tree
Hide file tree
Showing 11 changed files with 218 additions and 102 deletions.
204 changes: 164 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ once_cell = "1.16.0"
log = "0.4.17"

[dev-dependencies]
criterion = "0.4.0"
criterion = { version = "0.5.1", features = ["html_reports"] }
random-string = "1.0.0"

[[bench]]
Expand Down
1 change: 0 additions & 1 deletion src/config/default_config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::config::configuration::Configuration;
use serde;
use serde::{Deserialize, Serialize};
#[warn(unused_imports)]
use serde_yaml;
use std::fs::File;
use std::io::{BufReader, Read};
Expand Down
8 changes: 1 addition & 7 deletions src/core/cjk_segmenter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::dict::dictionary::GLOBAL_DICT;

const SEGMENTER_NAME: &str = "CJK_SEGMENTER";

#[derive(Debug)]
#[derive(Default, Debug)]
pub struct CJKSegmenter {}

impl Segmenter for CJKSegmenter {
Expand Down Expand Up @@ -41,9 +41,3 @@ impl Segmenter for CJKSegmenter {
return SEGMENTER_NAME;
}
}

impl CJKSegmenter {
pub fn new() -> Self {
CJKSegmenter {}
}
}
14 changes: 8 additions & 6 deletions src/core/cn_quantifier_segmenter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ impl Segmenter for CnQuantifierSegmenter {
}
}

impl CnQuantifierSegmenter {
pub fn new() -> Self {
impl Default for CnQuantifierSegmenter {
fn default() -> Self {
CnQuantifierSegmenter {
start: None,
end: None,
Expand All @@ -43,7 +43,9 @@ impl CnQuantifierSegmenter {
]),
}
}
}

impl CnQuantifierSegmenter {
fn process_cnumber(
&mut self,
input: &str,
Expand Down Expand Up @@ -141,17 +143,17 @@ impl CnQuantifierSegmenter {
}

fn initial_state(&self) -> bool {
match self.start {
return match self.start {
None => match self.end {
None => {
return true;
true
}
Some(_) => {
return false;
false
}
},
Some(_) => {
return false;
false
}
}
}
Expand Down
Loading

0 comments on commit 4d41648

Please sign in to comment.