Plural inflection methods for the English-language Linguistics module.
It provides conversion of plural forms of all nouns, most verbs, and some adjectives. It also provides “classical” variants (for example: “brother” -> “brethren”, “dogma” -> “dogmata”, etc.) where appropriate.
Classical “..a” -> “..ae”
Classical “..a” -> “..ata”
Classical “..en” -> “..ina”
Classical “..[ei]x” -> “..ices”
Arabic: “..” -> “..i”
Hebrew: “..” -> “..im”
Classical “..o” -> “..i” (but normally -> “..os”)
Classical “..on” -> “..a”
Classical “..um” -> “..a”
Classical “..us” -> “..i”
Classical “..us” -> “..us” (assimilated 4th declension latin nouns)
Unconditional “..a” -> “..ae”
Unconditional “..[ei]x” -> “..ices”
Unconditional “..man” -> “..mans”
Always “..o” -> “..os”
Unconditional “..on” -> “a”
Unconditional “..um” -> “..a”
Unconditional “..us” -> “i”
Plurals
Singular words ending in …s (all inflect with …es)
Don’t inflect in classical mode, otherwise normal inflection
Return the plural of the given phrase if count indicates it should be plural.
# File lib/linguistics/en/pluralization.rb, line 401 def plural( count=2 ) phrase = if self.respond_to?( :to_int ) self.numwords else self.to_s end self.log.debug "Pluralizing %p" % [ phrase ] pre = text = post = nil # If the string has whitespace, only pluralize the middle bit, but # preserve the whitespace to add back to the result. if md = /\A(\s*)(.+?)(\s*)\Z/.match( phrase.to_s ) pre, text, post = md.captures else return phrase end plural = postprocess( text, pluralize_special_adjective(text, count) || pluralize_special_verb(text, count) || pluralize_noun(text, count) ) return pre + plural + post end
Return the plural of the given adjectival phrase if count indicates it should be plural.
# File lib/linguistics/en/pluralization.rb, line 463 def plural_adjective( count=2 ) phrase = self.to_s md = /\A(\s*)(.+?)(\s*)\Z/.match( phrase ) pre, word, post = md.captures return phrase if word.nil? or word.empty? plural = postprocess( word, pluralize_special_adjective(word, count) || word ) return pre + plural + post end
Return the plural of the given noun phrase if count indicates it should be plural.
# File lib/linguistics/en/pluralization.rb, line 431 def plural_noun( count=2 ) phrase = self.to_s md = /\A(\s*)(.+?)(\s*)\Z/.match( phrase ) pre, word, post = md.captures return phrase if word.nil? or word.empty? plural = postprocess( word, pluralize_noun(word, count) ) return pre + plural + post end
Return the plural of the given verb phrase if count indicates it should be plural.
# File lib/linguistics/en/pluralization.rb, line 446 def plural_verb( count=2 ) phrase = self.to_s md = /\A(\s*)(.+?)(\s*)\Z/.match( phrase ) pre, word, post = md.captures return phrase if word.nil? or word.empty? plural = postprocess( word, pluralize_special_verb(word, count) || pluralize_general_verb(word, count) ) return pre + plural + post end
Generated with the Darkfish Rdoc Generator 2.