namae 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fd611e09da3c6d134065dbe46162518556ce531
4
- data.tar.gz: b91fd641df6a06e2b2da4bd8bcad70baa753a612
3
+ metadata.gz: 9c35acb2595cb60e9256141f209a97ebe717c5fd
4
+ data.tar.gz: ce3c39facdf1b12051b56edb8330376f777eb2d8
5
5
  SHA512:
6
- metadata.gz: aa0a37702affcb7a5aa8c54961303cec1b7bfc45856bd364949a67251a66a5cde33365d0489cfe303d62beb5dd7a88c018b493b719d4d67793f8391f965a5cc5
7
- data.tar.gz: 745d03394228e6420f1f95383ac62d76c9d46a4b2a101e42af6d8406e13edef0c17d3fae7740633c77504d745395427e3a996c4399e939e9bb4acf2d6afdd17f
6
+ metadata.gz: e3e158d44f41686c75eadb19b9a4ef984db05b57d7e2be63aa4db7b8c62bb119216ddbd6a7a1c2bc28d6068f6a7df7a7cbb2cb8f176903b43e54e2af07df21f5
7
+ data.tar.gz: e440237a7f090dc85cbb1e68f1388831147823794b305fcc0e6ae131fe4cb26692d841ca0f9a2facf3bcf65f5ab6ac79fe0ec492a2adeb9e8cb6eac427435eb8
data/Gemfile CHANGED
@@ -8,10 +8,10 @@ end
8
8
 
9
9
 
10
10
  group :development do
11
- gem 'simplecov', '~>0.8', :require => false, :platforms => [:ruby_19, :ruby_20, :ruby_21]
11
+ gem 'simplecov', '~>0.8', :require => false, :platforms => :ruby
12
12
  gem 'rubinius-coverage', '~>2.0', :platform => :rbx
13
13
  gem 'coveralls', '~>0.7', :require => false
14
- gem 'racc', '1.4.9', :platform => [:ruby]
14
+ gem 'racc', '1.4.9', :platform => :ruby
15
15
  end
16
16
 
17
17
  group :optional do
@@ -21,7 +21,8 @@ group :optional do
21
21
  end
22
22
 
23
23
  group :debug do
24
- gem 'debugger', '~>1.6', :platform => [:mri_20, :mri_21, :mri_19]
24
+ gem 'debugger', '~>1.6', :platform => [:mri_20, :mri_19]
25
+ gem 'byebug', '~>3.5', :platform => [:mri_21, :mri_22]
25
26
  gem 'rubinius-compiler', '~>2.0', :platform => :rbx
26
27
  gem 'rubinius-debugger', '~>2.0', :platform => :rbx
27
28
  end
@@ -25,3 +25,10 @@ Feature: Parse the names in the Readme file
25
25
  Scenarios: Readme examples (sort-order)
26
26
  | name | given | particle | family | suffix | title | appellation | nick |
27
27
  | Carreño Quiñones, María-Jose | María-Jose | | Carreño Quiñones | | | | |
28
+
29
+ @issues @appellation @nick @suffix
30
+ Scenarios: Nicknames Appellations and Suffices
31
+ | name | given | particle | family | suffix | title | appellation | nick |
32
+ | Mr. Yukihiro "Matz" Matsumoto | Yukihiro | | Matsumoto | | | Mr. | Matz |
33
+ | Yukihiro "Matz" Matsumoto Sr. | Yukihiro | | Matsumoto | Sr. | | | Matz |
34
+ | Mr. Yukihiro "Matz" Matsumoto Sr. | Yukihiro | | Matsumoto | Sr. | | Mr. | Matz |
@@ -15,8 +15,11 @@ rescue LoadError
15
15
  end unless RUBY_VERSION < '1.9'
16
16
 
17
17
  begin
18
- if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
18
+ case
19
+ when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
19
20
  require 'rubinius/debugger'
21
+ when RUBY_VERSION > '2.0'
22
+ require 'byebug'
20
23
  else
21
24
  require 'debugger'
22
25
  end
@@ -0,0 +1,17 @@
1
+ Feature: Parse names with a title
2
+ As a hacker who works with Namae
3
+ I want to be able to parse names with a title
4
+
5
+ Scenario Outline: Names with titles
6
+
7
+ When I parse the name "<name>"
8
+ Then the parts should be:
9
+ | given | particle | family | suffix | title | appellation | nick |
10
+ | <given> | <particle> | <family> | <suffix> | <title> | <appellation> | <nick> |
11
+
12
+ @names @title
13
+ Scenarios: Names with titles
14
+ | name | given | particle | family | suffix | title |
15
+ # | Bernado Franecki, PhD | Bernado | | Franecki | | PhD |
16
+ # | Dr. John Smith, Ph.D. | John | | Smith | | Dr. Ph.D. |
17
+
data/lib/namae/parser.rb CHANGED
@@ -12,7 +12,7 @@ require 'strscan'
12
12
  module Namae
