Skip to content

europeanplaice/address_normalizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

address_normalizer

Boost Qiを用いて住所を正規化します。

Address address_parse(std::string address_string);

結果は Address構造体として返ります。

struct Address {
    std::string prefecture; //都道府県
    std::string county; //
    std::string municipality; //市区町村
    std::string ward; //区行政区
    std::string town; //町名
    std::string district; //番地
    std::string prefecture_suffix; // 都道府県接尾辞
    std::string municipality_suffix; // 市区町村接尾辞
    std::string subarea; // 丁目
    std::string block; //
    std::string building_num ; //
    std::string building_name ; // ビル名
    std::string building_floor ; // ビル フロア
};

例(単体テストより抜粋)

#include <gtest/gtest.h>
#include "parser.h"

TEST(ParserTest, BasicAssertions2){
    std::string s("山梨県南巨摩郡身延町切石350");
    Address address_parsed = address_parse(s);
    EXPECT_EQ("山梨", address_parsed.prefecture);
    EXPECT_EQ("", address_parsed.prefecture_suffix);
    EXPECT_EQ("南巨摩", address_parsed.county);
    EXPECT_EQ("身延", address_parsed.municipality);
    EXPECT_EQ("", address_parsed.municipality_suffix);
    EXPECT_EQ("切石", address_parsed.town);
    EXPECT_EQ("350", address_parsed.district);
}

TEST(ParserTest, Buildings){
    std::string s("東京都港区六本木6-10-1六本木ヒルズ森タワー53階");
    Address address_parsed = address_parse(s);
    EXPECT_EQ("東京", address_parsed.prefecture);
    EXPECT_EQ("", address_parsed.prefecture_suffix);
    EXPECT_EQ("", address_parsed.municipality);
    EXPECT_EQ("", address_parsed.municipality_suffix);
    EXPECT_EQ("六本木", address_parsed.town);
    EXPECT_EQ("6", address_parsed.subarea);
    EXPECT_EQ("10", address_parsed.block);
    EXPECT_EQ("1", address_parsed.building_num);
    EXPECT_EQ("六本木ヒルズ森タワー", address_parsed.building_name);
    EXPECT_EQ("53", address_parsed.building_floor);
}

About

Boost Qiを用いて住所を正規化します。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published