0
@@ -5,18 +5,24 @@ module Inflector
0
- plural_rules.each do |(rule, replacement)|
0
- break if result.gsub!(rule, replacement)
0
+ if uncountable_words.include?(result.downcase)
0
+ plural_rules.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
0
- singular_rules.each do |(rule, replacement)|
0
- break if result.gsub!(rule, replacement)
0
+ if uncountable_words.include?(result.downcase)
0
+ singular_rules.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
0
def camelize(lower_case_and_underscored_word)
0
@@ -55,42 +61,47 @@ module Inflector
0
+ def uncountable_words #:doc
0
+ %w( equipment information rice money species series fish )
0
def plural_rules #:doc:
0
- [/(fish)$/i, '\1\2'], # fish
0
- [/(information|equipment|money)$/i, '\1'], # plural nouns
0
- [/^(ox)$/i, '\1\2en'], # ox
0
- [/([m|l])ouse/i, '\1ice'], # mouse, louse
0
- [/(x|ch|ss|sh)$/i, '\1es'], # search, switch, fix, box, process, address
0
- [/(series)$/i, '\1\2'],
0
+ [/^(ox)$/i, '\1\2en'], # ox
0
+ [/([m|l])ouse$/i, '\1ice'], # mouse, louse
0
+ [/(matr|vert)ix|ex$/i, '\1ices'], # matrix, vertex, index
0
+ [/(x|ch|ss|sh)$/i, '\1es'], # search, switch, fix, box, process, address
0
[/([^aeiouy]|qu)ies$/i, '\1y'],
0
- [/([^aeiouy]|qu)y$/i, '\1ies'], # query, ability, agency
0
- [/(hive)$/i, '\1s'], # archive, hive
0
+ [/([^aeiouy]|qu)y$/i, '\1ies'], # query, ability, agency
0
+ [/(hive)$/i, '\1s'], # archive, hive
0
[/(?:([^f])fe|([lr])f)$/i, '\1\2ves'], # half, safe, wife
0
- [/sis$/i, 'ses'], # basis, diagnosis
0
- [/([ti])um$/i, '\1a'], # datum, medium
0
- [/(p)erson$/i, '\1\2eople'], # person, salesperson
0
- [/(m)an$/i, '\1\2en'], # man, woman, spokesman
0
- [/(c)hild$/i, '\1\2hildren'], # child
0
- [/(buffal|tomat)o$/i, '\1\2oes'], # buffalo, tomato
0
- [/(bu)s$/i, '\1\2ses'], # bus
0
- [/(alias)/i, '\1es'], # alias
0
- [/([octop|vir])us$/i, '\1i'], # octopus, virus - virus has no defined plural (according to Latin/dictionary.com), but viri is better than viruses/viruss
0
- [/s$/i, 's'], # no change (compatibility)
0
+ [/sis$/i, 'ses'], # basis, diagnosis
0
+ [/([ti])um$/i, '\1a'], # datum, medium
0
+ [/(p)erson$/i, '\1eople'], # person, salesperson
0
+ [/(m)an$/i, '\1en'], # man, woman, spokesman
0
+ [/(c)hild$/i, '\1hildren'], # child
0
+ [/(buffal|tomat)o$/i, '\1\2oes'], # buffalo, tomato
0
+ [/(bu)s$/i, '\1\2ses'], # bus
0
+ [/(alias)/i, '\1es'], # alias
0
+ [/(octop|vir)us$/i, '\1i'], # octopus, virus - virus has no defined plural (according to Latin/dictionary.com), but viri is better than viruses/viruss
0
+ [/(ax|cri|test)is$/i, '\1es'], # axis, crisis
0
+ [/s$/i, 's'], # no change (compatibility)
0
def singular_rules #:doc:
0
- [/(f)ish$/i, '\1\2ish'],
0
+ [/(matr)ices$/i, '\1ix'],
0
+ [/(vert)ices$/i, '\1ex'],
0
[/([octop|vir])i$/i, '\1us'],
0
+ [/(cris|ax|test)es$/i, '\1is'],
0
- [/([m|l])ice
/i, '\1ouse'],
0
+ [/([m|l])ice
$/i, '\1ouse'],
0
[/(x|ch|ss|sh)es$/i, '\1'],
0
[/(m)ovies$/i, '\1\2ovie'],
0
[/(s)eries$/i, '\1\2eries'],
0
@@ -103,11 +114,11 @@ module Inflector
0
[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i, '\1\2sis'],
0
[/(p)eople$/i, '\1\2erson'],
0
- [/(m)en$/i, '\1
\2an'],
0
[/(s)tatus$/i, '\1\2tatus'],
0
[/(c)hildren$/i, '\1\2hild'],
0
[/(n)ews$/i, '\1\2ews'],
0
\ No newline at end of file
Comments
No one has commented yet.