13
13
  class Parser < Racc::Parser
14
14
 
15
- module_eval(<<'...end parser.y/module_eval...', 'parser.y', 99)
15
+ module_eval(<<'...end parser.y/module_eval...', 'parser.y', 107)
16
16
 
17
17
  include Singleton
18
18
 
@@ -180,72 +180,78 @@ module_eval(<<'...end parser.y/module_eval...', 'parser.y', 99)
180
180
  ##### State transition tables begin ###
181
181
 
182
182
  racc_action_table = [
183
- -38, -40, -39, 14, 22, 15, 24, -38, -40, -39,
184
- -38, -40, -39, 62, 53, 52, 54, 63, 58, -22,
185
- -22, -34, -22, 56, 16, 56, -22, -22, 53, 52,
186
- 54, 17, 53, 52, 54, 39, 53, 52, 54, 39,
187
- -38, 39, -22, 39, 14, 12, 15, -38, 33, 7,
188
- 8, 14, 12, 15, 39, 32, 7, 8, 14, 22,
189
- 15, 24, 30, 46, 31, 30, 42, 31, 53, 52,
190
- 54, 30, 28, 31, 30, 28, 31, 30, 28, 31,
191
- 30, 28, 31, 30, 28, 31, 14, 22, 15, 30,
192
- 56, 31, 53, 52, 54, 45 ]
183
+ -39, 16, 32, 30, -40, 31, 33, -39, 17, -39,
184
+ -39, -40, 67, -40, -40, 66, 53, 52, 54, -38,
185
+ 59, -22, 39, -34, 45, 58, -38, 53, 52, 54,
186
+ 53, 52, 54, 59, 39, 39, 62, 39, 53, 52,
187
+ 54, 14, 12, 15, 68, 39, 7, 8, 14, 12,
188
+ 15, 58, 39, 7, 8, 14, 22, 15, 24, 14,
189
+ 22, 15, 24, 14, 22, 15, 30, 28, 31, 30,
190
+ 28, 31, -19, -19, -19, 30, 42, 31, 30, 28,
191
+ 31, -20, -20, -20, 30, 46, 31, 30, 28, 31,
192
+ 30, 28, 31, -19, -19, -19, 53, 52, 54, 53,
193
+ 52, 54, 39, 58, 59 ]
193
194
 
194
195
  racc_action_check = [
195
- 22, 15, 14, 9, 9, 9, 9, 22, 15, 14,
196
- 22, 15, 14, 49, 49, 49, 49, 50, 44, 42,
197
- 28, 49, 28, 38, 1, 50, 42, 28, 32, 32,
198
- 32, 1, 58, 58, 58, 32, 45, 45, 45, 58,
199
- 12, 23, 12, 45, 0, 0, 0, 12, 16, 0,
200
- 0, 17, 17, 17, 60, 11, 17, 17, 20, 20,
201
- 20, 20, 29, 29, 29, 24, 24, 24, 63, 63,
202
- 63, 25, 25, 25, 10, 10, 10, 35, 35, 35,
203
- 21, 21, 21, 41, 41, 41, 5, 5, 5, 43,
204
- 65, 43, 66, 66, 66, 27 ]
196
+ 14, 1, 11, 43, 15, 43, 16, 14, 1, 14,
197
+ 14, 15, 50, 15, 15, 49, 49, 49, 49, 12,
198
+ 50, 12, 23, 49, 27, 37, 12, 32, 32, 32,
199
+ 45, 45, 45, 38, 32, 40, 44, 45, 62, 62,
200
+ 62, 0, 0, 0, 57, 62, 0, 0, 17, 17,
201
+ 17, 60, 61, 17, 17, 9, 9, 9, 9, 20,
202
+ 20, 20, 20, 5, 5, 5, 10, 10, 10, 21,
203
+ 21, 21, 22, 22, 22, 24, 24, 24, 25, 25,
204
+ 25, 28, 28, 28, 29, 29, 29, 35, 35, 35,
205
+ 41, 41, 41, 42, 42, 42, 67, 67, 67, 73,
206
+ 73, 73, 64, 70, 72 ]
205
207
 
