Skip to content

Commit

Permalink
combine pluralization and singularization rules (#30)
Browse files Browse the repository at this point in the history
* combine pluralization and singularization rules

Combines the rules for pluralization and singularization into a single
set for improved consistency and maintenance.
Suffix rules are now ordered with most specific matches (longest suffixes)
matched before shorter suffixes.

Also fixed pluralization of "you", should be "you" instead of "yous".
And added some extra cases for better handling of some words ending with
"us".

* remove unused rule

The rule for "appendix" suffix is not used because it's already
in the list of full words.

* alphabetize single to plural word map
  • Loading branch information
pgier authored and markbates committed Dec 17, 2019
1 parent 92a7634 commit 89744b3
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 234 deletions.
4 changes: 4 additions & 0 deletions flect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ var singlePluralAssertions = []tt{
{"prize", "prizes"},
{"edge", "edges"},
{"database", "databases"},
{"circus", "circuses"},
{"plus", "pluses"},
{"fuse", "fuses"},
{"prometheus", "prometheuses"},
}

var pluralSingularAssertions = []tt{}
Expand Down
4 changes: 2 additions & 2 deletions name/name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func Test_Name(t *testing.T) {
{"Widget_ID", "WidgetID"},
{"Widget_Id", "WidgetID"},
{"Widget_id", "WidgetID"},
{"Nice to see you!", "NiceToSeeYou"},
{"Nice to see you today!", "NiceToSeeYouToday"},
{"*hello*", "Hello"},
{"i've read a book! have you?", "IveReadABookHaveYou"},
{"i've read a book! have you read it?", "IveReadABookHaveYouReadIt"},
{"This is `code` ok", "ThisIsCodeOK"},
{"foo_bar", "FooBar"},
{"admin/widget", "AdminWidget"},
Expand Down
4 changes: 2 additions & 2 deletions name/tablize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ func Test_Tableize(t *testing.T) {
table := []tt{
{"", ""},
{"bob dylan", "bob_dylans"},
{"Nice to see you!", "nice_to_see_yous"},
{"Nice to see you!", "nice_to_see_you"},
{"*hello*", "hellos"},
{"i've read a book! have you?", "ive_read_a_book_have_yous"},
{"i've read a book! have you?", "ive_read_a_book_have_you"},
{"This is `code` ok", "this_is_code_oks"},
{"foo_bar", "foo_bars"},
{"admin/widget", "admin_widgets"},
Expand Down

0 comments on commit 89744b3

Please sign in to comment.