-
Notifications
You must be signed in to change notification settings - Fork 163
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
Add Pluralize
function for strings
#3992
Conversation
Or maybe it should be
where |
I think a function would be better. Looking at the examples, perhaps do:
One advantage for this is we could for now add some option to disable pluralizing, which could be a "quick hack" to not break package testing. |
Agree with @ChrisJefferson. The new function could go under 27.9 Operations to Evaluate Strings. |
Just as an extension, I do agree with the plan to fix the pluralisation, and agree it looks bad. |
That will be fun to implement properly :) https://en.wikipedia.org/wiki/English_plurals |
Auto pluralization heuristics can easily cover 99% of the cases, and e.g. Ruby on Rails relies on it heavily (or at least used to when I last used it). Some references:
I think the main reason this isn't done in all parts of GAP is that it's extra work; and while I also find it grating to read, I also understand that sometimes, finishing your actual work is more important than scratching these itches ;-). |
e44d9a0
to
bc88f6d
Compare
Thanks for the input. I'll give look into adding a
Hence my "priority: low" tag ;-) But while I'm unemployed, I've decided I'll take some liberties! |
Oh, sure, I didn't mean to shoot this project down, to the contrary, I am happy somebody works on it :-) |
ce3c6a0
to
d78e528
Compare
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.
Really nice! I'd approve, except for that TODO in the documentation ;-)
d78e528
to
0ce456f
Compare
Hopefully this is now complete. |
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.
Looks good to me! I made a minor suggestion but that could be done in a future PR.
Just in case you are interested in taking this a little bit further: I found a few more things that could be adjusted to use Pluralize
; I grepped for '" points'
, '" vectors'
, '" elements'
, '" pts'
I will make the changes that you suggest. |
I've done so @fingolfin. |
Pluralize
function for strings
I've done some work towards making objects correctly pluralise the word 'generator' in GAP, especially in
ViewString
methods.In English, you say that you have
0 generators
,1 generator
, orn generators
, in the case thatn > 1
. Most (all?) of the methods forViewString
orViewObj
in the library do not special case1 generator
, and instead write1 generators
.So we get, for example:
rather than
The wrongness grates on me, and makes GAP seem that little bit less professional. Therefore, I've gone some way to addressing this. However, I have not spent the time to finish and polish this work, because:
Is there a good reason that I've missed for GAP to be this way?
Will changing all of these methods break the tests of so many packages that it's not worth doing?
My 'fixes' are ugly and repetitive. Really, I want a function that I can use from anyway in GAP, to return the string "generator" if the number of generators is 1, or "generators" otherwise. Any suggestions? How general should this be? That way I could adjust the string construction code to be something like:
where
FUNC
would print the concatenation of the first two arguments if the third istrue
, and only prints the first argument otherwise.