namae 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/namae/parser.y CHANGED
@@ -24,32 +24,24 @@ rule
24
24
 
25
25
  display_order : u_words word opt_suffices opt_titles
26
26
  {
27
- result = Name.new(:given => val[0], :family => val[1],
28
- :suffix => val[2], :title => val[3])
27
+ result = Name.new(
28
+ :given => val[0], :family => val[1], :suffix => val[2], :title => val[3]
29
+ )
29
30
  }
30
31
  | u_words NICK last opt_suffices opt_titles
31
32
  {
32
- result = Name.new(:given => val[0], :nick => val[1],
33
- :family => val[2], :suffix => val[3], :title => val[4])
33
+ result = Name.new(
34
+ :given => val[0], :nick => val[1], :family => val[2], :suffix => val[3], :title => val[4]
35
+ )
34
36
  }
35
37
  | u_words NICK von last opt_suffices opt_titles
36
38
  {
37
- result = Name.new(:given => val[0], :nick => val[1],
38
- :particle => val[2], :family => val[3],
39
- :suffix => val[4], :title => val[5])
39
+ result = Name.new(
40
+ :given => val[0], :nick => val[1], :particle => val[2], :family => val[3], :suffix => val[4], :title => val[5])
40
41
  }
41
42
  | u_words von last
42
43
  {
43
- result = Name.new(:given => val[0], :particle => val[1],
44
- :family => val[2])
45
- }
46
- | u_words UPARTICLE last
47
- {
48
- result = if include_particle_in_family?
49
- Name.new(:given => val[0], :family => val[1,2].join(' '))
50
- else
51
- Name.new(:given => val[0], :particle => val[1], :family => val[2])
52
- end
44
+ result = Name.new(:given => val[0], :particle => val[1], :family => val[2])
53
45
  }
54
46
  | von last
55
47
  {
@@ -58,32 +50,29 @@ rule
58
50
 
59
51
  sort_order : last COMMA first
60
52
  {
61
- result = Name.new({ :family => val[0], :suffix => val[2][0],
62
- :given => val[2][1] }, !!val[2][0])
63
- }
64
- | UPARTICLE last COMMA first
65
- {
66
- result = if include_particle_in_family?
67
- Name.new({ :family => val[0,2].join(' '), :suffix => val[3][0], :given => val[3][1] }, !!val[3][0])
68
- else
69
- Name.new({ :particle => val[0], :family => val[1], :suffix => val[3][0], :given => val[3][1] }, !!val[3][0])
70
- end
53
+ result = Name.new({
54
+ :family => val[0], :suffix => val[2][0], :given => val[2][1]
55
+ }, !!val[2][0])
71
56
  }
72
57
  | von last COMMA first
73
58
  {
74
- result = Name.new({ :particle => val[0], :family => val[1],
75
- :suffix => val[3][0], :given => val[3][1] }, !!val[3][0])
59
+ result = Name.new({
60
+ :particle => val[0], :family => val[1], :suffix => val[3][0], :given => val[3][1]
61
+ }, !!val[3][0])
76
62
  }
77
63
  | u_words von last COMMA first
78
64
  {
79
- result = Name.new({ :particle => val[0,2].join(' '), :family => val[2],
80
- :suffix => val[4][0], :given => val[4][1] }, !!val[4][0])
65
+ result = Name.new({
66
+ :particle => val[0,2].join(' '), :family => val[2], :suffix => val[4][0], :given => val[4][1]
67
+ }, !!val[4][0])
81
68
  }
82
69
  ;
83
70
 
84
- von : LWORD
85
- | von LWORD { result = val.join(' ') }
86
- | von u_words LWORD { result = val.join(' ') }
71
+ von : particle
72
+ | von particle { result = val.join(' ') }
73
+ | von u_words particle { result = val.join(' ') }
74
+
75
+ particle : LWORD | UPARTICLE
87
76
 
88
77
  last : LWORD | u_words
89
78
 
@@ -103,7 +92,7 @@ rule
103
92
  opt_comma : /* empty */ | COMMA
104
93
  opt_words : /* empty */ | words
105
94
 
106
- word : LWORD | UWORD | PWORD
95
+ word : LWORD | UWORD | PWORD | UPARTICLE
107
96
 
108
97
  opt_suffices : /* empty */ | suffices
109
98
 
@@ -130,7 +119,7 @@ require 'strscan'
130
119
  :title => /\s*\b(sir|lord|count(ess)?|(gen|adm|col|maj|capt|cmdr|lt|sgt|cpl|pvt|pastor|pr|reverend|rev|elder|deacon|deaconess|father|fr|rabbi|cantor|vicar|prof|dr|md|ph\.?d)\.?)(\s+|$)/i,
131
120
  :suffix => /\s*\b(JR|Jr|jr|SR|Sr|sr|[IVX]{2,})(\.|\b)/,
132
121
  :appellation => /\s*\b((mrs?|ms|fr|hr)\.?|miss|herr|frau)(\s+|$)/i,
133
- :uppercase_particle => /\s*\b((Da|De|Di|De\sLa|Du|Der|Des|Da|St|Saint|Les|Van)\.?)(\s+|$)/
122
+ :uppercase_particle => /\s*\b(D[aiu]|De[rs]?|St\.?|Saint|La|Les|V[ao]n)(\s+|$)/
134
123
  }
