namegender 0.5.0 → 0.6.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 +31 -0
  3. data/lib/namegender.rb +28 -0
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5350923af9d635c3f939d1f25538c60b6accc0defeb05cf22039573ff89e10fe
4
- data.tar.gz: 39dcaef2b09d1357e6a6bab9d47f4ac5136e936e4b3a1d1a66bea68ae315f583
3
+ metadata.gz: c4643c981f5be9a9a9e2e4ebd41d812b466c1e740918d01374daf75c9d1e60ae
4
+ data.tar.gz: b46fa7433ebbae2738c127a4b1446d13d1fa14f98ec3369ad3c6ac7184d1b316
5
5
  SHA512:
6
- metadata.gz: fe4b4f3e318ebb9f6ff60ff3d8492cfd83d2e1fb068208563a966c3a5fc5dad1e84289956d31c47b9cd2edddadace69f6a216074922276e284689ba5c2ae3d97
7
- data.tar.gz: 036b301d1b82c4443657cbaa9a38351de62bb15c47c7621741475a0e7fcc3c46c1085c7f2b3fde0ae0ff558de84383645341e5f35f0a78f8b2f7a36cdd3dbe4a
6
+ metadata.gz: 2fcce41ef6af0dab6bb88560310d56d8573d8f2267b95a3b9c669818f679f7b63a1b0f27dd9d77ec329d651b3f14a879d7eaae30f7a58cd5283165f15328e54b
7
+ data.tar.gz: 8a072d1a84da3868b1d170f98b8c90e7210716f91737fb9f3fb30515e50b166706c3d5801edf94e5a63010273beef31143fbe2c3e3da679a5065d35672ba2f3a
data/README.md CHANGED
@@ -53,6 +53,37 @@ result["registrations"].each { |r| puts "#{r["country"]} #{r["share"]}%" }
53
53
  puts result["attested_in"].join(", ")
54
54
  ```
55
55
 
56
+ ## Salutation
57
+
58
+ A ready-to-use salutation for a letter or an email, in `en`, `de`, `fr`, `es`,
59
+ `it`, `pt`, `nl`, `tr`, `pl` or `ja` (and regional variants such as `de-AT`
60
+ or `pt-BR`). Without `language:` it follows `locale:`, then the country, then
61
+ English.
62
+
63
+ ```ruby
64
+ result = client.salutation("Dr. Anna Müller", language: "de")
65
+ puts result["salutation"]["formal"] # Sehr geehrte Frau Dr. Müller,
66
+ puts result["salutation"]["informal"] # Liebe Anna,
67
+
68
+ client.salutation("Ahmet Yılmaz", language: "tr")["salutation"]["formal"] # Sayın Ahmet Bey,
69
+
70
+ # Names stored in separate fields are used as they are, not parsed:
71
+ client.salutation(first_name: "Anna", last_name: "Müller", title: "Dr.", language: "de")
72
+
73
+ result = client.salutation_bulk(["Dr. Anna Müller", "Müller GmbH"], language: "de")
74
+ result["results"].each { |r| puts r["salutation"]["formal"] }
75
+ puts result["summary"] # total, gendered, neutral, organization
76
+ ```
77
+
78
+ One credit per name. When the gender is not certain enough (`min_probability:`,
79
+ default 90), you get the neutral form rather than a guess: `form` is
80
+ `"gendered"`, `"neutral"` or `"organization"`, and `reason` says why it is not
81
+ gendered (`"gender_unknown"`, `"below_min_probability"`, ...). `best_guess`
82
+ does not apply here. If you already know the gender, pass
83
+ `gender: "female"`, `"male"` or `"neutral"`. `salutation_bulk` takes up to 100
84
+ names and returns `results` in input order. An unsupported language raises
85
+ `NameGender::Error` with status 422 and `body["supported"]`.
86
+
56
87
  ## File jobs
57
88
 
58
89
  Upload a CSV or XLSX file (up to 100 MB and 1,000,000 rows) and get it back
data/lib/namegender.rb CHANGED
@@ -52,6 +52,34 @@ module NameGender
52
52
  def countries(value, limit: nil)
53
53
  post("/gender/countries", { name: value, limit: limit }.compact)
54
54
  end
55
+ # A salutation for a letter or an email: "Sehr geehrte Frau Dr. Müller,",
56
+ # "Sayın Ahmet Bey,". `value` is the full name, titles included; pass
57
+ # `first_name:` and `last_name:` instead when they are stored separately
58
+ # (they are not parsed). `language` defaults to the language of `locale`,
59
+ # then the main language of the country, then "en"; an unsupported one is
60
+ # a 422. `gender:` ("male", "female", "neutral") is a known gender and
61
+ # skips the lookup; `min_probability:` (50-100, server default 90) is the
62
+ # certainty below which the neutral form is used; `title:` is an academic
63
+ # title kept in a separate field ("Dr."). "form" and "reason" in the result
64
+ # say why a neutral form was chosen. One credit per name. `best_guess` and
65
+ # `ai_fallback` do not apply here and are not accepted.
66
+ def salutation(value = nil, first_name: nil, last_name: nil, language: nil, country: nil, locale: nil, ip: nil,
67
+ gender: nil, min_probability: nil, title: nil)
68
+ post("/salutation", {
69
+ name: value, first_name: first_name, last_name: last_name, language: language, country: country,
70
+ locale: locale, ip: ip, gender: gender, min_probability: min_probability, title: title
71
+ }.compact)
72
+ end
73
+ # Up to 100 names; every option applies to all of them. "results" keeps
74
+ # the input order, "summary" counts the gendered, neutral and organization
75
+ # forms.
76
+ def salutation_bulk(values, language: nil, country: nil, locale: nil, ip: nil, gender: nil, min_probability: nil,
77
+ title: nil)
78
+ post("/salutation/bulk", {
79
+ names: Array(values), language: language, country: country, locale: locale, ip: ip, gender: gender,
80
+ min_probability: min_probability, title: title
81
+ }.compact)
82
+ end
55
83
  def account
56
84
  request(Net::HTTP::Get, "/me")
57
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: namegender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - NameGender
@@ -10,8 +10,8 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2026-10-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: A dependency-free Ruby client for name, email, username, bulk and country
14
- distribution lookups through NameGender.
13
+ description: A dependency-free Ruby client for name, email, username, bulk, country
14
+ distribution and salutation lookups through NameGender.
15
15
  email:
16
16
  - support@namegender.com
17
17
  executables: []