namegender 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +28 -0
- data/lib/namegender.rb +24 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 697eadb66c1e662a33a859ad917c8a094db92477df1687d5120ff4c6894dd466
|
|
4
|
+
data.tar.gz: fb5eb0a69ef1e910892b847be2dbd253b9e2b3bf596192aadcdbfc46bd21fcf0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f8b59ef517681af8a964f29430b8ae253f70afbffa58bc4a261c029c51655a351488b9698a898c9253bf32e4d54c4ccaea01b5bcadcb7cab730561a06e914e53
|
|
7
|
+
data.tar.gz: 566b094d3df1e8647a72571543c358798427442352fe579954f279b603426c3204d0be0341c4a5b4b903c835439eb7d00ac70ffc9bf2350ec283e4554a3213ed
|
data/README.md
CHANGED
|
@@ -113,6 +113,34 @@ judged by their shape only. It takes `country:`, `locale:` and `ip:`, not
|
|
|
113
113
|
`best_guess` or `ai_fallback`. `name_check_bulk` takes up to 100 names and
|
|
114
114
|
returns `results` in input order.
|
|
115
115
|
|
|
116
|
+
## Age from name
|
|
117
|
+
|
|
118
|
+
The estimated age of the people who carry a first name, from birth records.
|
|
119
|
+
It describes a group, not a person: never use it for decisions about an
|
|
120
|
+
individual.
|
|
121
|
+
|
|
122
|
+
```ruby
|
|
123
|
+
result = client.age("Brittany")
|
|
124
|
+
puts result["age"] # 36 (median)
|
|
125
|
+
puts result["age_range"] # {"low"=>32, "high"=>38}, the middle half
|
|
126
|
+
puts result["age_range_80"] # {"low"=>28, "high"=>41}, the middle 80%
|
|
127
|
+
puts result["birth_year"] # 1990
|
|
128
|
+
|
|
129
|
+
client.age("Brittany", gender: "female", country: "US")
|
|
130
|
+
|
|
131
|
+
result = client.age_bulk(["Brittany", "Margaret"])
|
|
132
|
+
result["results"].each { |r| puts "#{r["name"]} #{r["age"]}" }
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
It covers the US, France and Norway; with no country hint US data is used and
|
|
136
|
+
`country_source` is `"default"`. For other countries `age` is `nil` and
|
|
137
|
+
`reason` is `"country_not_covered"`, with no credit charged; `reason` can also
|
|
138
|
+
be `"not_found"` or `"insufficient_data"`. These are normal answers, not
|
|
139
|
+
errors. `gender:` (`"male"` or `"female"`) narrows the estimate to that
|
|
140
|
+
gender's records. It takes `country:`, `locale:` and `ip:`, not `best_guess`
|
|
141
|
+
or `ai_fallback`. One credit per name; `age_bulk` takes up to 100 names and
|
|
142
|
+
returns `results` in input order. Age responses carry no `data_version`.
|
|
143
|
+
|
|
116
144
|
## File jobs
|
|
117
145
|
|
|
118
146
|
Upload a CSV or XLSX file (up to 100 MB and 1,000,000 rows) and get it back
|
data/lib/namegender.rb
CHANGED
|
@@ -101,6 +101,26 @@ module NameGender
|
|
|
101
101
|
def name_check_bulk(values, country: nil, locale: nil, ip: nil)
|
|
102
102
|
post("/name-check/bulk", { names: Array(values), country: country, locale: locale, ip: ip }.compact)
|
|
103
103
|
end
|
|
104
|
+
# Estimated age of the people who carry a first name, from birth records:
|
|
105
|
+
# "age" is the median, "age_range" the middle half and "age_range_80" the
|
|
106
|
+
# middle 80 percent ({"low", "high"}), "birth_year" the median birth year.
|
|
107
|
+
# It describes a group, not a person: never use it for decisions about an
|
|
108
|
+
# individual. Covers the US, France and Norway; with no country hint US
|
|
109
|
+
# data is used and "country_source" is "default". When "age" is nil,
|
|
110
|
+
# "reason" says why ("not_found", "insufficient_data" or
|
|
111
|
+
# "country_not_covered"); that is a normal answer, not an error, and
|
|
112
|
+
# "country_not_covered" costs no credit. `gender:` ("male" or "female")
|
|
113
|
+
# narrows to that gender's records; `country`, `locale` and `ip` work as
|
|
114
|
+
# in #name. Options that are nil or empty are not sent. One credit per
|
|
115
|
+
# name. Age responses carry no "data_version".
|
|
116
|
+
def age(value, gender: nil, country: nil, locale: nil, ip: nil)
|
|
117
|
+
post("/age", present(name: value, gender: gender, country: country, locale: locale, ip: ip))
|
|
118
|
+
end
|
|
119
|
+
# Up to 100 names; every option applies to all of them. "results" keeps
|
|
120
|
+
# the input order.
|
|
121
|
+
def age_bulk(values, gender: nil, country: nil, locale: nil, ip: nil)
|
|
122
|
+
post("/age/bulk", present(names: Array(values), gender: gender, country: country, locale: locale, ip: ip))
|
|
123
|
+
end
|
|
104
124
|
def account
|
|
105
125
|
request(Net::HTTP::Get, "/me")
|
|
106
126
|
end
|
|
@@ -113,6 +133,10 @@ module NameGender
|
|
|
113
133
|
def post(path, body)
|
|
114
134
|
request(Net::HTTP::Post, path, body)
|
|
115
135
|
end
|
|
136
|
+
# The fields that are set: nil and empty strings are dropped.
|
|
137
|
+
def present(fields)
|
|
138
|
+
fields.reject { |_, v| v.nil? || v == "" }
|
|
139
|
+
end
|
|
116
140
|
def request(klass, path, body = nil, raw: nil, headers: {})
|
|
117
141
|
response = transmit(klass, path, body, raw: raw, headers: headers)
|
|
118
142
|
# 204 (a cancelled job) has no body.
|
metadata
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: namegender
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- NameGender
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A dependency-free Ruby client for name, email, username, bulk, country
|
|
14
|
-
distribution, salutation
|
|
14
|
+
distribution, salutation, name check and age lookups through NameGender.
|
|
15
15
|
email:
|
|
16
16
|
- support@namegender.com
|
|
17
17
|
executables: []
|