206
208
  racc_action_pointer = [
207
- 41, 24, nil, nil, nil, 83, nil, nil, nil, 0,
208
- 71, 53, 40, nil, 2, 1, 48, 48, nil, nil,
209
- 55, 77, 0, 31, 62, 68, nil, 93, 20, 59,
210
- nil, nil, 25, nil, nil, 74, nil, nil, 13, nil,
211
- nil, 80, 19, 86, 16, 33, nil, nil, nil, 11,
212
- 15, nil, nil, nil, nil, nil, nil, nil, 29, nil,
213
- 44, nil, nil, 65, nil, 80, 89 ]
209
+ 38, 1, nil, nil, nil, 60, nil, nil, nil, 52,
210
+ 63, 0, 19, nil, 0, 4, 6, 45, nil, nil,
211
+ 56, 66, 69, 12, 72, 75, nil, 22, 78, 81,
212
+ nil, nil, 24, nil, nil, 84, nil, 16, 23, nil,
213
+ 25, 87, 90, 0, 34, 27, nil, nil, nil, 13,
214
+ 10, nil, nil, nil, nil, nil, nil, 35, nil, nil,
215
+ 42, 42, 35, nil, 92, nil, nil, 93, nil, nil,
216
+ 94, nil, 94, 96, nil ]
214
217
 
215
218
  racc_action_default = [
216
- -1, -45, -2, -4, -5, -45, -8, -9, -10, -23,
217
- -45, -45, -19, -28, -30, -31, -45, -45, -6, -7,
218
- -45, -45, -19, -41, -45, -45, -29, -15, -20, -23,
219
- -30, -31, -36, 67, -3, -45, -15, -11, -42, -43,
220
- -12, -45, -19, -23, -14, -36, -21, -16, -24, -37,
221
- -26, -32, -38, -39, -40, -14, -44, -13, -36, -17,
222
- -45, -33, -35, -45, -18, -25, -27 ]
219
+ -1, -49, -2, -4, -5, -49, -8, -9, -10, -23,
220
+ -49, -49, -19, -28, -30, -31, -49, -49, -6, -7,
221
+ -49, -49, -38, -41, -49, -49, -29, -15, -22, -23,
222
+ -30, -31, -36, 75, -3, -49, -15, -45, -42, -43,
223
+ -41, -49, -22, -23, -14, -36, -21, -16, -24, -37,
224
+ -26, -32, -38, -39, -40, -14, -11, -46, -47, -44,
225
+ -45, -41, -36, -17, -49, -33, -35, -49, -48, -12,
226
+ -45, -18, -25, -27, -13 ]
223
227
 
224
228
  racc_goto_table = [
225
- 3, 38, 26, 66, 27, 18, 9, 2, 47, 23,
226
- 37, 20, 21, 26, 60, 36, 25, 3, 40, 44,
227
- 23, 59, 26, 9, 34, 19, 1, 35, nil, 55,
228
- 43, 41, nil, nil, 64, 57, 26, nil, 65, nil,
229
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 61,
229
+ 3, 37, 26, 50, 56, 18, 2, 9, 47, 23,
230
+ 1, 19, 20, 26, 73, 27, 50, 3, 60, 64,
231
+ 23, 63, 26, 34, 9, nil, 36, 69, 21, 40,
232
+ 44, 43, 25, 50, nil, 72, 26, 74, 71, 70,
233
+ 55, nil, nil, 35, nil, nil, 61, 41, nil, 65,
230
234
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
231
- nil, nil, nil, nil, nil, nil, 61 ]
235
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
236
+ nil, nil, nil, 65 ]
232
237
 
233
238
  racc_goto_check = [
234
- 3, 15, 16, 13, 9, 3, 7, 2, 11, 3,
235
- 8, 7, 10, 16, 14, 9, 10, 3, 9, 9,
236
- 3, 11, 16, 7, 2, 4, 1, 10, nil, 9,
237
- 7, 10, nil, nil, 11, 9, 16, nil, 15, nil,
238
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 3,
239
+ 3, 8, 17, 16, 9, 3, 2, 7, 12, 3,
240
+ 1, 4, 7, 17, 14, 10, 16, 3, 8, 15,
241
+ 3, 12, 17, 2, 7, nil, 10, 9, 11, 10,
242
+ 10, 7, 11, 16, nil, 16, 17, 9, 12, 8,
243
+ 10, nil, nil, 11, nil, nil, 10, 11, nil, 3,
244
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
239
245
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
240
- nil, nil, nil, nil, nil, nil, 3 ]
246
+ nil, nil, nil, 3 ]
241
247
 
242
248
  racc_goto_pointer = [
243
- nil, 26, 7, 0, 20, nil, nil, 6, -13, -6,
244
- 7, -24, nil, -60, -35, -22, -7 ]
249
+ nil, 10, 6, 0, 6, nil, nil, 7, -22, -33,
250
+ 5, 23, -24, nil, -53, -30, -29, -7, nil ]
245
251
 