135
124
 
136
125
  class << self
@@ -197,7 +186,9 @@ require 'strscan'
197
186
  def parse!(string)
198
187
  @input = StringScanner.new(normalize(string))
199
188
  reset
200
- do_parse
189
+ names = do_parse
190
+ names.map(&:merge_particles!) if include_particle_in_family?
191
+ names
201
192
  end
202
193
 
203
194
  def normalize(string)
data/lib/namae/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Namae
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 1
4
+ MINOR = 2
5
5
  PATCH = 0
6
6
  BUILD = nil
7
7
 
data/lib/namae.rb CHANGED
@@ -2,4 +2,4 @@ require 'namae/version'
2
2
 
3
3
  require 'namae/name'
4
4
  require 'namae/parser'
5
- require 'namae/utility'
5
+ require 'namae/utility'
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: namae
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
- - Dan Collis-Puro
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2021-03-12 00:00:00.000000000 Z
11
+ date: 2024-01-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: racc
@@ -17,64 +16,49 @@ dependencies:
17
16
  requirements:
18
17
  - - "~>"
19
18
  - !ruby/object:Gem::Version
20
- version: '1.4'
21
- type: :development
19
+ version: '1.7'
20
+ type: :runtime
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
24
  - - "~>"
26
25
  - !ruby/object:Gem::Version
27
- version: '1.4'
26
+ version: '1.7'
28
27
  description: " Namae (名前) is a parser for human names. It recognizes personal names
29
28
  of various cultural backgrounds and tries to split them into their component parts
30
29
  (e.g., given and family names, honorifics etc.). "
31
30
  email:
32
31
  - sylvester@keil.or.at
33
- - dan@collispuro.com
34
32
  executables: []
35
33
  extensions: []
36
34
  extra_rdoc_files:
37
35
  - README.md
36
+ - AGPL
38
37
  files:
39
- - ".codeclimate.yml"
40
- - ".coveralls.yml"
41
- - ".document"
42
- - ".rspec"
43
- - ".rubocop.yml"
44
- - ".simplecov"
45
- - ".travis.yml"
46
- - ".yardopts"
47
38
  - AGPL
48
39
  - BSDL
49
- - Gemfile
50
40
  - README.md
51
- - Rakefile
52
- - cucumber.yml
53
- - features/bibtex.feature
54
- - features/examples.feature
55
- - features/lists.feature
56
- - features/step_definitions/namae_steps.rb
57
- - features/suffix.feature
58
- - features/support/env.rb
59
- - features/title.feature
60
41
  - lib/namae.rb
61
42
  - lib/namae/name.rb
62
43
  - lib/namae/parser.rb
63
44
  - lib/namae/parser.y
64
45
  - lib/namae/utility.rb
65
46
  - lib/namae/version.rb
66
- - namae.gemspec
67
- - spec/namae/name_spec.rb
68
- - spec/namae/parser_spec.rb
69
- - spec/namae/utility_spec.rb
70
- - spec/spec_helper.rb
71
- - spec/thread_safety_spec.rb
72
47
  homepage: https://github.com/berkmancenter/namae
73
48
  licenses:
74
49
  - AGPL-3.0
50
+ - BSD-2-Clause
75
51
  metadata: {}
76
52
  post_install_message:
77
- rdoc_options: []
53
+ rdoc_options:
54
+ - "--line-numbers"
55
+ - "--inline-source"
56
+ - "--title"
57
+ - "'Namae'"
58
+ - "--main"
59
+ - README.md
60
+ - "--exclude"
61
+ - lib/namae/parser.rb
78
62
  require_paths:
79
63
  - lib
80
64
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -88,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
72
  - !ruby/object:Gem::Version
89
73
  version: '0'
90
74
  requirements: []
91
- rubygems_version: 3.2.3
75
+ rubygems_version: 3.5.3
92
76
  signing_key:
93
77
  specification_version: 4
94
78
  summary: Namae (名前) parses personal names and splits them into their component parts.
data/.codeclimate.yml DELETED
@@ -1,16 +0,0 @@
1
- ---
2
- endinges:
3
- duplication:
4
- enabled: true
5
- config:
6
- languages:
7
- - ruby
8
- fixme:
9
- enabled: true
10
- rubocop:
11
- enabled: true
12
- ratings:
13
- paths:
14
- - '**.rb'
15
- exclude_paths:
16
- - lib/namae/parser.rb
data/.coveralls.yml DELETED
@@ -1 +0,0 @@
1
- service_name: travis-ci
data/.document DELETED
@@ -1,7 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- AGPL
6
- BSDL
7
- README.md
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --require ./spec/spec_helper.rb
2
- --color