-
Notifications
You must be signed in to change notification settings - Fork 114
feat: add pluralizer package #1128
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c125390
add plural and singular method in fluent str
krishankumar01 4f20561
add pluralizer package
krishankumar01 19327c1
add language type for supported language
krishankumar01 b37a1f6
Merge branch 'master' into kkumar-gcc/str-plural-method
krishankumar01 a2b8abc
re-arch the pluralizer module
krishankumar01 181899f
chore: update mocks
krishankumar01 b7d68e7
add test cases for initialisation
krishankumar01 72966f3
add test cases for inflector and english language
krishankumar01 e57e718
add more rules for english
krishankumar01 5bf8a39
move english ruleset to separate package
krishankumar01 86fb316
chore: update mocks
krishankumar01 79c66e9
Add more rules for English pluralization and singularization
krishankumar01 efdfe35
add new method to extend irregular and uninflected message
krishankumar01 c9274f9
chore: update mocks
krishankumar01 30abc5a
Register methods return errors instead of boolean flags
krishankumar01 dc6fb38
Merge remote-tracking branch 'origin/kkumar-gcc/str-plural-method' in…
krishankumar01 0e27f68
add const for english language
krishankumar01 8caa345
optimize MatchCase method
krishankumar01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package pluralizer | ||
|
|
||
| type Inflector interface { | ||
| Language() Language | ||
| Plural(word string) string | ||
| SetLanguage(language Language) Inflector | ||
| Singular(word string) string | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package pluralizer | ||
|
|
||
| type Language interface { | ||
| Name() string | ||
| SingularRuleset() Ruleset | ||
| PluralRuleset() Ruleset | ||
| } | ||
|
|
||
| type Transformation interface { | ||
| Apply(word string) string | ||
| } | ||
|
|
||
| type Pattern interface { | ||
| Matches(word string) bool | ||
| } | ||
|
|
||
| type Substitution interface { | ||
| From() string | ||
| To() string | ||
| } | ||
|
|
||
| type Transformations []Transformation | ||
|
|
||
| type Patterns []Pattern | ||
|
|
||
| type Substitutions []Substitution |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package pluralizer | ||
|
|
||
| type Ruleset interface { | ||
| AddIrregular(substitutions ...Substitution) Ruleset | ||
| AddUninflected(words ...string) Ruleset | ||
| Regular() Transformations | ||
| Uninflected() Patterns | ||
| Irregular() Substitutions | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we should throw an error in these two cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hwbrzzl ^^