246
252
  racc_goto_default = [
247
- nil, nil, nil, 51, 4, 5, 6, 29, nil, 11,
248
- 10, nil, 48, 49, nil, 50, 13 ]
253
+ nil, nil, nil, 51, 4, 5, 6, 29, nil, nil,
254
+ 11, 10, nil, 48, 49, nil, 38, 13, 57 ]
249
255
 
250
256
  racc_reduce_table = [
251
257
  0, 0, :racc_error,
@@ -259,44 +265,48 @@ racc_reduce_table = [
259
265
  1, 13, :_reduce_none,
260
266
  1, 16, :_reduce_9,
261
267
  1, 16, :_reduce_10,
262
- 3, 15, :_reduce_11,
263
- 3, 15, :_reduce_12,
264
- 4, 15, :_reduce_13,
268
+ 4, 15, :_reduce_11,
269
+ 5, 15, :_reduce_12,
270
+ 6, 15, :_reduce_13,
265
271
  3, 15, :_reduce_14,
266
272
  2, 15, :_reduce_15,
267
273
  3, 17, :_reduce_16,
268
274
  4, 17, :_reduce_17,
269
275
  5, 17, :_reduce_18,
276
+ 1, 22, :_reduce_none,
277
+ 2, 22, :_reduce_20,
278
+ 3, 22, :_reduce_21,
270
279
  1, 21, :_reduce_none,
271
- 2, 21, :_reduce_20,
272
- 3, 21, :_reduce_21,
273
- 1, 20, :_reduce_none,
274
- 1, 20, :_reduce_none,
275
- 1, 22, :_reduce_24,
276
- 3, 22, :_reduce_25,
277
- 1, 22, :_reduce_26,
278
- 3, 22, :_reduce_27,
280
+ 1, 21, :_reduce_none,
281
+ 1, 23, :_reduce_24,
282
+ 3, 23, :_reduce_25,
283
+ 1, 23, :_reduce_26,
284
+ 3, 23, :_reduce_27,
279
285
  1, 18, :_reduce_none,
280
286
  2, 18, :_reduce_29,
281
- 1, 27, :_reduce_none,
282
- 1, 27, :_reduce_none,
283
- 1, 24, :_reduce_none,
284
- 2, 24, :_reduce_33,
285
- 0, 25, :_reduce_none,
287
+ 1, 28, :_reduce_none,
288
+ 1, 28, :_reduce_none,
286
289
  1, 25, :_reduce_none,
287
- 0, 23, :_reduce_none,
288
- 1, 23, :_reduce_none,
290
+ 2, 25, :_reduce_33,
291
+ 0, 26, :_reduce_none,
292
+ 1, 26, :_reduce_none,
293
+ 0, 24, :_reduce_none,
294
+ 1, 24, :_reduce_none,
289
295
  1, 14, :_reduce_none,
290
296
  1, 14, :_reduce_none,
291
297
  1, 14, :_reduce_none,
292
298
  0, 19, :_reduce_none,
293
299
  1, 19, :_reduce_none,
294
- 1, 26, :_reduce_none,
295
- 2, 26, :_reduce_44 ]
300
+ 1, 27, :_reduce_none,
301
+ 2, 27, :_reduce_44,
302
+ 0, 20, :_reduce_none,
303
+ 1, 20, :_reduce_none,
304
+ 1, 29, :_reduce_none,
305
+ 2, 29, :_reduce_48 ]
296
306
 
297
- racc_reduce_n = 45
307
+ racc_reduce_n = 49
298
308
 
299
- racc_shift_n = 67
309
+ racc_shift_n = 75
300
310
 
