-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
郡名と町名が一致している場合: 類似度測定による候補を更に絞り込む (#292)
* update: #268: `VagueExpressionAdapter`に単体テストを追加 * update: #268: `get_most_similar_match()`を分解 * add: #268: `trim_city_name()`を定義 * add: #268: `trim_city_name()`を使用し候補を絞るようにした * update: #268: 結合テスト`郡名と町名が一致している場合()`を有効化
- Loading branch information
1 parent
65a5bd5
commit 9204588
Showing
5 changed files
with
101 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod converter; | ||
pub mod sequence_matcher; | ||
mod trimmer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pub fn trim_city_name(input: &str) -> String { | ||
match input.chars().position(|c| c == '郡' || c == '市') { | ||
Some(position) => input.chars().skip(position + 1).collect::<String>(), | ||
None => input.to_string(), | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::util::trimmer::trim_city_name; | ||
|
||
#[test] | ||
fn trim_city_name_成功() { | ||
assert_eq!(trim_city_name("南会津郡下郷町"), "下郷町"); | ||
assert_eq!(trim_city_name("南会津郡只見町"), "只見町"); | ||
assert_eq!(trim_city_name("白河市新白河一丁目"), "新白河一丁目"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters