japanese_address_parser 2.2.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/CHANGELOG.md +15 -0
  4. data/Dockerfile +15 -0
  5. data/Gemfile.lock +25 -24
  6. data/README.md +8 -0
  7. data/docker-compose.yml +6 -0
  8. data/japanese_address_parser.gemspec +2 -2
  9. data/js/node_modules/.package-lock.json +7 -7
  10. data/js/node_modules/@geolonia/japanese-numeral/dist/index.js +1 -1
  11. data/js/node_modules/@geolonia/japanese-numeral/dist/oldJapaneseNumerics.js +1 -0
  12. data/js/node_modules/@geolonia/japanese-numeral/dist/utils.js +5 -1
  13. data/js/node_modules/@geolonia/japanese-numeral/package.json +1 -1
  14. data/js/node_modules/@geolonia/japanese-numeral/src/index.ts +1 -1
  15. data/js/node_modules/@geolonia/japanese-numeral/src/oldJapaneseNumerics.ts +1 -0
  16. data/js/node_modules/@geolonia/japanese-numeral/src/utils.ts +6 -1
  17. data/js/node_modules/@geolonia/japanese-numeral/test/test.ts +5 -0
  18. data/js/node_modules/@geolonia/normalize-japanese-addresses/README.md +21 -14
  19. data/js/node_modules/@geolonia/normalize-japanese-addresses/dist/config.d.ts +1 -5
  20. data/js/node_modules/@geolonia/normalize-japanese-addresses/dist/lib/cacheRegexes.d.ts +1 -0
  21. data/js/node_modules/@geolonia/normalize-japanese-addresses/dist/main-browser.d.ts +1 -1
  22. data/js/node_modules/@geolonia/normalize-japanese-addresses/dist/main-browser.js +94 -36
  23. data/js/node_modules/@geolonia/normalize-japanese-addresses/dist/main-node.d.ts +1 -1
  24. data/js/node_modules/@geolonia/normalize-japanese-addresses/dist/main-node.js +88 -35
  25. data/js/node_modules/@geolonia/normalize-japanese-addresses/dist/normalize.d.ts +13 -0
  26. data/js/node_modules/@geolonia/normalize-japanese-addresses/package.json +4 -4
  27. data/js/node_modules/@geolonia/normalize-japanese-addresses/src/config.ts +1 -6
  28. data/js/node_modules/@geolonia/normalize-japanese-addresses/src/lib/cacheRegexes.ts +45 -9
  29. data/js/node_modules/@geolonia/normalize-japanese-addresses/src/lib/dict.ts +2 -2
  30. data/js/node_modules/@geolonia/normalize-japanese-addresses/src/main-browser.ts +1 -2
  31. data/js/node_modules/@geolonia/normalize-japanese-addresses/src/main-node.ts +2 -3
  32. data/js/node_modules/@geolonia/normalize-japanese-addresses/src/normalize.ts +43 -15
  33. data/js/package-lock.json +14 -14
  34. data/lib/japanese_address_parser/data/01-01204.csv +1 -1
  35. data/lib/japanese_address_parser/data/01-01206.csv +2 -2
  36. data/lib/japanese_address_parser/data/01-01210.csv +1 -1
  37. data/lib/japanese_address_parser/data/01-01224.csv +1 -1
  38. data/lib/japanese_address_parser/data/01-01230.csv +1 -1
  39. data/lib/japanese_address_parser/data/01-01303.csv +1 -1
  40. data/lib/japanese_address_parser/data/01-01407.csv +3 -3
  41. data/lib/japanese_address_parser/data/01-01610.csv +1 -1
  42. data/lib/japanese_address_parser/data/01-01632.csv +1 -1
  43. data/lib/japanese_address_parser/data/01-01637.csv +1 -1
  44. data/lib/japanese_address_parser/data/01-01646.csv +1 -1
  45. data/lib/japanese_address_parser/data/01-01691.csv +1 -1
  46. data/lib/japanese_address_parser/data/03-03202.csv +1 -1
  47. data/lib/japanese_address_parser/data/03-03205.csv +29 -29
  48. data/lib/japanese_address_parser/data/03-03209.csv +56 -56
  49. data/lib/japanese_address_parser/data/03-03213.csv +1 -1
  50. data/lib/japanese_address_parser/data/03-03302.csv +1 -1
  51. data/lib/japanese_address_parser/data/03-03366.csv +1 -1
  52. data/lib/japanese_address_parser/data/03-03483.csv +1 -1
  53. data/lib/japanese_address_parser/data/03-03524.csv +1 -1
  54. data/lib/japanese_address_parser/data/04-04101.csv +6 -6
  55. data/lib/japanese_address_parser/data/04-04206.csv +32 -32
  56. data/lib/japanese_address_parser/data/04-04207.csv +41 -41
  57. data/lib/japanese_address_parser/data/06-06203.csv +1 -1
  58. data/lib/japanese_address_parser/data/07-07207.csv +1 -1
  59. data/lib/japanese_address_parser/data/07-07301.csv +2 -2
  60. data/lib/japanese_address_parser/data/11-11201.csv +3 -3
  61. data/lib/japanese_address_parser/data/12-12211.csv +1 -1
  62. data/lib/japanese_address_parser/data/12-12215.csv +2 -2
  63. data/lib/japanese_address_parser/data/13-13103.csv +2 -2
  64. data/lib/japanese_address_parser/data/13-13104.csv +3 -3
  65. data/lib/japanese_address_parser/data/13-13116.csv +5 -5
  66. data/lib/japanese_address_parser/data/14-14402.csv +2 -2
  67. data/lib/japanese_address_parser/data/15-15210.csv +5 -5
  68. data/lib/japanese_address_parser/data/15-15222.csv +4 -4
  69. data/lib/japanese_address_parser/data/15-15226.csv +1 -1
  70. data/lib/japanese_address_parser/data/16-16207.csv +1 -1
  71. data/lib/japanese_address_parser/data/16-16323.csv +2 -2
  72. data/lib/japanese_address_parser/data/17-17201.csv +26 -26
  73. data/lib/japanese_address_parser/data/17-17202.csv +1 -1
  74. data/lib/japanese_address_parser/data/17-17206.csv +29 -29
  75. data/lib/japanese_address_parser/data/19-19209.csv +1 -1
  76. data/lib/japanese_address_parser/data/19-19213.csv +2 -2
  77. data/lib/japanese_address_parser/data/20-20210.csv +1 -1
  78. data/lib/japanese_address_parser/data/20-20385.csv +14 -0
  79. data/lib/japanese_address_parser/data/20.csv +1 -13
  80. data/lib/japanese_address_parser/data/22-22135.csv +1 -1
  81. data/lib/japanese_address_parser/data/22-22209.csv +1 -1
  82. data/lib/japanese_address_parser/data/22-22210.csv +1 -1
  83. data/lib/japanese_address_parser/data/22-22211.csv +1 -1
  84. data/lib/japanese_address_parser/data/22-22325.csv +2 -2
  85. data/lib/japanese_address_parser/data/22-22341.csv +1 -1
  86. data/lib/japanese_address_parser/data/23-23105.csv +5 -5
  87. data/lib/japanese_address_parser/data/24-24205.csv +1 -1
  88. data/lib/japanese_address_parser/data/25-25202.csv +1 -1
  89. data/lib/japanese_address_parser/data/26-26102.csv +14 -14
  90. data/lib/japanese_address_parser/data/26-26103.csv +1 -1
  91. data/lib/japanese_address_parser/data/26-26104.csv +9 -9
  92. data/lib/japanese_address_parser/data/26-26105.csv +4 -4
  93. data/lib/japanese_address_parser/data/26-26106.csv +15 -15
  94. data/lib/japanese_address_parser/data/26-26107.csv +1 -1
  95. data/lib/japanese_address_parser/data/27-27145.csv +1 -1
  96. data/lib/japanese_address_parser/data/27-27202.csv +1 -1
  97. data/lib/japanese_address_parser/data/27-27208.csv +2 -2
  98. data/lib/japanese_address_parser/data/27-27211.csv +1 -1
  99. data/lib/japanese_address_parser/data/27-27227.csv +2 -2
  100. data/lib/japanese_address_parser/data/28-28109.csv +41 -41
  101. data/lib/japanese_address_parser/data/28-28201.csv +1 -1
  102. data/lib/japanese_address_parser/data/28-28204.csv +1 -1
  103. data/lib/japanese_address_parser/data/28-28208.csv +7 -7
  104. data/lib/japanese_address_parser/data/28-28217.csv +3 -3
  105. data/lib/japanese_address_parser/data/28-28226.csv +1 -1
  106. data/lib/japanese_address_parser/data/29-29201.csv +50 -50
  107. data/lib/japanese_address_parser/data/29-29203.csv +1 -1
  108. data/lib/japanese_address_parser/data/30-30304.csv +3 -3
  109. data/lib/japanese_address_parser/data/34-34210.csv +2 -2
  110. data/lib/japanese_address_parser/data/35-35201.csv +1 -1
  111. data/lib/japanese_address_parser/data/35-35213.csv +2 -2
  112. data/lib/japanese_address_parser/data/36-36201.csv +15 -15
  113. data/lib/japanese_address_parser/data/36-36202.csv +14 -14
  114. data/lib/japanese_address_parser/data/36-36207.csv +3 -3
  115. data/lib/japanese_address_parser/data/36-36208.csv +1 -1
  116. data/lib/japanese_address_parser/data/36-36468.csv +23 -23
  117. data/lib/japanese_address_parser/data/38-38202.csv +1 -1
  118. data/lib/japanese_address_parser/data/38-38203.csv +1 -1
  119. data/lib/japanese_address_parser/data/38-38210.csv +1 -1
  120. data/lib/japanese_address_parser/data/38-38422.csv +2 -2
  121. data/lib/japanese_address_parser/data/39-39206.csv +1 -1
  122. data/lib/japanese_address_parser/data/39-39210.csv +1 -1
  123. data/lib/japanese_address_parser/data/39-39212.csv +3 -3
  124. data/lib/japanese_address_parser/data/39-39386.csv +2 -2
  125. data/lib/japanese_address_parser/data/39-39412.csv +1 -1
  126. data/lib/japanese_address_parser/data/40-40131.csv +7 -7
  127. data/lib/japanese_address_parser/data/41-41201.csv +1 -1
  128. data/lib/japanese_address_parser/data/42-42214.csv +1 -1
  129. data/lib/japanese_address_parser/data/43-43101.csv +2 -2
  130. data/lib/japanese_address_parser/data/43-43204.csv +1 -1
  131. data/lib/japanese_address_parser/data/43-43205.csv +2 -2
  132. data/lib/japanese_address_parser/data/43-43215.csv +3 -3
  133. data/lib/japanese_address_parser/data/44-44204.csv +1 -1
  134. data/lib/japanese_address_parser/data/45-45201.csv +2 -2
  135. data/lib/japanese_address_parser/data/45-45202.csv +1 -1
  136. data/lib/japanese_address_parser/data/45-45203.csv +2 -2
  137. data/lib/japanese_address_parser/data/46-46201.csv +2 -2
  138. data/lib/japanese_address_parser/data/46-46210.csv +1 -1
  139. data/lib/japanese_address_parser/data/46-46215.csv +1 -1
  140. data/lib/japanese_address_parser/data/46-46216.csv +1 -1
  141. data/lib/japanese_address_parser/data/46-46217.csv +4 -4
  142. data/lib/japanese_address_parser/data/46-46218.csv +3 -3
  143. data/lib/japanese_address_parser/data/46-46221.csv +1 -1
  144. data/lib/japanese_address_parser/models/prefecture.rb +2 -13
  145. data/lib/japanese_address_parser/version.rb +1 -1
  146. metadata +10 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c72404909fd5b006109dce08ec33c77f8cc0b592dd7a8f33aee8c0cbd269a883