301
311
  racc_token_table = {
302
312
  false => 0,
@@ -352,6 +362,7 @@ Racc_token_to_s_table = [
352
362
  "sort_order",
353
363
  "u_words",
354
364
  "opt_suffices",
365
+ "opt_titles",
355
366
  "last",
356
367
  "von",
357
368
  "first",
@@ -359,7 +370,8 @@ Racc_token_to_s_table = [
359
370
  "words",
360
371
  "opt_comma",
361
372
  "suffices",
362
- "u_word" ]
373
+ "u_word",
374
+ "titles" ]
363
375
 
364
376
  Racc_debug_parser = false
365
377
 
@@ -369,28 +381,28 @@ Racc_debug_parser = false
369
381
 
370
382
  module_eval(<<'.,.,', 'parser.y', 11)
371
383
  def _reduce_1(val, _values, result)
372
- result = []
384
+ result = []
373
385
  result
374
386
  end
375
387
  .,.,
376
388
 
377
389
  module_eval(<<'.,.,', 'parser.y', 12)
378
390
  def _reduce_2(val, _values, result)
379
- result = [val[0]]
391
+ result = [val[0]]
380
392
  result
381
393
  end
382
394
  .,.,
383
395
 
384
396
  module_eval(<<'.,.,', 'parser.y', 13)
385
397
  def _reduce_3(val, _values, result)
386
- result = val[0] << val[2]
398
+ result = val[0] << val[2]
387
399
  result
388
400
  end
389
401
  .,.,
390
402
 
391
403
  module_eval(<<'.,.,', 'parser.y', 15)
392
404
  def _reduce_4(val, _values, result)
393
- result = Name.new(:given => val[0])
405
+ result = Name.new(:given => val[0])
394
406
  result
395
407
  end
396
408
  .,.,
@@ -399,14 +411,14 @@ module_eval(<<'.,.,', 'parser.y', 15)
399
411
 
400
412
  module_eval(<<'.,.,', 'parser.y', 17)
401
413
  def _reduce_6(val, _values, result)
402
- result = val[0].merge(:family => val[1])
414
+ result = val[0].merge(:family => val[1])
403
415
  result
404
416
  end
405
417
  .,.,
406
418
 
407
419
  module_eval(<<'.,.,', 'parser.y', 18)
408
420
  def _reduce_7(val, _values, result)
409
- result = val[1].merge(val[0])
421
+ result = val[1].merge(val[0])
410
422
  result
411
423
  end
412
424
  .,.,
@@ -415,99 +427,102 @@ module_eval(<<'.,.,', 'parser.y', 18)
415
427
 
416
428
  module_eval(<<'.,.,', 'parser.y', 21)
417
429
  def _reduce_9(val, _values, result)
418
- result = Name.new(:appellation => val[0])
430
+ result = Name.new(:appellation => val[0])
419
431
  result
420
432
  end
421
433
  .,.,
422
434
 
423
435
  module_eval(<<'.,.,', 'parser.y', 22)
424
436
  def _reduce_10(val, _values, result)
425
- result = Name.new(:title => val[0])
437
+ result = Name.new(:title => val[0])
426
438
  result
427
439
  end
428
440
  .,.,
429
441
 
430
442
  module_eval(<<'.,.,', 'parser.y', 26)
431
443
  def _reduce_11(val, _values, result)
432
- result = Name.new(:given => val[0], :family => val[1], :suffix => val[2])
433
-
444
+ result = Name.new(:given => val[0], :family => val[1],
445
+ :suffix => val[2], :title => val[3])
446
+
434
447
  result
435
448
  end
436
449
  .,.,
437
450
 
438
- module_eval(<<'.,.,', 'parser.y', 30)
451
+ module_eval(<<'.,.,', 'parser.y', 31)
439
452
  def _reduce_12(val, _values, result)
440
- result = Name.new(:given => val[0], :nick => val[1], :family => val[2])
441
-
453
+ result = Name.new(:given => val[0], :nick => val[1],
454
+ :family => val[2], :suffix => val[3], :title => val[4])
455
+
442
456
  result
443
457
  end
444
458
  .,.,
445
459
 
446
- module_eval(<<'.,.,', 'parser.y', 34)
460
+ module_eval(<<'.,.,', 'parser.y', 36)
447
461
  def _reduce_13(val, _values, result)
448
462
  result = Name.new(:given => val[0], :nick => val[1],
449
- :particle => val[2], :family => val[3])
450
-
463
+ :particle => val[2], :family => val[3],
464
+ :suffix => val[4], :title => val[5])
465
+
451
466
  result
452
467
  end
453
468
  .,.,
454
469
 
455
- module_eval(<<'.,.,', 'parser.y', 39)
470
+ module_eval(<<'.,.,', 'parser.y', 42)
456
471
  def _reduce_14(val, _values, result)
457
472
  result = Name.new(:given => val[0], :particle => val[1],
458
473
  :family => val[2])
459
-
474
+
460
475
  result
461
476
  end
462
477
  .,.,
463
478
 
464
- module_eval(<<'.,.,', 'parser.y', 44)
479
+ module_eval(<<'.,.,', 'parser.y', 47)
465
480
  def _reduce_15(val, _values, result)
466
481
  result = Name.new(:particle => val[0], :family => val[1])
467
-
482
+
468
483
  result
469
484
  end
470
485
  .,.,
471
486
 
472
- module_eval(<<'.,.,', 'parser.y', 49)
487
+ module_eval(<<'.,.,', 'parser.y', 52)
473
488
  def _reduce_16(val, _values, result)
474
489
  result = Name.new({ :family => val[0], :suffix => val[2][0],
475
490
  :given => val[2][1] }, !!val[2][0])
476
-
491
+
477
492
  result
478
493
  end
479
494
  .,.,
480
495
 
