From cd22f5e04fa13f3c453de75b97ffd53616bb6845 Mon Sep 17 00:00:00 2001 From: Yonghwan SO Date: Fri, 6 Jan 2023 02:01:06 +0900 Subject: [PATCH] the last clean up, with and the test case for #61 --- flect_test.go | 28 ++++++++++++---------------- plural_rules.go | 27 ++------------------------- 2 files changed, 14 insertions(+), 41 deletions(-) diff --git a/flect_test.go b/flect_test.go index d055f20..848d77a 100644 --- a/flect_test.go +++ b/flect_test.go @@ -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}, @@ -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}, diff --git a/plural_rules.go b/plural_rules.go index f682ba6..53c6081 100644 --- a/plural_rules.go +++ b/plural_rules.go @@ -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 @@ -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 @@ -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() {