Repository navigation
Expand file tree
/
Copy pathtest.js
More file actions
executable file
·277 lines (275 loc) · 8.5 KB
/
Copy pathtest.js
File metadata and controls
executable file
·277 lines (275 loc) · 8.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
const japa = require('../');
const assert = require('assert').strict;
describe('Parsing', function () {
const tests = [
{
text: '東京都調布市入間町2-29番21号',
result: {
prefecture: '東京都',
city: '調布市',
town: '入間町',
chome: 2,
ban: 29,
go: 21,
left: ''
}
},
{
text: '東京都調布市入間町三丁目1番地7',
result: {
prefecture: '東京都',
city: '調布市',
town: '入間町',
chome: 3,
ban: 1,
go: 7,
left: ''
}
},
{
text: '東京都調布市入間町十 三丁目二十八番七〇',
result: {
prefecture: '東京都',
city: '調布市',
town: '入間町',
chome: 13,
ban: 28,
go: 70,
left: ''
}
},
{
text: '東京都杉並区成田東1 丁目',
result: {
prefecture: '東京都',
city: '杉並区',
town: '成田東',
chome: 1,
ban: undefined,
go: undefined,
left: ''
}
},
{
text: '東京都板橋区小茂根5678 丁目',
result: {
prefecture: '東京都',
city: '板橋区',
town: '小茂根',
chome: 5678,
ban: undefined,
go: undefined,
left: ''
}
},
{
text: '東京都板橋区徳丸4丁目',
result: {
prefecture: '東京都',
city: '板橋区',
town: '徳丸',
chome: 4,
ban: undefined,
go: undefined,
left: ''
}
},
{
text: '東京都調布市深大寺東町4',
result: {
prefecture: '東京都',
city: '調布市',
town: '深大寺東町',
chome: 4,
ban: undefined,
go: undefined,
left: ''
}
},
{
text: '栃木県芳賀郡芳賀町芳賀台52-1',
result: {
prefecture: '栃木県',
city: '芳賀郡芳賀町',
town: '芳賀台',
chome: 52,
ban: 1,
go: undefined,
left: ''
}
},
{
text: '栃木県塩谷郡高根沢町上高根沢2900',
result: {
prefecture: '栃木県',
city: '塩谷郡高根沢町',
town: '上高根沢',
chome: 2900,
ban: undefined,
go: undefined,
left: ''
}
},
{
text: '東京都西東京市芝久保町3-2022-14他(要相談)',
result: {
prefecture: '東京都',
city: '西東京市',
town: '芝久保町',
chome: 3,
ban: 2022,
go: 14,
left: '他(要相談)'
}
},
{
text: '東京都板橋区大谷口北町',
result: {
prefecture: '東京都',
city: '板橋区',
town: '大谷口北町',
chome: undefined,
ban: undefined,
go: undefined,
left: ''
}
},
{
text: '板橋区大谷口北町',
result: {
prefecture: '東京都',
city: '板橋区',
town: '大谷口北町',
chome: undefined,
ban: undefined,
go: undefined,
left: ''
},
options: {
prefecture: '東京都'
}
},
{
text: '板橋区',
result: {
prefecture: '東京都',
city: '板橋区',
town: undefined,
chome: undefined,
ban: undefined,
go: undefined,
left: ''
},
options: {
prefecture: '東京都'
}
},
{
text: '大阪府',
result: {
prefecture: '大阪府',
city: undefined,
town: undefined,
chome: undefined,
ban: undefined,
go: undefined,
left: ''
},
options: {
prefecture: '東京都'
}
},
{
text: '東京都北区東十条6丁目',
result: {
prefecture: '東京都',
city: '北区',
town: '東十条',
chome: 6,
ban: undefined,
go: undefined,
left: ''
}
},
{
text: '東京北区東十条6丁目',
result: {
prefecture: '東京都',
city: '北区',
town: '東十条',
chome: 6,
ban: undefined,
go: undefined,
left: ''
}
},
{
text: '東京北区東十条6丁目二 十八番七〇',
result: {
prefecture: '東京都',
city: '北区',
town: '東十条',
chome: 6,
ban: 28,
go: 70,
left: ''
}
},
];
tests.forEach((t) => it(t.text + (t.options ? ` ${JSON.stringify(t.options)}`: ''), async function () {
const result = await japa.parse(t.text, t.options);
assert.deepEqual(result, t.result);
}));
});
describe('Normalization', function () {
const tests = [
{
text: '東京北区東十条6丁目',
result: '東京都北区東十条六丁目'
},
{
text: '東京都調布市入間町2丁目-29番21号',
result: '東京都調布市入間町二丁目29番21号'
},
{
text: '東京都調布市入間町十 三丁目二十八番七〇',
result: '東京都調布市入間町十三丁目28番70号'
},
{
text: '東京都調布市入間町十 三丁目二十八番七〇',
result: '東京都調布市入間町13-28-70',
options: { number_scheme: 'numeric' }
},
{
text: '京都府京都市東山区本町22-489-1',
result: '京都府京都市東山区本町二十二丁目489番1号'
},
{
text: '東京都北区西ケ原4丁目',
result: '東京都北区西ケ原四丁目'
},
{
text: '東京都 北区 西ヶ 原4丁目',
result: '東京都北区西ケ原四丁目'
},
{
text: '京都府京都市東山区本町22-489-1',
result: '京都府京都市東山区本町22丁目489−1',
options: { number_scheme: 'chome_full_width' }
},
{
text: '東京都千代田区東神田3-1-9',
result: '東京都千代田区東神田3丁目1-9',
options: { number_scheme: 'chome_numeric' }
},
{
text: '東京都国分寺市高木町1丁目6番32',
result: '東京都国分寺市高木町1丁目6番32',
options: { number_scheme: 'chome_ban_numeric' }
}
];
tests.forEach((t) => it(t.text + (t.options ? ` ${JSON.stringify(t.options)}`: ''), async function () {
const result = await japa.normalize(t.text, t.options);
assert.strictEqual(result, t.result);
}));
});