import "github.com/docker/notary/vendor/github.com/jinzhu/inflection"
Package inflection pluralizes and singularizes English nouns.
inflection.Plural("person") => "people" inflection.Plural("Person") => "People" inflection.Plural("PERSON") => "PEOPLE" inflection.Singular("people") => "person" inflection.Singular("People") => "Person" inflection.Singular("PEOPLE") => "PERSON" inflection.Plural("FancyPerson") => "FancydPeople" inflection.Singular("FancyPeople") => "FancydPerson"
Standard rules are from Rails's ActiveSupport (https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflections.rb)
If you want to register more rules, follow:
inflection.AddUncountable("fish") inflection.AddIrregular("person", "people") inflection.AddPlural("(bu)s$", "${1}ses") # "bus" => "buses" / "BUS" => "BUSES" / "Bus" => "Buses" inflection.AddSingular("(bus)(es)?$", "${1}") # "buses" => "bus" / "Buses" => "Bus" / "BUSES" => "BUS"
AddIrregular adds an irregular inflection
AddPlural adds a plural inflection
AddSingular adds a singular inflection
AddUncountable adds an uncountable inflection
GetUncountable retrieves the uncountable inflection values
Plural converts a word to its plural form
func SetIrregular(inflections IrregularSlice)
SetIrregular sets the irregular inflections slice
func SetPlural(inflections RegularSlice)
SetPlural sets the plural inflections slice
func SetSingular(inflections RegularSlice)
SetSingular sets the singular inflections slice
SetUncountable sets the uncountable inflections slice
Singular converts a word to its singular form
type Irregular struct {
// contains filtered or unexported fields
}
Irregular is a hard replace inflection, containing both singular and plural forms
IrregularSlice is a slice of Irregular inflections
func GetIrregular() IrregularSlice
GetIrregular retrieves the irregular inflection values
type Regular struct {
// contains filtered or unexported fields
}
Regular is a regexp find replace inflection
RegularSlice is a slice of Regular inflections
func GetPlural() RegularSlice
GetPlural retrieves the plural inflection values
func GetSingular() RegularSlice
GetSingular retrieves the singular inflection values
Package inflection imports 2 packages (graph). Updated 2017-08-12. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).