Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/v0.1.21をmainブランチにマージ #486

Merged
merged 10 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.1.20"
version = "0.1.21"
edition = "2021"
description = "A Rust Library to parse japanese addresses."
repository = "https://github.com/YuukiToriyama/japanese-address-parser"
Expand Down
2 changes: 1 addition & 1 deletion core/src/domain/common/latlng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
pub struct LatLng {
/// 緯度
pub(crate) latitude: f64,
/// 軽度
/// 経度
pub(crate) longitude: f64,
}
30 changes: 17 additions & 13 deletions core/src/experimental/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ pub struct Parser {
}

impl Parser {
/// Parse address into token sequence.
/// Parse address into [ParsedAddress].
///
/// 住所をパースしトークン列に変換します
/// 住所をパースし、[ParsedAddress]を返します
///
/// # Example
/// ```
Expand All @@ -81,7 +81,11 @@ impl Parser {
/// async fn example() {
/// let parser = Parser::default();
/// let result = parser.parse("埼玉県所沢市上山口2135").await;
/// println!("{:?}", result);
/// assert_eq!(result.prefecture, "埼玉県");
/// assert_eq!(result.city, "所沢市");
/// assert_eq!(result.town, "上山口");
/// assert_eq!(result.rest, "2135");
/// assert_eq!(result.metadata.depth, 3);
/// }
/// ```
pub async fn parse(&self, address: &str) -> ParsedAddress {
Expand All @@ -95,15 +99,15 @@ impl Parser {
#[derive(Debug, PartialEq, Serialize)]
pub struct ParsedAddress {
/// 都道府県名
prefecture: String,
pub prefecture: String,
/// 市区町村名
city: String,
pub city: String,
/// 町名
town: String,
pub town: String,
/// それ以降
rest: String,
pub rest: String,
/// メタデータ
metadata: Metadata,
pub metadata: Metadata,
}

#[derive(Debug, PartialEq, Serialize)]
Expand All @@ -112,19 +116,19 @@ pub struct Metadata {
///
/// 住所のパースに成功し、緯度経度の情報が取得できる場合、緯度を返します。
/// 緯度経度の情報はあくまで検出できた地域の代表点を表すものであり、入力された住所の実際の位置とは必ずしも一致しないことに注意してください。
latitude: Option<f64>,
/// 軽度
pub latitude: Option<f64>,
/// 経度
///
/// 住所のパースに成功し、緯度経度の情報が取得できる場合、軽度を返します
/// 住所のパースに成功し、緯度経度の情報が取得できる場合、経度を返します
/// 緯度経度の情報はあくまで検出できた地域の代表点を表すものであり、入力された住所の実際の位置とは必ずしも一致しないことに注意してください。
longitude: Option<f64>,
pub longitude: Option<f64>,
/// パース処理の深度
///
/// - `0`: 何も検出できなかった場合
/// - `1`: 都道府県名までは検出できた場合
/// - `2`: 市区町村名までは検出できた場合
/// - `3`: 町名まで検出できた場合
depth: u8,
pub depth: u8,
}

impl From<Vec<Token>> for ParsedAddress {
Expand Down
Loading