Module: NameGenderClassifier::FallbackGenderDetector
- Defined in:
- lib/name_gender_classifier/fallback_gender_detector.rb
Overview
If no match is found in the database, this module is called to predict the gender based on the first name suffix.
Constant Summary collapse
- LOCALE =
Returns the locale.
'PT_BR'
- PT_BR_MALE_SUFFIXES =
Returns male suffix terminations for pt-br.
%w[ard as el eu ex iz is o on or os ur us rge me pe se re vi].freeze
- PT_BR_FEMALE_SUFFIXES =
Returns female suffix terminations for pt-br.
%w[a ais are ari eis eme ere ese iko ime ire yse ise isse oko uko ume quel bel cao ce de dis le li lis liz lse ne nis nge ris riz sse].freeze
Class Method Summary collapse
-
.guess_gender(name) ⇒ String
Try to guess the gender based on first name suffix.
Class Method Details
.guess_gender(name) ⇒ String
Try to guess the gender based on first name suffix.
22 23 24 25 |
# File 'lib/name_gender_classifier/fallback_gender_detector.rb', line 22 def self.guess_gender(name) return 'female' if const_get("#{LOCALE}_FEMALE_SUFFIXES").any? { |t| name.end_with?(t) } return 'male' if const_get("#{LOCALE}_MALE_SUFFIXES").any? { |t| name.end_with?(t) } end |