namegender 0.6.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +57 -0
  3. data/lib/namegender.rb +45 -0
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4643c981f5be9a9a9e2e4ebd41d812b466c1e740918d01374daf75c9d1e60ae
4
- data.tar.gz: b46fa7433ebbae2738c127a4b1446d13d1fa14f98ec3369ad3c6ac7184d1b316
3
+ metadata.gz: 697eadb66c1e662a33a859ad917c8a094db92477df1687d5120ff4c6894dd466
4
+ data.tar.gz: fb5eb0a69ef1e910892b847be2dbd253b9e2b3bf596192aadcdbfc46bd21fcf0
5
5
  SHA512:
6
- metadata.gz: 2fcce41ef6af0dab6bb88560310d56d8573d8f2267b95a3b9c669818f679f7b63a1b0f27dd9d77ec329d651b3f14a879d7eaae30f7a58cd5283165f15328e54b
7
- data.tar.gz: 8a072d1a84da3868b1d170f98b8c90e7210716f91737fb9f3fb30515e50b166706c3d5801edf94e5a63010273beef31143fbe2c3e3da679a5065d35672ba2f3a
6
+ metadata.gz: f8b59ef517681af8a964f29430b8ae253f70afbffa58bc4a261c029c51655a351488b9698a898c9253bf32e4d54c4ccaea01b5bcadcb7cab730561a06e914e53
7
+ data.tar.gz: 566b094d3df1e8647a72571543c358798427442352fe579954f279b603426c3204d0be0341c4a5b4b903c835439eb7d00ac70ffc9bf2350ec283e4554a3213ed
data/README.md CHANGED
@@ -84,6 +84,63 @@ does not apply here. If you already know the gender, pass
84
84
  names and returns `results` in input order. An unsupported language raises
85
85
  `NameGender::Error` with status 422 and `body["supported"]`.
86
86
 
87
+ ## Name check
88
+
89
+ Whether a name typed into a form looks like a real person's name, with the
90
+ reasons. It never calls a name fake: use it to flag records for a closer look,
91
+ not to reject people automatically.
92
+
93
+ ```ruby
94
+ result = client.name_check("asdf qwerty")
95
+ puts result["assessment"] # implausible
96
+ puts result["score"] # 0 (0-100)
97
+ result["signals"].each { |s| puts "#{s["code"]} #{s["severity"]} #{s["part"]}" } # keyboard_pattern high first_name, ...
98
+
99
+ client.name_check("Jennifer Null")["assessment"] # plausible
100
+
101
+ # Names stored in separate fields are used as they are, not parsed:
102
+ client.name_check(first_name: "Jennifer", last_name: "Null", country: "US")
103
+
104
+ result = client.name_check_bulk(["Jennifer Null", "asdf qwerty"])
105
+ puts result["summary"] # total, plausible, suspicious, implausible
106
+ ```
107
+
108
+ One credit per name. `assessment` is `"plausible"`, `"suspicious"` or
109
+ `"implausible"`; each signal has `code`, `severity` (`high`, `medium`, `low`,
110
+ `info`, `positive`), `part` and `value` (either can be `nil`). `evidence`
111
+ says whether the first name is counted, attested or not found. Surnames are
112
+ judged by their shape only. It takes `country:`, `locale:` and `ip:`, not
113
+ `best_guess` or `ai_fallback`. `name_check_bulk` takes up to 100 names and
114
+ returns `results` in input order.
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
+
87
144
  ## File jobs
88
145
 
89
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
@@ -80,6 +80,47 @@ module NameGender
80
80
  min_probability: min_probability, title: title
81
81
  }.compact)
82
82
  end
83
+ # Whether a name typed into a form looks like a real person's name, with
84
+ # reasons. It never calls a name fake: use it to flag records for a look,
85
+ # not to reject people automatically. "assessment" is "plausible",
86
+ # "suspicious" or "implausible", "score" is 0-100, and "signals" lists
87
+ # why ({"code", "severity", "part", "value"}; "part" and "value" can be
88
+ # nil). Surnames are judged by their shape only. `value` is the full name;
89
+ # pass `first_name:` and `last_name:` instead when they are stored
90
+ # separately (they are not parsed). `country`, `locale` and `ip` work as
91
+ # in #name. One credit per name. `best_guess`, `ai_fallback` and
92
+ # `language` do not apply here and are not accepted.
93
+ def name_check(value = nil, first_name: nil, last_name: nil, country: nil, locale: nil, ip: nil)
94
+ post("/name-check", {
95
+ name: value, first_name: first_name, last_name: last_name, country: country, locale: locale, ip: ip
96
+ }.compact)
97
+ end
98
+ # Up to 100 names; every option applies to all of them. "results" keeps
99
+ # the input order, "summary" counts the plausible, suspicious and
100
+ # implausible names.
101
+ def name_check_bulk(values, country: nil, locale: nil, ip: nil)
102
+ post("/name-check/bulk", { names: Array(values), country: country, locale: locale, ip: ip }.compact)
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
83
124
  def account
84
125
  request(Net::HTTP::Get, "/me")
85
126
  end
@@ -92,6 +133,10 @@ module NameGender
92
133
  def post(path, body)
93
134
  request(Net::HTTP::Post, path, body)
94
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
95
140
  def request(klass, path, body = nil, raw: nil, headers: {})
96
141
  response = transmit(klass, path, body, raw: raw, headers: headers)
97
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.6.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-06 00:00:00.000000000 Z
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 and salutation lookups through NameGender.
14
+ distribution, salutation, name check and age lookups through NameGender.
15
15
  email:
16
16
  - support@namegender.com
17
17
  executables: []