4
- data.tar.gz: ee2da5984f6e06ef0739e18bcac4f17b53b86b764d59e178fb23b06792324678
3
+ metadata.gz: 72363aa74cf45e200716ce789f6755ea43b23b556d913a76cd4479e88c44e571
4
+ data.tar.gz: 844e5565b51f6cb3d630b244d77c6197cbbc35e6f57015d807ef546173e03f59
5
5
  SHA512:
6
- metadata.gz: 708d3a884f7c4d6da95944da2da0450e1fcde68fcee1193be497a03130432d3205e25625d9cd23dd1b7935a49d11374489b51594a0c0853474b33fd2cfed7ea4
7
- data.tar.gz: c8eb589b93201d7e20fdb905a157925e2d984a0135c1e72f32828ef14bffc2bd09de7b225824c01ba71e93370f565a79d2070f79899b3f1c72e730d967c781af
6
+ metadata.gz: 780a695538d70fdded3cc8a2be167241f006fa4719658cb7d556d52911be7a91addb6fdea8a7989fcccd945229fa3f8a4dc76007f982f9ba8a5c9a39c175e6e8
7
+ data.tar.gz: 98ba158b5ccce3fd5b49f6e1ca1eb0f9a3958dbaf0f0d1bb6bddd944208cea89f29195b5688ed43d2b687653e92e9caad3d60f0c0a8cad00e0cd3a0797d3d0ab
data/.rubocop.yml CHANGED
@@ -6,6 +6,7 @@ require:
6
6
 
