Skip to content

Commit

Permalink
feat: 🎸 「番」の削除を末尾のみへと変更
Browse files Browse the repository at this point in the history
  • Loading branch information
flag3 committed Oct 28, 2023
1 parent 847128f commit 0ab0342
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ export const normalize: Normalizer = async (
/([0-9]+|[〇一二三四五六七八九十百千]+)\s*(番地?)\s*([0-9]+|[〇一二三四五六七八九十百千]+)\s*号?/,
'$1-$3',
)
.replace(/([0-9]+|[〇一二三四五六七八九十百千]+)番地?/, '$1')
.replace(/([0-9]+|[〇一二三四五六七八九十百千]+)番(地|$)/, '$1')
.replace(/([0-9]+|[〇一二三四五六七八九十百千]+)の/g, '$1-')
.replace(
/([0-9]+|[〇一二三四五六七八九十百千]+)[--﹣−‐⁃‑‒–—﹘―⎯⏤ーー─━]/g,
Expand Down
7 changes: 6 additions & 1 deletion test/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ for (const [runtime, normalize] of cases) {

test('東京都千代田区三番町2番地4三番町KSビル10階(番地と建物名が混ざり、「番」が消えることがないこと)', async () => {
const res = await normalize('東京都千代田区三番町2番地4三番町KSビル10階')
expect(res).toStrictEqual({"pref": "東京都", "city": "千代田区", "town": "三番町", "addr": "2-4三町KSビル10階", "lat": 35.690557, "lng": 139.743591, "level": 3})
expect(res).toStrictEqual({"pref": "東京都", "city": "千代田区", "town": "三番町", "addr": "2-4三番町KSビル10階", "lat": 35.690557, "lng": 139.743591, "level": 3})
})

test('東京都千代田区神田美土代町9番地7千代田21ビル7階(「7千代田」が「7000代田」にならないこと)', async () => {
Expand All @@ -889,6 +889,11 @@ for (const [runtime, normalize] of cases) {
})
})

test('神奈川県川崎市川崎区駅前本町15番5十五番館ビル(「5十五番館ビル」が「番」が消えずに「5十五番館ビル」となる)', async () => {
const res = await normalize('神奈川県川崎市川崎区駅前本町15番5十五番館ビル')
expect(res).toStrictEqual({"pref": "神奈川県", "city": "川崎市川崎区", "town": "駅前本町", "addr": "15-5十五番館ビル", "lat": 35.530613, "lng": 139.702222, "level": 3})
})

describe('途中にスペースを含むケース', () => {
// https://github.com/geolonia/normalize-japanese-addresses/issues/180
test('京都府京都市 下京区上之町999', async () => {
Expand Down

0 comments on commit 0ab0342

Please sign in to comment.