481
- module_eval(<<'.,.,', 'parser.y', 54)
496
+ module_eval(<<'.,.,', 'parser.y', 57)
482
497
  def _reduce_17(val, _values, result)
483
498
  result = Name.new({ :particle => val[0], :family => val[1],
484
499
  :suffix => val[3][0], :given => val[3][1] }, !!val[3][0])
485
-
500
+
486
501
  result
487
502
  end
488
503
  .,.,
489
504
 
490
- module_eval(<<'.,.,', 'parser.y', 59)
505
+ module_eval(<<'.,.,', 'parser.y', 62)
491
506
  def _reduce_18(val, _values, result)
492
507
  result = Name.new({ :particle => val[0,2].join(' '), :family => val[2],
493
508
  :suffix => val[4][0], :given => val[4][1] }, !!val[4][0])
494
-
509
+
495
510
  result
496
511
  end
497
512
  .,.,
498
513
 
499
514
  # reduce 19 omitted
500
515
 
501
- module_eval(<<'.,.,', 'parser.y', 65)
516
+ module_eval(<<'.,.,', 'parser.y', 68)
502
517
  def _reduce_20(val, _values, result)
503
- result = val.join(' ')
518
+ result = val.join(' ')
504
519
  result
505
520
  end
506
521
  .,.,
507
522
 
508
- module_eval(<<'.,.,', 'parser.y', 66)
523
+ module_eval(<<'.,.,', 'parser.y', 69)
509
524
  def _reduce_21(val, _values, result)
510
- result = val.join(' ')
525
+ result = val.join(' ')
511
526
  result
512
527
  end
513
528
  .,.,
@@ -516,39 +531,39 @@ module_eval(<<'.,.,', 'parser.y', 66)
516
531
 
517
532
  # reduce 23 omitted
518
533
 
519
- module_eval(<<'.,.,', 'parser.y', 70)
534
+ module_eval(<<'.,.,', 'parser.y', 73)
520
535
  def _reduce_24(val, _values, result)
521
- result = [nil,val[0]]
536
+ result = [nil,val[0]]
522
537
  result
523
538
  end
524
539
  .,.,
525
540
 
526
- module_eval(<<'.,.,', 'parser.y', 71)
541
+ module_eval(<<'.,.,', 'parser.y', 74)
527
542
  def _reduce_25(val, _values, result)
528
- result = [val[2],val[0]]
543
+ result = [val[2],val[0]]
529
544
  result
530
545
  end
531
546
  .,.,
532
547
 
533
- module_eval(<<'.,.,', 'parser.y', 72)
548
+ module_eval(<<'.,.,', 'parser.y', 75)
534
549
  def _reduce_26(val, _values, result)
535
- result = [val[0],nil]
550
+ result = [val[0],nil]
536
551
  result
537
552
  end
538
553
  .,.,
539
554
 
540
- module_eval(<<'.,.,', 'parser.y', 73)
555
+ module_eval(<<'.,.,', 'parser.y', 76)
541
556
  def _reduce_27(val, _values, result)
542
- result = [val[0],val[2]]
557
+ result = [val[0],val[2]]
543
558
  result
544
559
  end
545
560
  .,.,
546
561
 
547
562
  # reduce 28 omitted
548
563
 
549
- module_eval(<<'.,.,', 'parser.y', 76)
564
+ module_eval(<<'.,.,', 'parser.y', 79)
550
565
  def _reduce_29(val, _values, result)
551
- result = val.join(' ')
566
+ result = val.join(' ')
552
567
  result
553
568
  end
554
569
  .,.,
@@ -559,9 +574,9 @@ module_eval(<<'.,.,', 'parser.y', 76)
559
574
 
560
575
  # reduce 32 omitted
561
576
 
562
- module_eval(<<'.,.,', 'parser.y', 81)
577
+ module_eval(<<'.,.,', 'parser.y', 84)
563
578
  def _reduce_33(val, _values, result)
564
- result = val.join(' ')
579
+ result = val.join(' ')
565
580
  result
566
581
  end
567
582
  .,.,
@@ -586,9 +601,22 @@ module_eval(<<'.,.,', 'parser.y', 81)
586
601
 
587
602
  # reduce 43 omitted
588
603
 
589
- module_eval(<<'.,.,', 'parser.y', 91)
604
+ module_eval(<<'.,.,', 'parser.y', 94)
590
605
  def _reduce_44(val, _values, result)
591
- result = val.join(' ')
606
+ result = val.join(' ')
607
+ result
608
+ end
609
+ .,.,
610
+
611
+ # reduce 45 omitted
612
+
613
+ # reduce 46 omitted
614
+
615
+ # reduce 47 omitted
616
+
617
+ module_eval(<<'.,.,', 'parser.y', 99)
618
+ def _reduce_48(val, _values, result)
619
+ result = val.join(' ')
592
620
  result
