def singularize(word)
      result = word.to_s.dup

      if inflections.uncountables.any? { |inflection| result =~ /#{inflection}\Z/i }
        result
      else
        inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
        result
      end
    end
def singularize(word)
      result = word.to_s.dup

      if inflections.uncountables.any? { |inflection| result =~ /#{inflection}\Z/i }
        result
      else
        inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
        result
      end
    end
The reverse of +pluralize+, returns the singular form of a word in a string.

 Examples:
   "posts".singularize            # => "post"
   "octopi".singularize           # => "octopus"
   "sheep".singularize            # => "sheep"
   "word".singularize             # => "word"
   "CamelOctopi".singularize      # => "CamelOctopus"