Module: Pinspec::Analyzer::Inflector
- Defined in:
- lib/pinspec/analyzer/inflector.rb
Constant Summary collapse
- IRREGULAR_PLURALS =
{ "person" => "people", "child" => "children", "man" => "men", "woman" => "women", "foot" => "feet", "tooth" => "teeth", "mouse" => "mice", "goose" => "geese", "ox" => "oxen", "datum" => "data", "medium" => "media", "criterion" => "criteria", "analysis" => "analyses", "diagnosis" => "diagnoses", "basis" => "bases", "index" => "indices", "matrix" => "matrices", "vertex" => "vertices", "status" => "statuses" }.freeze
- IRREGULAR_SINGULARS =
IRREGULAR_PLURALS.invert.freeze
- UNCOUNTABLE =
%w[ data metadata series species information equipment money news settings preferences credentials ].freeze
Class Method Summary collapse
Class Method Details
.singular_candidates(table) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/pinspec/analyzer/inflector.rb', line 49 def singular_candidates(table) table = table.to_s return [table] if table.empty? candidates = [] candidates << IRREGULAR_SINGULARS[table] if IRREGULAR_SINGULARS.key?(table) candidates << table if UNCOUNTABLE.include?(table) candidates << "#{table[0..-4]}y" if table.end_with?("ies") && table.length > 3 candidates << table[0..-2] if table.end_with?("s") && !table.end_with?("ss") candidates << table[0..-3] if table.end_with?("es") && table.length > 2 candidates << table candidates.compact.uniq end |
.table_candidates(stem) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pinspec/analyzer/inflector.rb', line 36 def table_candidates(stem) stem = stem.to_s return [stem] if stem.empty? candidates = [] candidates << IRREGULAR_PLURALS[stem] if IRREGULAR_PLURALS.key?(stem) candidates << stem if UNCOUNTABLE.include?(stem) candidates.concat(regular_plurals(stem)) candidates << stem candidates.compact.uniq end |