593
621
  end
594
622
  .,.,
data/lib/namae/parser.y CHANGED
@@ -22,18 +22,21 @@ rule
22
22
  honorific : APPELLATION { result = Name.new(:appellation => val[0]) }
23
23
  | TITLE { result = Name.new(:title => val[0]) }
24
24
 
25
- display_order : u_words word opt_suffices
25
+ display_order : u_words word opt_suffices opt_titles
26
26
  {
27
- result = Name.new(:given => val[0], :family => val[1], :suffix => val[2])
27
+ result = Name.new(:given => val[0], :family => val[1],
28
+ :suffix => val[2], :title => val[3])
28
29
  }
29
- | u_words NICK last
30
+ | u_words NICK last opt_suffices opt_titles
30
31
  {
31
- result = Name.new(:given => val[0], :nick => val[1], :family => val[2])
32
+ result = Name.new(:given => val[0], :nick => val[1],
33
+ :family => val[2], :suffix => val[3], :title => val[4])
32
34
  }
33
- | u_words NICK von last
35
+ | u_words NICK von last opt_suffices opt_titles
34
36
  {
35
37
  result = Name.new(:given => val[0], :nick => val[1],
36
- :particle => val[2], :family => val[3])
38
+ :particle => val[2], :family => val[3],
39
+ :suffix => val[4], :title => val[5])
37
40
  }
38
41
  | u_words von last
39
42
  {
@@ -91,6 +94,11 @@ rule
91
94
  suffices : SUFFIX
92
95
  | suffices SUFFIX { result = val.join(' ') }
93
96
 
97
+ opt_titles : /* empty */ | titles
98
+
99
+ titles : TITLE
100
+ | titles TITLE { result = val.join(' ') }
101
+
94
102
  ---- header
95
103
  require 'singleton'
96
104
  require 'strscan'
data/lib/namae/version.rb CHANGED
@@ -2,7 +2,7 @@ module Namae
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 9
5
- PATCH = 2
5
+ PATCH = 3
6
6
  BUILD = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.').freeze
data/namae.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: namae 0.9.2 ruby lib
5
+ # stub: namae 0.9.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "namae"
9
- s.version = "0.9.2"
9
+ s.version = "0.9.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Sylvester Keil", "Dan Collis-Puro"]
14
- s.date = "2014-07-09"
14
+ s.date = "2015-01-19"
15
15
  s.description = " Namae (\u{540d}\u{524d}) is a parser for human names. It recognizes personal names of various cultural backgrounds and tries to split them into their component parts (e.g., given and family names, honorifics etc.). "
16
16
  s.email = ["sylvester@keil.or.at", "dan@collispuro.com"]
17
17
  s.extra_rdoc_files = [
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
37
37
  "features/step_definitions/namae_steps.rb",
38
38
  "features/suffix.feature",
39
39
  "features/support/env.rb",
40
+ "features/title.feature",
40
41
  "lib/namae.rb",
41
42
  "lib/namae/name.rb",
42
43
  "lib/namae/parser.rb",
@@ -51,7 +52,7 @@ Gem::Specification.new do |s|
51
52
  ]
52
53
  s.homepage = "https://github.com/berkmancenter/namae"
53
54
  s.licenses = ["AGPL"]
54
- s.rubygems_version = "2.2.2"
55
+ s.rubygems_version = "2.4.5"
55
56
  s.summary = "Namae (\u{540d}\u{524d}) parses personal names and splits them into their component parts."
56
57
 
57
58
  if s.respond_to? :specification_version then
@@ -73,6 +73,18 @@ module Namae
73
73
  end
74
74
  end
75
75
 
76
+ %w{Ph.D. PhD PHD Dr. Dr Prof.}.each do |title|
77
+ describe "the next token is #{title.inspect}" do
78
+ before { parser.send(:input).string = title }
79
+ it 'returns a TITLE token' do
80
+ expect(parser.send(:next_token)).to eq([:TITLE, title])
81
+ end
82
+
83
+ it 'the input matches the suffix pattern' do
84
+ expect(parser.title).to match(title)
85
+ end
86
+ end
87
+ end
76
88
  end
77
89
 
78
90
  describe '#parse!' do
@@ -106,6 +118,14 @@ module Namae
106
118
  expect(parser.parse!('Yukihiro "Matz" Matsumoto')[0].values_at(:given, :family, :nick)).to eq(%w{Yukihiro Matsumoto Matz})
107
119
  end
108
120
 
