Skip to content

Commit

Permalink
the last clean up, with and the test case for #61
Browse files Browse the repository at this point in the history
  • Loading branch information
sio4 committed Jan 5, 2023
1 parent a5b7e0d commit cd22f5e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 41 deletions.
28 changes: 12 additions & 16 deletions flect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,34 +94,27 @@ var singlePluralAssertions = []dict{
{"SmartPerson", "SmartPeople", true, true},
{"great_person", "great_people", true, true},
{"salesperson", "salespeople", true, true},
{"custom_field", "custom_fields", true, true},
{"funky jeans", "funky jeans", true, true},
{"payment_information", "payment_information", true, true},
{"sportsEquipment", "sportsEquipment", true, true},
{"status_code", "status_codes", true, true},
{"user_custom_field", "user_custom_fields", true, true},
{"SuperbOx", "SuperbOxen", true, true},
{"WildOx", "WildOxen", true, true},
{"wild_ox", "wild_oxen", true, true},
{"box", "boxes", true, true},
{"cat", "cats", true, true},
{"fox", "foxes", true, true},
{"comment", "comments", true, true},
{"custom_field", "custom_fields", true, true},
{"dear", "dears", true, true},
{"diagnosis_a", "diagnosis_as", true, true},
{"edge", "edges", true, true},
{"equipment", "equipment", true, true},
{"experience", "experiences", true, true},
{"field", "fields", true, true},
{"fleet", "fleets", true, true},
{"foobar", "foobars", true, true},
{"fox", "foxes", true, true},
{"funky jeans", "funky jeans", true, true},
{"jeans", "jeans", true, true},
{"mouse", "mice", true, true},
{"news", "news", true, true},
{"newsletter", "newsletters", true, true},
{"payment_information", "payment_information", true, true},
{"rice", "rice", true, true},
{"sportsEquipment", "sportsEquipment", true, true},
{"stack", "stacks", true, true},
{"status_code", "status_codes", true, true},
{"user", "users", true, true},
{"user_custom_field", "user_custom_fields", true, true},
{"woman", "women", true, true},
{"human", "humans", true, true},
{"spokesman", "spokesmen", true, true},
Expand Down Expand Up @@ -304,8 +297,11 @@ var singlePluralAssertions = []dict{
{"spice", "spices", true, true}, // -pice
{"device", "devices", true, true}, // -vice
{"service", "services", true, true},
{"fix", "fixes", true, true}, // -ix
{"sex", "sexes", true, true}, // -ex
{"fix", "fixes", true, true}, // -ix
{"sex", "sexes", true, true}, // -ex
{"invoice", "invoices", true, true}, // gobuffalo/flect#61
{"voice", "voices", true, true},
{"choice", "choices", true, true},

// Words from Latin that end in -is change -is to -es
{"axis", "axes", true, true},
Expand Down
27 changes: 2 additions & 25 deletions plural_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ var dictionary = []word{
{singular: "auditorium", plural: "auditoria", alternative: "auditoriums"},
{singular: "symposium", plural: "symposia", alternative: "symposiums"},
{singular: "curriculum", plural: "curriculums", alternative: "curricula"}, // ulum
{singular: "quota", plural: "quotas"},

// Words from Latin that end in -us change -us to -i or -era
{singular: "alumnus", plural: "alumni", alternative: "alumnuses"}, // -i
Expand Down Expand Up @@ -206,25 +207,7 @@ var dictionary = []word{
// singleToPlural is the highest priority map for Pluralize().
// singularToPluralSuffixList is used to build pluralRules for suffixes and
// compound words.
var singleToPlural = map[string]string{
"alias": "aliases",
"antenna": "antennas",
"concerto": "concertos",
"fez": "fezzes",
"foo": "foos",
"graffito": "graffiti",
"halo": "halos",
"libretto": "librettos",
"offspring": "offspring",
"photo": "photos",
"piano": "pianos",
"quiz": "quizzes",
"quota": "quotas",
"ress": "resses",
"shoe": "shoes",
"synapse": "synapses",
"vedalia": "vedalias",
}
var singleToPlural = map[string]string{}

// pluralToSingle is the highest priority map for Singularize().
// singularToPluralSuffixList is used to build singularRules for suffixes and
Expand All @@ -233,12 +216,6 @@ var pluralToSingle = map[string]string{}

// NOTE: This map should not be built as reverse map of singleToPlural since
// there are words that has the same plurals.
func init() {
// FIXME: remove when the data fully migrated to dictionary.
for k, v := range singleToPlural {
pluralToSingle[v] = k
}
}

// build singleToPlural and pluralToSingle with dictionary
func init() {
Expand Down

0 comments on commit cd22f5e

Please sign in to comment.