Skip to content

Commit

Permalink
update: #410: フィーチャフラグeliminate-whitespacesが指定された場合、入力された文字列からホワイトス…
Browse files Browse the repository at this point in the history
…ペースを取り除くようにした
  • Loading branch information
YuukiToriyama committed Sep 12, 2024
1 parent 9ff4e88 commit 8aaebcd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ default = ["city-name-correction"]
blocking = ["reqwest/blocking"]
city-name-correction = []
format-house-number = []
eliminate-whitespaces = []

[dependencies]
itertools = "0.13.0"
Expand Down
17 changes: 16 additions & 1 deletion core/src/tokenizer/read_prefecture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ impl Tokenizer<Init> {
prefecture_name: None,
city_name: None,
town_name: None,
rest: input.strip_variation_selectors(),
rest: if cfg!(feature = "eliminate-whitespaces") {
input.strip_variation_selectors().strip_whitespaces()
} else {
input.strip_variation_selectors()
},
_state: PhantomData,
}
}
Expand Down Expand Up @@ -117,6 +121,17 @@ mod tests {
assert_eq!(tokenizer.rest, "東京都葛飾区立石5-13-1")
}

#[test]
#[cfg(feature = "eliminate-whitespaces")]
fn new_ホワイトスペース除却() {
let tokenizer = Tokenizer::new("東京都 目黒区 下目黒 4‐1‐1");
assert_eq!(tokenizer.input, "東京都 目黒区 下目黒 4‐1‐1");
assert_eq!(tokenizer.prefecture_name, None);
assert_eq!(tokenizer.city_name, None);
assert_eq!(tokenizer.town_name, None);
assert_eq!(tokenizer.rest, "東京都目黒区下目黒4‐1‐1")
}

#[test]
fn read_prefecture_成功() {
let tokenizer = Tokenizer::new("東京都港区芝公園4丁目2-8");
Expand Down

0 comments on commit 8aaebcd

Please sign in to comment.