Skip to content

Commit

Permalink
ken_all.csv 由来でふりがなとローマ字のデータに不要な文字列が入ってしまうバグを修正。 (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
champierre committed Jul 7, 2022
1 parent e57da77 commit 28b071d
Show file tree
Hide file tree
Showing 4 changed files with 582 additions and 561 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v2
- run: mkdir data || true
- run: npm install
- name: Build Nagano data only
run: node bin/build.js 20,1
- name: Build Nagano, Hokkaido, and Nara data
run: node bin/build.js 20,1,29
- name: Test
run: npx mocha
15 changes: 15 additions & 0 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ const removeStringEnclosedInParentheses = text => {
return text.replace(REMOVE_STRING_IN_PARENS_REGEX, '')
}

const REMOVE_STRING_STARTING_WITH_OPENING_PARENS_REGEX = /\(.+$/
const removeStringStartingWithOpeningParentheses = text => {
return text.replace(REMOVE_STRING_STARTING_WITH_OPENING_PARENS_REGEX, '')
}

const getPostalKanaOrRomeItems = (
prefName,
cityName,
Expand Down Expand Up @@ -280,6 +285,16 @@ const getPostalKanaOrRomeItems = (
postalRecord['町域名ローマ字'] = ''
}
}

// 「ナカマチ(5115-5149、5171、5183、5186、」のような場合の「(」以降の不要な文字列を削除する。
if (postalRecord['町域名カナ']) {
postalRecord['町域名カナ'] = removeStringStartingWithOpeningParentheses(postalRecord['町域名カナ'])
}

if (postalRecord['町域名ローマ字']) {
postalRecord['町域名ローマ字'] = removeStringStartingWithOpeningParentheses(postalRecord['町域名ローマ字'])
}

return postalRecord
}
}
Expand Down
Loading

0 comments on commit 28b071d

Please sign in to comment.