7
7
  AllCops:
8
8
  EnabledByDefault: true
9
+ TargetRubyVersion: 2.7
9
10
 
10
11
  Metrics/BlockLength:
11
12
  Exclude:
@@ -35,3 +36,6 @@ Style/StringHashKeys:
35
36
  # elseがない場合にはcase文ではなくif文を許容する。
36
37
  Style/MissingElse:
37
38
  EnforcedStyle: case
39
+
40
+ Gemspec/DependencyVersion:
41
+ EnforcedStyle: forbidden
data/CHANGELOG.md CHANGED
@@ -17,6 +17,21 @@ Change Log の形式は [Keep a Changelog](http://keepachangelog.com/) に従い
17
17
 
18
18
  ### Security
19
19
 
20
+ ## [3.0.0] - 2022-09-25
21
+ ### Added
22
+
23
+ - [#49](https://github.com/yamat47/japanese_address_parser/pull/49) Dockerを使って開発環境の準備をできるようにした。([@yamat47](https://github.com/yamat47))
24
+
25
+ ### Security
26
+
27
+ - [#51](https://github.com/yamat47/japanese_address_parser/pull/51) Ruby 2.6 のサポートを切った。([@yamat47](https://github.com/yamat47))
28
+
29
+ ## [2.2.1] - 2022-07-16
30
+ ### Changed
31
+
32
+ - [#45](https://github.com/yamat47/japanese_address_parser/pull/45) geolonia/japanese-addressesのバージョンを上げた。([@yamat47](https://github.com/yamat47))
33
+ - [#46](https://github.com/yamat47/japanese_address_parser/pull/46) CIでRSpecを並列実行させるようにした。([@yamat47](https://github.com/yamat47))
34
+
20
35
  ## [2.2.0] - 2022-03-12
21
36
  ### Added
22
37
 
data/Dockerfile ADDED
@@ -0,0 +1,15 @@
1
+ FROM ruby:3.1.2-alpine
2
+
3
+ ENV LANG=C.UTF-8 \
4
+ APP_HOME=/gemsrc
5
+
6
+ # `japanese_address_parser.gemspec` needs git.
7
+ RUN apk update && \
8
+ apk add --virtual build-dependencies --no-cache git nodejs make gcc musl-dev
9
+
10
+ RUN mkdir $APP_HOME
11
+ WORKDIR $APP_HOME
12
+
13
+ COPY . $APP_HOME
14
+
15
+ RUN bundle install
data/Gemfile.lock CHANGED
@@ -1,32 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- japanese_address_parser (2.2.0)
4
+ japanese_address_parser (3.0.0)
5
5
  schmooze
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (6.1.4.6)
10
+ activesupport (7.0.4)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 1.6, < 2)
13
13
  minitest (>= 5.1)
14
14
  tzinfo (~> 2.0)
15
- zeitwerk (~> 2.3)
16
15
  ast (2.4.2)
17
- concurrent-ruby (1.1.9)
16
+ concurrent-ruby (1.1.10)
18
17
  diff-lcs (1.5.0)
19
- factory_bot (6.2.0)
18
+ factory_bot (6.2.1)
20
19
  activesupport (>= 5.0.0)
21
- i18n (1.10.0)
20
+ i18n (1.12.0)
22
21
  concurrent-ruby (~> 1.0)
23
- minitest (5.15.0)
24
- parallel (1.21.0)
25
- parser (3.1.1.0)
22
+ json (2.6.2)
23
+ minitest (5.16.3)
24
+ parallel (1.22.1)
25
+ parser (3.1.2.1)
26
26
  ast (~> 2.4.1)
27
27
  rainbow (3.1.1)
28
28
  rake (13.0.6)
29
- regexp_parser (2.2.1)
29
+ regexp_parser (2.5.0)
30
30
  rexml (3.2.5)
31
31
  rspec (3.11.0)
32
32
  rspec-core (~> 3.11.0)
@@ -34,42 +34,43 @@ GEM
34
34
  rspec-mocks (~> 3.11.0)
35
35
  rspec-core (3.11.0)
36
36
  rspec-support (~> 3.11.0)
37
- rspec-expectations (3.11.0)
37
+ rspec-expectations (3.11.1)
38
38
  diff-lcs (>= 1.2.0, < 2.0)
39
39
  rspec-support (~> 3.11.0)
40
- rspec-mocks (3.11.0)
40
+ rspec-mocks (3.11.1)
41
41
  diff-lcs (>= 1.2.0, < 2.0)
42
42
  rspec-support (~> 3.11.0)
43
- rspec-support (3.11.0)
44
- rubocop (1.25.1)
43
+ rspec-support (3.11.1)
44
+ rubocop (1.36.0)
45
+ json (~> 2.3)
45
46
  parallel (~> 1.10)
46
- parser (>= 3.1.0.0)
47
+ parser (>= 3.1.2.1)
47
48
  rainbow (>= 2.2.2, < 4.0)
48
49
  regexp_parser (>= 1.8, < 3.0)
49
- rexml
50
- rubocop-ast (>= 1.15.1, < 2.0)
50
+ rexml (>= 3.2.5, < 4.0)
51
+ rubocop-ast (>= 1.20.1, < 2.0)
51
52
  ruby-progressbar (~> 1.7)
52
53
  unicode-display_width (>= 1.4.0, < 3.0)
53
- rubocop-ast (1.16.0)
54
+ rubocop-ast (1.21.0)
54
55
  parser (>= 3.1.1.0)
55
56
  rubocop-rake (0.6.0)
56
57
  rubocop (~> 1.0)
57
- rubocop-rspec (2.9.0)
58
- rubocop (~> 1.19)
58
+ rubocop-rspec (2.13.2)
59
+ rubocop (~> 1.33)
59
60
  ruby-progressbar (1.11.0)
60
61
  schmooze (0.2.0)
61
- tzinfo (2.0.4)
62
+ tzinfo (2.0.5)
62
63
  concurrent-ruby (~> 1.0)
63
- unicode-display_width (2.1.0)
64
- zeitwerk (2.5.4)
64
+ unicode-display_width (2.3.0)
65
65
 
66
66
  PLATFORMS
67
+ aarch64-linux-musl
67
68
  arm64-darwin-21
68
69
  x86_64-darwin-21
69
70
  x86_64-linux
70
71
 
71
72
  DEPENDENCIES
72
- activesupport (< 7)
73
+ activesupport
73
74
  factory_bot
74
75
  japanese_address_parser!
75
76
  rake
data/README.md CHANGED
@@ -111,6 +111,14 @@ address.furigana #=> "トウキョウトミナトクシバコウエン 4"
111
111
  bin/setup
112
112
  ```
113
113
 
114
+ 開発環境の構築は Docker を使ってもできます。
115
+ MacOS でしか試していないので、他プラットフォームで動かなかったら issue でご報告ください。
116
+
117
+ ```
118
+ docker compose build
119
+ docker compose run --rm gemsrc sh
120
+ ```
121
+
114
122
  自動テストやリンターを実行するには、このコマンドを実行してください:
115
123
 
116
124
  ```
@@ -0,0 +1,6 @@
1
+ version: "3"
2
+ services:
3
+ gemsrc:
4
+ build: .
5
+ volumes:
6
+ - .:/gemsrc
@@ -12,7 +12,7 @@ require_relative 'lib/japanese_address_parser/version'
12
12
  spec.description = 'JapaneseAddressParser is a Ruby gem that parses Japanese address. To detect the address, it uses geolonia/japanese-addresses (https://github.com/geolonia/japanese-addresses) CSV data.'
13
13
  spec.homepage = 'https://github.com/yamat47/japanese_address_parser'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = '>= 2.6.0'
15
+ spec.required_ruby_version = '>= 2.7.0'
16
16
 
17
17
  spec.metadata['homepage_uri'] = spec.homepage
18
18
  spec.metadata['source_code_uri'] = 'https://github.com/yamat47/japanese_address_parser'
@@ -31,7 +31,7 @@ require_relative 'lib/japanese_address_parser/version'
31
31
  spec.require_paths = ['lib']
32
32
 
33
33
  spec.add_dependency('schmooze')
34
- spec.add_development_dependency('activesupport', '< 7')
34
+ spec.add_development_dependency('activesupport')
35
35
  spec.add_development_dependency('factory_bot')
36
36
  spec.add_development_dependency('rake')
37
37
  spec.add_development_dependency('rspec')
@@ -4,16 +4,16 @@
4
4
  "requires": true,
5
5
  "packages": {
6
6
  "node_modules/@geolonia/japanese-numeral": {
7
- "version": "0.1.15",
8
- "resolved": "https://registry.npmjs.org/@geolonia/japanese-numeral/-/japanese-numeral-0.1.15.tgz",
9
- "integrity": "sha512-g8xizIJH7sfd5JSJyN6pCbNNWVkasMpw84gpYQZJ09VDuTT5qzT5cKhr3+pFyS4SpfwQ9rrsJBmeD6z3vI2bjA=="
7
+ "version": "0.1.16",
8
+ "resolved": "https://registry.npmjs.org/@geolonia/japanese-numeral/-/japanese-numeral-0.1.16.tgz",
9
+ "integrity": "sha512-xzSsIHhyyjqNpW8qSh5bFMu3FJvyJGBbNZ/t8clPHkigjUdZ7Ck8wkzCkcwlVd00RkoHwGDLnvXx5W0WiGK0TQ=="
10
10
  },
11
11
  "node_modules/@geolonia/normalize-japanese-addresses": {
12
- "version": "2.5.1",
13
- "resolved": "https://registry.npmjs.org/@geolonia/normalize-japanese-addresses/-/normalize-japanese-addresses-2.5.1.tgz",
14
- "integrity": "sha512-aIAkkyNnK7AVtP7ArTxNtx11pNpuQF3xiQ60PVG0N0MkpZom5qQ2JpgthHFdxh5ZEQA/ol5yFqPNdopKRIXytA==",
12
+ "version": "2.5.8",
13
+ "resolved": "https://registry.npmjs.org/@geolonia/normalize-japanese-addresses/-/normalize-japanese-addresses-2.5.8.tgz",
14
+ "integrity": "sha512-mv3+vHU2qXPjn2wbZH2p8kOKp7zTdcwCAWz8yryyyM5OGCRjHiqGBg+1t78Ut8b0wopyLJ7GjNanIoflEEKVeg==",
15
15
  "dependencies": {
16
- "@geolonia/japanese-numeral": "^0.1.15",
16
+ "@geolonia/japanese-numeral": "^0.1.16",
17
17
  "isomorphic-unfetch": "^3.1.0",
18
18
  "lru-cache": "^6.0.0"
19
19
  }
@@ -52,7 +52,7 @@ function number2kanji(num) {
52
52
  }
53
53
  exports.number2kanji = number2kanji;
54
54
  function findKanjiNumbers(text) {
55
- const num = '([0-90-9]*)|([〇一二三四五六七八九壱壹弐貳貮参參肆伍陸漆捌玖]*)';
55
+ const num = '([0-90-9]*)|([〇一二三四五六七八九壱壹弐弍貳貮参參肆伍陸漆捌玖]*)';
56
56
  const basePattern = `((${num})(千|阡|仟))?((${num})(百|陌|佰))?((${num})(十|拾))?(${num})?`;
57
57
  const pattern = `((${basePattern}兆)?(${basePattern}億)?(${basePattern}(万|萬))?${basePattern})`;
58
58
  const regex = new RegExp(pattern, 'g');
@@ -5,6 +5,7 @@ const oldJapaneseNumerics = {
5
5
  壱: '一',
6
6
  壹: '一',
7
7
  弐: '二',
8
+ 弍: '二',
8
9
  貳: '二',
9
10
  貮: '二',
10
11
  参: '三',
@@ -72,7 +72,11 @@ function kan2n(japanese) {
72
72
  number = number + Number(kanji);
73
73
  }
74
74
  else {
75
- number = number + japaneseNumerics_1.default[kanji];
75
+ for (let index = 0; index < kanji.length; index++) {
76
+ const char = kanji[index];
77
+ const digit = kanji.length - index - 1;
78
+ number = number + japaneseNumerics_1.default[char] * (10 ** digit);
79
+ }
76
80
  }
77
81
  }
78
82
  return number;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geolonia/japanese-numeral",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "Converts Japanese Kanji numeral to number.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -59,7 +59,7 @@ export function number2kanji(num: number) {
59
59
  }
60
60
 
61
61
  export function findKanjiNumbers(text: string) {
62
- const num = '([0-90-9]*)|([〇一二三四五六七八九壱壹弐貳貮参參肆伍陸漆捌玖]*)'
62
+ const num = '([0-90-9]*)|([〇一二三四五六七八九壱壹弐弍貳貮参參肆伍陸漆捌玖]*)'
63
63
  const basePattern = `((${num})(千|阡|仟))?((${num})(百|陌|佰))?((${num})(十|拾))?(${num})?`
64
64
  const pattern = `((${basePattern}兆)?(${basePattern}億)?(${basePattern}(万|萬))?${basePattern})`
65
65
  const regex = new RegExp(pattern, 'g')
@@ -7,6 +7,7 @@ const oldJapaneseNumerics: oldJapaneseNumericsType = {
7
7
  壱: '一',
8
8
  壹: '一',
9
9
  弐: '二',
10
+ 弍: '二',
10
11
  貳: '二',
11
12
  貮: '二',
12
13
  参: '三',
@@ -77,7 +77,12 @@ export function kan2n(japanese: string) {
77
77
  if (kanji.match(/^[0-9]+$/)) {
78
78
  number = number + Number(kanji)
79
79
  } else {
80
- number = number + japaneseNumerics[kanji]
80
+ for (let index = 0; index < kanji.length; index++) {
81
+ const char = kanji[index];
82
+ const digit = kanji.length - index - 1
83
+ number = number + japaneseNumerics[char] * (10 ** digit)
84
+
85
+ }
81
86
  }
82
87
  }
83
88
 
@@ -13,7 +13,11 @@ describe('Tests for japaneseNumeral.', () => {
13
13
  assert.deepEqual(kanji2number('二〇二〇'), 2020)
14
14
  assert.deepEqual(kanji2number('二千'), 2000)
15
15
  assert.deepEqual(kanji2number('壱万'), 10000)
16
+ assert.deepEqual(kanji2number('弍万'), 20000)
16
17
  assert.deepEqual(kanji2number('一二三四'), 1234)
18
+ assert.deepEqual(kanji2number('千二三四'), 1234)
19
+ assert.deepEqual(kanji2number('千二百三四'), 1234)
20
+ assert.deepEqual(kanji2number('千二百三十四'), 1234)
17
21
  assert.deepEqual(kanji2number('壱阡陌拾壱兆壱阡陌拾壱億壱阡陌拾壱萬壱阡陌拾壱'), 1111111111111111)
18
22
  assert.deepEqual(kanji2number('壱仟佰拾壱兆壱仟佰拾壱億壱仟佰拾壱萬壱仟佰拾壱'), 1111111111111111)
19
23
  });
@@ -62,6 +66,7 @@ describe('Tests for japaneseNumeral.', () => {
62
66
 
63
67
  it('should find old Japanese Kanji numbers.', () => {
64
68
  assert.deepEqual([ '壱', '弐' ], findKanjiNumbers('私が住んでいるのは壱番館の弐号室です。'))
69
+ assert.deepEqual([ '弍' ], findKanjiNumbers('私は、ハイツ弍号棟に住んでいます。'))
65
70
  assert.deepEqual([ '壱阡陌拾壱兆壱億壱萬', ], findKanjiNumbers('私は、壱阡陌拾壱兆壱億壱萬円持っています。'))
66
71
  assert.deepEqual([ '壱仟佰拾壱兆壱億壱萬', ], findKanjiNumbers('私は、壱仟佰拾壱兆壱億壱萬円持っています。'))
67
72
  })
@@ -1,6 +1,6 @@
1
1
  # @geolonia/normalize-japanese-addresses
2
2
 
3
- ![build](https://github.com/geolonia/normalize-japanese-addresses/workflows/build/badge.svg)
3
+ [![build](https://github.com/geolonia/normalize-japanese-addresses/actions/workflows/build.yml/badge.svg)](https://github.com/geolonia/normalize-japanese-addresses/actions/workflows/build.yml)
4
4
 
5
5
  オープンソースの住所正規化ライブラリです。
6
6
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  https://codepen.io/geolonia/pen/oNBrqzL
12
12
 
13
- ## 使い方
13
+ ## インストール
14
14
 
15
15
  ライブラリは npm レジストリで `@geolonia/normalize-japanese-addresses` として配布されています。
16
16
  npm コマンドなどを使ってインストールして下さい。
@@ -19,7 +19,9 @@ npm コマンドなどを使ってインストールして下さい。
19
19
  $ npm install @geolonia/normalize-japanese-addresses -S
20
20
  ```
21
21
 
22
- ### `normalize(address: string)`
22
+ ## 使い方
23
+
24
+ ### `normalize(address: string, option: Option)`
23
25
 
24
26
  住所を正規化します。
25
27
 
@@ -37,20 +39,22 @@ normalize('北海道札幌市西区24-2-2-3-3').then(result => {
37
39
  * `2` - 市区町村まで判別できた。
38
40
  * `3` - 町丁目まで判別できた。
39
41
 
40
- 例えば都道府県名のみを正規化したい場合、`level` オプションで指定することで処理を早くすることができます。
42
+ 例えば都道府県名のみを正規化したい場合、`level` オプションで指定することで処理を速くすることができます。
41
43
 
42
44
  ```javascript
43
45
  const { normalize } = require('@geolonia/normalize-japanese-addresses')
44
- normalize('北海道札幌市西区24-2-2-3-3', {level}).then(result => {
46
+ normalize('北海道札幌市西区24-2-2-3-3', { level: 1 }).then(result => {
45
47
  console.log(result); // {"pref": "北海道", "city": "", "town": "", "addr": "札幌市西区二十四軒二条二丁目3-3", "lat": null, "lng": null, "level"; 1}
46
48
  })
47
49
  ```
48
50
 
49
- ### オプション
51
+ ### グローバルオプション
52
+
53
+ 以下のパラメーターを変更することでライブラリの動作全体に関わる設定が変更できます。
50
54
 
51
55
  #### `config.townCacheSize: number`
52
56
 
53
- @geolonia/normalize-japanese-addresses は市区町村毎の最新の町丁目のデータを web API から取得し住所の正規化を行います。 `townCacheSize` オプションはキャッシュする市区町村の数を変更します。デフォルトは 1,000 件になっています。
57
+ @geolonia/normalize-japanese-addresses は市区町村毎の最新の町丁目のデータを web API から取得し住所の正規化を行います。`townCacheSize` オプションはキャッシュする市区町村の数を変更します。デフォルトは 1,000 件になっています。
54
58
 
55
59
  #### `config.japaneseAddressesApi: string`
56
60
 
@@ -58,9 +62,11 @@ normalize('北海道札幌市西区24-2-2-3-3', {level}).then(result => {
58
62
 
59
63
  このオプションに対して `file://` 形式の URL を指定することで、ローカルファイルとして保存したファイルを参照することができます。
60
64
 
65
+ ##### 使用例
66
+
61
67
  ```shell
62
68
  # Geolonia 住所データのダウンロード
63
- $ curl -sL https://github.com/geolonia/japanese-addresses/archive/refs/heads/master.tar.gz | tar xvf -
69
+ $ curl -sL https://github.com/geolonia/japanese-addresses/archive/refs/heads/master.tar.gz | tar xvfz -
64
70
  ```
65
71
 
66
72
  ```javascript
@@ -108,12 +114,13 @@ $ npm install
108
114
  $ npm run build
109
115
  ```
110
116
 
111
- dist フォルダ以下に main.js など必要なファイルが生成されるので、
117
+ dist フォルダ以下に main-node.js など必要なファイルが生成されるので、
112
118
 
113
- ```
114
- const { normalize } = require('./dist/main-node.js')
115
- normalize('北海道札幌市西区24-2-2-3-3', {level: 3}).then(result => {
116
- console.log(result); // {"pref": "北海道", "city": "", "town": "", "addr": "札幌市西区二十四軒二条二丁目3-3", "level"; 1}
119
+ ```javascript
120
+ // sample.js
121
+ const { normalize } = require('./dist/main-node.js');
122
+ normalize('北海道札幌市西区24-2-2-3-3', { level: 3 }).then(result => {
123
+ console.log(result); // { "pref": "北海道", "city": "", "town": "", "addr": "札幌市西区二十四軒二条二丁目3-3", "level": 1 }
117
124
  })
118
125
  ```
119
126
 
@@ -134,7 +141,7 @@ $ node sample.js
134
141
 
135
142
  ### 貢献方法
136
143
 
137
- プルリクエストや Issue はいつでも歓迎します。
144
+ [プルリクエスト](https://github.com/geolonia/normalize-japanese-addresses/pulls) や [Issue](https://github.com/geolonia/normalize-japanese-addresses/issues) はいつでも歓迎します。
138
145
 
139
146
  ## ライセンス、利用規約
140
147
 
@@ -1,6 +1,2 @@
1
- export interface Config {
2
- japaneseAddressesApi: string;
3
- /** 町丁目のデータを何件までキャッシュするか。デフォルト 1,000 */
4
- townCacheSize: number;
5
- }
1
+ import { Config } from './normalize';
6
2
  export declare const currentConfig: Config;
@@ -3,6 +3,7 @@ declare type PrefectureList = {
3
3
  };
4
4
  interface SingleTown {
5
5
  town: string;
6
+ originalTown?: string;
6
7
  koaza: string;
7
8
  lat: string;
8
9
  lng: string;
@@ -1,3 +1,3 @@
1
1
  import * as Normalize from './normalize';
2
- export declare const config: import("./config").Config;
2
+ export declare const config: Normalize.Config;
3
3
  export declare const normalize: Normalize.Normalizer;