Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Recca Tsai committed Jun 22, 2016
1 parent df81586 commit 497dcfc
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Normalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,19 @@ class Normalizer
* @var array
*/
private static $countyNameMap = [
'臺北' => '台北',
'台北縣' => '新北市',
'北市' => '台北市',
'北縣' => '新北市',
'臺南' => '台南',
'台南縣' => '台南市',
'南市' => '台南市',
'南縣' => '台南市',
'臺中' => '台中',
'台中縣' => '台中市',
'中市' => '台中市',
'中縣' => '台中市',
'高雄縣' => '高雄市',
'高縣' => '高雄市',
'高市' => '高雄市',
// '台東市' => '臺東市',
'臺東縣' => '台東縣',
];

/**
Expand Down Expand Up @@ -250,7 +246,7 @@ class Normalizer
'萬福村' => '萬福里',
'萬山村' => '萬山里',
'萬安村' => '萬安里',
'萬村' => '萬里',
'萬里村' => '萬里里',
'菁湖村' => '菁湖里',
'菁寮村' => '菁寮里',
'菁埔村' => '菁埔里',
Expand Down Expand Up @@ -479,7 +475,6 @@ class Normalizer
'後港村' => '後港里',
'後市村' => '後市里',
'後壁村' => '後壁里',
'xx村' => '後xx里',
'彭山村' => '彭山里',
'彌靖村' => '彌靖里',
'彌陀村' => '彌陀里',
Expand Down Expand Up @@ -740,7 +735,13 @@ private function normalizeCountyName($address)
{
return preg_replace_callback('/^('.implode('|', array_keys(self::$countyNameMap)).')/', function ($m) {
return self::$countyNameMap[$m[1]];
}, $address);
}, strtr($address, [
'臺北' => '台北',
'臺南' => '台南',
'臺中' => '台中',
'臺東市' => '台東市',
'臺東縣' => '台東縣',
]));
}

/**
Expand Down

0 comments on commit 497dcfc

Please sign in to comment.