gender_detector 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gender_detector.rb +17 -15
- data/lib/gender_detector/version.rb +1 -1
- metadata +15 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c5163b78567fcc01065054f923931d101f83015
|
4
|
+
data.tar.gz: 28bd20c35b5946ac08c33c413a462e4dfd70e86e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 613a60d4e62eac81e1e2465e103798ea853f5ba4f490161cf79502390d2f13dff7ac6eb06f4adcebff3cbb9d007c9bdba8850561dd6a603fe95d4ba70b3b37de
|
7
|
+
data.tar.gz: 4a4418adabcffdb57f8f09d3f10112747e40c0546a0ca542fcefb5f9b755f1f56e5c11fd4f5ee0260301013a0d9a8da6c2e81a58611d06634491f46eb0740df5
|
data/lib/gender_detector.rb
CHANGED
@@ -1,17 +1,21 @@
|
|
1
1
|
require 'gender_detector/version'
|
2
2
|
|
3
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.4.0')
|
4
|
+
require 'active_support/core_ext/string/multibyte'
|
5
|
+
end
|
6
|
+
|
3
7
|
# Main class for interacting with the data file
|
4
8
|
class GenderDetector
|
5
|
-
COUNTRIES = [
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
COUNTRIES = %i[great_britain ireland usa italy malta portugal
|
10
|
+
spain france belgium luxembourg the_netherlands
|
11
|
+
east_frisia germany austria swiss iceland denmark
|
12
|
+
norway sweden finland estonia latvia lithuania
|
13
|
+
poland czech_republic slovakia hungary romania
|
14
|
+
bulgaria bosniaand croatia kosovo macedonia
|
15
|
+
montenegro serbia slovenia albania greece russia
|
16
|
+
belarus moldova ukraine armenia azerbaijan georgia
|
17
|
+
the_stans turkey arabia israel china india japan
|
18
|
+
korea vietnam other_countries].freeze
|
15
19
|
|
16
20
|
ISO_3166_MAPPING = {
|
17
21
|
'AE' => :arabia, 'AL' => :albania, 'AM' => :armenia, 'AT' => :austria,
|
@@ -70,7 +74,7 @@ class GenderDetector
|
|
70
74
|
@unknown_value
|
71
75
|
elsif country.nil?
|
72
76
|
most_popular_gender(name) do |country_values|
|
73
|
-
country_values.split('').
|
77
|
+
country_values.split('').reject { |l| l.strip == '' }.length
|
74
78
|
end
|
75
79
|
elsif COUNTRIES.include?(country)
|
76
80
|
most_popular_gender_in_country(name, country)
|
@@ -98,7 +102,7 @@ class GenderDetector
|
|
98
102
|
def eat_name_line(line)
|
99
103
|
return if line.start_with?('#', '=')
|
100
104
|
|
101
|
-
parts = line.split(' ').
|
105
|
+
parts = line.split(' ').reject { |p| p.strip == '' }
|
102
106
|
country_values = line.slice(30, line.length)
|
103
107
|
name = @case_sensitive ? parts[1] : downcase(parts[1])
|
104
108
|
|
@@ -139,9 +143,7 @@ class GenderDetector
|
|
139
143
|
end
|
140
144
|
|
141
145
|
def downcase(name)
|
142
|
-
if defined?(
|
143
|
-
UnicodeUtils.downcase(name)
|
144
|
-
elsif defined?(ActiveSupport::Multibyte::Chars)
|
146
|
+
if defined?(ActiveSupport::Multibyte::Chars)
|
145
147
|
name.mb_chars.downcase.to_s
|
146
148
|
else
|
147
149
|
name.downcase
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gender_detector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Muller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,84 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.50'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.50'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '5.
|
33
|
+
version: '5.10'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '5.
|
40
|
+
version: '5.10'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '12.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '12.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.5'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.5'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: unicode_utils
|
56
|
+
name: activesupport
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1
|
61
|
+
version: '5.1'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1
|
68
|
+
version: '5.1'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
70
|
+
name: minitest-stub-const
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
75
|
+
version: '0.6'
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
82
|
+
version: '0.6'
|
97
83
|
description: Guess gender from first name, with multilingual support.
|
98
84
|
email:
|
99
85
|
- bamuller@gmail.com
|
@@ -125,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
111
|
version: '0'
|
126
112
|
requirements: []
|
127
113
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.6.13
|
129
115
|
signing_key:
|
130
116
|
specification_version: 4
|
131
117
|
summary: Get gender from first name.
|