package inflection
Import Path
github.com/jinzhu/inflection (on go.dev)
Dependency Relation
imports 2 packages, and imported by one package
Involved Source Files
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"
Package-Level Type Names (total 4)
Irregular is a hard replace inflection,
containing both singular and plural forms
IrregularSlice is a slice of Irregular inflections
func GetIrregular() IrregularSlice
func SetIrregular(inflections IrregularSlice)
Regular is a regexp find replace inflection
RegularSlice is a slice of Regular inflections
func GetPlural() RegularSlice
func GetSingular() RegularSlice
func SetPlural(inflections RegularSlice)
func SetSingular(inflections RegularSlice)
Package-Level Functions (total 14)
AddIrregular adds an irregular inflection
AddPlural adds a plural inflection
AddSingular adds a singular inflection
AddUncountable adds an uncountable inflection
GetIrregular retrieves the irregular inflection values
GetPlural retrieves the plural inflection values
GetSingular retrieves the singular inflection values
GetUncountable retrieves the uncountable inflection values
Plural converts a word to its plural form
SetIrregular sets the irregular inflections slice
SetPlural sets the plural inflections slice
SetSingular sets the singular inflections slice
SetUncountable sets the uncountable inflections slice
Singular converts a word to its singular form
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |