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.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +15 -0
- data/Dockerfile +15 -0
- data/Gemfile.lock +25 -24
- data/README.md +8 -0
- data/docker-compose.yml +6 -0
- data/japanese_address_parser.gemspec +2 -2
- data/js/node_modules/.package-lock.json +7 -7
- data/js/node_modules/@geolonia/japanese-numeral/dist/index.js +1 -1
- data/js/node_modules/@geolonia/japanese-numeral/dist/oldJapaneseNumerics.js +1 -0
- data/js/node_modules/@geolonia/japanese-numeral/dist/utils.js +5 -1
- data/js/node_modules/@geolonia/japanese-numeral/package.json +1 -1
- data/js/node_modules/@geolonia/japanese-numeral/src/index.ts +1 -1
- data/js/node_modules/@geolonia/japanese-numeral/src/oldJapaneseNumerics.ts +1 -0
- data/js/node_modules/@geolonia/japanese-numeral/src/utils.ts +6 -1
- data/js/node_modules/@geolonia/japanese-numeral/test/test.ts +5 -0
- data/js/node_modules/@geolonia/normalize-japanese-addresses/README.md +21 -14
- data/js/node_modules/@geolonia/normalize-japanese-addresses/dist/config.d.ts +1 -5
- data/js/node_modules/@geolonia/normalize-japanese-addresses/dist/lib/cacheRegexes.d.ts +1 -0
- data/js/node_modules/@geolonia/normalize-japanese-addresses/dist/main-browser.d.ts +1 -1
- data/js/node_modules/@geolonia/normalize-japanese-addresses/dist/main-browser.js +94 -36
- data/js/node_modules/@geolonia/normalize-japanese-addresses/dist/main-node.d.ts +1 -1
- data/js/node_modules/@geolonia/normalize-japanese-addresses/dist/main-node.js +88 -35
- data/js/node_modules/@geolonia/normalize-japanese-addresses/dist/normalize.d.ts +13 -0
- data/js/node_modules/@geolonia/normalize-japanese-addresses/package.json +4 -4
- data/js/node_modules/@geolonia/normalize-japanese-addresses/src/config.ts +1 -6
- data/js/node_modules/@geolonia/normalize-japanese-addresses/src/lib/cacheRegexes.ts +45 -9
- data/js/node_modules/@geolonia/normalize-japanese-addresses/src/lib/dict.ts +2 -2
- data/js/node_modules/@geolonia/normalize-japanese-addresses/src/main-browser.ts +1 -2
- data/js/node_modules/@geolonia/normalize-japanese-addresses/src/main-node.ts +2 -3
- data/js/node_modules/@geolonia/normalize-japanese-addresses/src/normalize.ts +43 -15
- data/js/package-lock.json +14 -14
- data/lib/japanese_address_parser/data/01-01204.csv +1 -1
- data/lib/japanese_address_parser/data/01-01206.csv +2 -2
- data/lib/japanese_address_parser/data/01-01210.csv +1 -1
- data/lib/japanese_address_parser/data/01-01224.csv +1 -1
- data/lib/japanese_address_parser/data/01-01230.csv +1 -1
- data/lib/japanese_address_parser/data/01-01303.csv +1 -1
- data/lib/japanese_address_parser/data/01-01407.csv +3 -3
- data/lib/japanese_address_parser/data/01-01610.csv +1 -1
- data/lib/japanese_address_parser/data/01-01632.csv +1 -1
- data/lib/japanese_address_parser/data/01-01637.csv +1 -1
- data/lib/japanese_address_parser/data/01-01646.csv +1 -1
- data/lib/japanese_address_parser/data/01-01691.csv +1 -1
- data/lib/japanese_address_parser/data/03-03202.csv +1 -1
- data/lib/japanese_address_parser/data/03-03205.csv +29 -29
- data/lib/japanese_address_parser/data/03-03209.csv +56 -56
- data/lib/japanese_address_parser/data/03-03213.csv +1 -1
- data/lib/japanese_address_parser/data/03-03302.csv +1 -1
- data/lib/japanese_address_parser/data/03-03366.csv +1 -1
- data/lib/japanese_address_parser/data/03-03483.csv +1 -1
- data/lib/japanese_address_parser/data/03-03524.csv +1 -1
- data/lib/japanese_address_parser/data/04-04101.csv +6 -6
- data/lib/japanese_address_parser/data/04-04206.csv +32 -32
- data/lib/japanese_address_parser/data/04-04207.csv +41 -41
- data/lib/japanese_address_parser/data/06-06203.csv +1 -1
- data/lib/japanese_address_parser/data/07-07207.csv +1 -1
- data/lib/japanese_address_parser/data/07-07301.csv +2 -2
- data/lib/japanese_address_parser/data/11-11201.csv +3 -3
- data/lib/japanese_address_parser/data/12-12211.csv +1 -1
- data/lib/japanese_address_parser/data/12-12215.csv +2 -2
- data/lib/japanese_address_parser/data/13-13103.csv +2 -2
- data/lib/japanese_address_parser/data/13-13104.csv +3 -3
- data/lib/japanese_address_parser/data/13-13116.csv +5 -5
- data/lib/japanese_address_parser/data/14-14402.csv +2 -2
- data/lib/japanese_address_parser/data/15-15210.csv +5 -5
- data/lib/japanese_address_parser/data/15-15222.csv +4 -4
- data/lib/japanese_address_parser/data/15-15226.csv +1 -1
- data/lib/japanese_address_parser/data/16-16207.csv +1 -1
- data/lib/japanese_address_parser/data/16-16323.csv +2 -2
- data/lib/japanese_address_parser/data/17-17201.csv +26 -26
- data/lib/japanese_address_parser/data/17-17202.csv +1 -1
- data/lib/japanese_address_parser/data/17-17206.csv +29 -29
- data/lib/japanese_address_parser/data/19-19209.csv +1 -1
- data/lib/japanese_address_parser/data/19-19213.csv +2 -2
- data/lib/japanese_address_parser/data/20-20210.csv +1 -1
- data/lib/japanese_address_parser/data/20-20385.csv +14 -0
- data/lib/japanese_address_parser/data/20.csv +1 -13
- data/lib/japanese_address_parser/data/22-22135.csv +1 -1
- data/lib/japanese_address_parser/data/22-22209.csv +1 -1
- data/lib/japanese_address_parser/data/22-22210.csv +1 -1
- data/lib/japanese_address_parser/data/22-22211.csv +1 -1
- data/lib/japanese_address_parser/data/22-22325.csv +2 -2
- data/lib/japanese_address_parser/data/22-22341.csv +1 -1
- data/lib/japanese_address_parser/data/23-23105.csv +5 -5
- data/lib/japanese_address_parser/data/24-24205.csv +1 -1
- data/lib/japanese_address_parser/data/25-25202.csv +1 -1
- data/lib/japanese_address_parser/data/26-26102.csv +14 -14
- data/lib/japanese_address_parser/data/26-26103.csv +1 -1
- data/lib/japanese_address_parser/data/26-26104.csv +9 -9
- data/lib/japanese_address_parser/data/26-26105.csv +4 -4
- data/lib/japanese_address_parser/data/26-26106.csv +15 -15
- data/lib/japanese_address_parser/data/26-26107.csv +1 -1
- data/lib/japanese_address_parser/data/27-27145.csv +1 -1
- data/lib/japanese_address_parser/data/27-27202.csv +1 -1
- data/lib/japanese_address_parser/data/27-27208.csv +2 -2
- data/lib/japanese_address_parser/data/27-27211.csv +1 -1
- data/lib/japanese_address_parser/data/27-27227.csv +2 -2
- data/lib/japanese_address_parser/data/28-28109.csv +41 -41
- data/lib/japanese_address_parser/data/28-28201.csv +1 -1
- data/lib/japanese_address_parser/data/28-28204.csv +1 -1
- data/lib/japanese_address_parser/data/28-28208.csv +7 -7
- data/lib/japanese_address_parser/data/28-28217.csv +3 -3
- data/lib/japanese_address_parser/data/28-28226.csv +1 -1
- data/lib/japanese_address_parser/data/29-29201.csv +50 -50
- data/lib/japanese_address_parser/data/29-29203.csv +1 -1
- data/lib/japanese_address_parser/data/30-30304.csv +3 -3
- data/lib/japanese_address_parser/data/34-34210.csv +2 -2
- data/lib/japanese_address_parser/data/35-35201.csv +1 -1
- data/lib/japanese_address_parser/data/35-35213.csv +2 -2
- data/lib/japanese_address_parser/data/36-36201.csv +15 -15
- data/lib/japanese_address_parser/data/36-36202.csv +14 -14
- data/lib/japanese_address_parser/data/36-36207.csv +3 -3
- data/lib/japanese_address_parser/data/36-36208.csv +1 -1
- data/lib/japanese_address_parser/data/36-36468.csv +23 -23
- data/lib/japanese_address_parser/data/38-38202.csv +1 -1
- data/lib/japanese_address_parser/data/38-38203.csv +1 -1
- data/lib/japanese_address_parser/data/38-38210.csv +1 -1
- data/lib/japanese_address_parser/data/38-38422.csv +2 -2
- data/lib/japanese_address_parser/data/39-39206.csv +1 -1
- data/lib/japanese_address_parser/data/39-39210.csv +1 -1
- data/lib/japanese_address_parser/data/39-39212.csv +3 -3
- data/lib/japanese_address_parser/data/39-39386.csv +2 -2
- data/lib/japanese_address_parser/data/39-39412.csv +1 -1
- data/lib/japanese_address_parser/data/40-40131.csv +7 -7
- data/lib/japanese_address_parser/data/41-41201.csv +1 -1
- data/lib/japanese_address_parser/data/42-42214.csv +1 -1
- data/lib/japanese_address_parser/data/43-43101.csv +2 -2
- data/lib/japanese_address_parser/data/43-43204.csv +1 -1
- data/lib/japanese_address_parser/data/43-43205.csv +2 -2
- data/lib/japanese_address_parser/data/43-43215.csv +3 -3
- data/lib/japanese_address_parser/data/44-44204.csv +1 -1
- data/lib/japanese_address_parser/data/45-45201.csv +2 -2
- data/lib/japanese_address_parser/data/45-45202.csv +1 -1
- data/lib/japanese_address_parser/data/45-45203.csv +2 -2
- data/lib/japanese_address_parser/data/46-46201.csv +2 -2
- data/lib/japanese_address_parser/data/46-46210.csv +1 -1
- data/lib/japanese_address_parser/data/46-46215.csv +1 -1
- data/lib/japanese_address_parser/data/46-46216.csv +1 -1
- data/lib/japanese_address_parser/data/46-46217.csv +4 -4
- data/lib/japanese_address_parser/data/46-46218.csv +3 -3
- data/lib/japanese_address_parser/data/46-46221.csv +1 -1
- data/lib/japanese_address_parser/models/prefecture.rb +2 -13
- data/lib/japanese_address_parser/version.rb +1 -1
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72363aa74cf45e200716ce789f6755ea43b23b556d913a76cd4479e88c44e571
|
4
|
+
data.tar.gz: 844e5565b51f6cb3d630b244d77c6197cbbc35e6f57015d807ef546173e03f59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 (
|
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 (
|
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.
|
16
|
+
concurrent-ruby (1.1.10)
|
18
17
|
diff-lcs (1.5.0)
|
19
|
-
factory_bot (6.2.
|
18
|
+
factory_bot (6.2.1)
|
20
19
|
activesupport (>= 5.0.0)
|
21
|
-
i18n (1.
|
20
|
+
i18n (1.12.0)
|
22
21
|
concurrent-ruby (~> 1.0)
|
23
|
-
|
24
|
-
|
25
|
-
|
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.
|
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.
|
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.
|
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.
|
44
|
-
rubocop (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.
|
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.
|
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.
|
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.
|
58
|
-
rubocop (~> 1.
|
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.
|
62
|
+
tzinfo (2.0.5)
|
62
63
|
concurrent-ruby (~> 1.0)
|
63
|
-
unicode-display_width (2.
|
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
|
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
|
```
|
data/docker-compose.yml
ADDED
@@ -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.
|
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'
|
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.
|
8
|
-
"resolved": "https://registry.npmjs.org/@geolonia/japanese-numeral/-/japanese-numeral-0.1.
|
9
|
-
"integrity": "sha512-
|
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.
|
13
|
-
"resolved": "https://registry.npmjs.org/@geolonia/normalize-japanese-addresses/-/normalize-japanese-addresses-2.5.
|
14
|
-
"integrity": "sha512-
|
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.
|
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');
|
@@ -72,7 +72,11 @@ function kan2n(japanese) {
|
|
72
72
|
number = number + Number(kanji);
|
73
73
|
}
|
74
74
|
else {
|
75
|
-
|
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;
|
@@ -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')
|
@@ -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
|
-
|
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
|
-
|
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
|
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
|
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
|
-
|
115
|
-
normalize('
|
116
|
-
|
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
|
-
|
144
|
+
[プルリクエスト](https://github.com/geolonia/normalize-japanese-addresses/pulls) や [Issue](https://github.com/geolonia/normalize-japanese-addresses/issues) はいつでも歓迎します。
|
138
145
|
|
139
146
|
## ライセンス、利用規約
|
140
147
|
|