121
+ it 'parses appellation and nick in \'Mr. Yukihiro "Matz" Matsumoto\'' do
122
+ expect(parser.parse!('Mr. Yukihiro "Matz" Matsumoto')[0].values_at(:appellation, :nick)).to eq(%w{Mr. Matz})
123
+ end
124
+
125
+ it 'parses suffix and nick in \'Yukihiro "Matz" Matsumoto Jr.\'' do
126
+ expect(parser.parse!('Yukihiro "Matz" Matsumoto Jr.')[0].values_at(:suffix, :nick)).to eq(%w{Jr. Matz})
127
+ end
128
+
109
129
  it 'parses given and family name in "Poe, Edgar A."' do
110
130
  expect(parser.parse!('Poe, Edgar A.')[0].values_at(:given, :family)).to eq(['Edgar A.', 'Poe'])
111
131
  end
@@ -125,6 +145,10 @@ module Namae
125
145
  expect(parser.parse!('Ken Griffey Jr.')[0].values_at(:given, :family, :suffix)).to eq(['Ken', 'Griffey', 'Jr.'])
126
146
  end
127
147
 
148
+ it 'parses Ph.D. title suffix in display order' do
149
+ expect(parser.parse!('Bernado Franecki Ph.D.')[0].values_at(:given, :family, :title)).to eq(['Bernado', 'Franecki', 'Ph.D.'])
150
+ #expect(parser.parse!('Bernado Franecki, Ph.D.')[0].values_at(:given, :family, :title)).to eq(['Bernado', 'Franecki', 'Ph.D.'])
151
+ end
128
152
  end
129
153
  end
130
154
 
data/spec/spec_helper.rb CHANGED
@@ -6,8 +6,11 @@ rescue LoadError
6
6
  end unless RUBY_VERSION < '1.9'
7
7
 
8
8
  begin
9
- if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
9
+ case
10
+ when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
10
11
  require 'rubinius/debugger'
12
+ when RUBY_VERSION > '2.0'
13
+ require 'byebug'
11
14
  else
12
15
  require 'debugger'
13
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: namae
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
@@ -9,48 +9,48 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-09 00:00:00.000000000 Z
12
+ date: 2015-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: simplecov
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0.8'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0.8'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rubinius-coverage
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '2.0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ~>
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '2.0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: coveralls
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0.7'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0.7'
56
56
  - !ruby/object:Gem::Dependency
@@ -67,9 +67,9 @@ dependencies:
67
67
  - - '='
68
68
  - !ruby/object:Gem::Version
69
69
  version: 1.4.9
70
- description: ' Namae (名前) is a parser for human names. It recognizes personal names
70
+ description: " Namae (名前) is a parser for human names. It recognizes personal names
71
71
  of various cultural backgrounds and tries to split them into their component parts
72
- (e.g., given and family names, honorifics etc.). '
72
+ (e.g., given and family names, honorifics etc.). "
73
73
  email:
74
74
  - sylvester@keil.or.at
75
75
  - dan@collispuro.com
@@ -78,13 +78,13 @@ extensions: []
78
78
  extra_rdoc_files:
79
79
  - README.md
80
80
  files:
81
- - .autotest
82
- - .coveralls.yml
83
- - .document
84
- - .rspec
85
- - .simplecov
86
- - .travis.yml
87
- - .yardopts
81
+ - ".autotest"
82
+ - ".coveralls.yml"
83
+ - ".document"
84
+ - ".rspec"
85
+ - ".simplecov"
86
+ - ".travis.yml"
87
+ - ".yardopts"
88
88
  - AGPL
89
89
  - BSDL
90
90
  - Gemfile
@@ -97,6 +97,7 @@ files:
97
97
  - features/step_definitions/namae_steps.rb
98
98
  - features/suffix.feature
99
99
  - features/support/env.rb
100
+ - features/title.feature
100
101
  - lib/namae.rb
101
102
  - lib/namae/name.rb
102
103
  - lib/namae/parser.rb
@@ -118,17 +119,17 @@ require_paths:
118
119
  - lib
119
120
  required_ruby_version: !ruby/object:Gem::Requirement
120
121
  requirements:
121
- - - '>='
122
+ - - ">="
122
123
  - !ruby/object:Gem::Version
123
124
  version: '0'
124
125
  required_rubygems_version: !ruby/object:Gem::Requirement
125
126
  requirements:
126
- - - '>='
127
+ - - ">="
127
128
  - !ruby/object:Gem::Version
128
129
  version: '0'
129
130
  requirements: []
130
131
  rubyforge_project:
131
- rubygems_version: 2.2.2
132
+ rubygems_version: 2.4.5
132
133
  signing_key:
133
134
  specification_version: 4
134
135
  summary: Namae (名前) parses personal names and splits them into their component parts.