Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom rules #11

Open
dudeskeeroo opened this issue Oct 14, 2019 · 0 comments
Open

Custom rules #11

dudeskeeroo opened this issue Oct 14, 2019 · 0 comments

Comments

@dudeskeeroo
Copy link

dudeskeeroo commented Oct 14, 2019

Thanks for great lib.

Singularize() is a near-impossible task because inflector can't distinguish context. e.g. it doesn't know if a word is a pronoun, noun, verb etc. Or which context our application will prefer. Should "Skies" become "Sky" or "Ski"?

It also just gets some things plain wrong: "caves' => "cafe", "Is" => "I", "His" => "Hi"

(In fact, the rule changing *-ves should be abolished and special cases for leaves, knives etc be added ... I think the exceptions to the rule are more common the the rule ;) I'll add another issue.)

It would be great if we could add our own rules so we can customize inflector behaviour. We add the rules that are for our circumstances and when inflector calls Singularize() it checks our custom rules first, before using the built-in rules.

e.g.

inflector.AddSingular("Skies", "Ski")
inflector.AddSingular("Caves", "Cave")
inflector.AddSingular("Shaves", "Shave")

Edit: Here's an example of some Singularize() issues on the Go Playground

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant