Skip Menu |

This queue is for tickets about the Lingua-EN-Inflexion CPAN distribution.

Report information
The Basics
Id: 133089
Status: resolved
Priority: 0/
Queue: Lingua-EN-Inflexion

People
Owner: Nobody in particular
Requestors: ALEENA [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Gotcha found when using ordinal and cardinal together
Hello again, When using NUMWORDS and ORD together in Lingua::EN::Inflect, the order they were used in did not matter: say "NUWORDS to ORD: " . ORD(NUMWORDS('3')); # NUWORDS to ORD: third say "ORD to NUWORDS: " . NUMWORDS(ORD('3')); # ORD to NUWORDS: third However, in Lingua::EN::Inlfexion, the order cardinal and ordinal are used in does matter: say "cardinal to ordinal: " . noun(noun('3')->cardinal)->ordinal; # cardinal to ordinal: third say "ordinal to cardinal: " . noun(noun('3')->ordinal)->cardinal; # ordinal to cardinal: three I do not know if this also affects using them together in inflect(). Again, I hope you are having a good day... Lady Aleena
Subject: Re: [rt.cpan.org #133089] Gotcha found when using ordinal and cardinal together
Date: Fri, 31 Jul 2020 21:54:26 +0000
To: bug-Lingua-EN-Inflexion [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Show quoted text
> When using NUMWORDS and ORD together in Lingua::EN::Inflect, > the order they were used in did not matter:
Yes. And that was clearly a bug in that module. Or, at least, in the design of the module's API. Show quoted text
> However, in Lingua::EN::Inflexion, the order > cardinal and ordinal are used in does matter:
Yes, this module does indeed fix that previous erroneous behaviour. The idea being that if you indicate that you ultimately want an ordinal (by calling ->ordinal() last), then you should get an ordinal. And, likewise, if you specify that you want a cardinal (by calling ->cardinal() last), then you should get a cardinal. Hence, I believe that the current behaviour is correct. However, it is entirely possible that I have misunderstood your report. If so please reply and help me understand why you believe the current behaviour to be wrong...or even just unsatisfactory. Thank-you again most sincerely for your continuing efforts to help improve this module. Damian
On Fri Jul 31 17:55:16 2020, damian@conway.org wrote: Show quoted text
> However, it is entirely possible that I have misunderstood your report. > If so please reply and help me understand why you believe > the current behaviour to be wrong...or even just unsatisfactory.
The behavior isn't wrong, or even unsatisfactory, it was a little surprise; a "gotcha". Using cardinal and ordinal together may be an edge case, but some who have been used to using NUMWORDS and ORD in any order they wanted may be a little confused at first. I may be in a very small minority who uses this module to get the number words for ordinals from a number. It is something I found noteworthy, but others may not. Do with it what you will. 8) Lady Aleena
Subject: Re: [rt.cpan.org #133089] Gotcha found when using ordinal and cardinal together
Date: Sat, 1 Aug 2020 09:26:29 +0000
To: bug-Lingua-EN-Inflexion [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Thanks for clarifying. I expect that the APIs are sufficiently different, and the number of serious users sufficiently small, that this change in behaviour in the new module will probably not cause widespread confusion. BTW, I'm assuming that you realized that, with Lingua::EN::Inflect, you don't actually ever need to use both methods together. You can just write: noun(3)->cardinal # "three" noun(3)->ordinal # "third" Thanks again, Damian
On Sat Aug 01 05:27:14 2020, damian@conway.org wrote: Show quoted text
> BTW, I'm assuming that you realized that, with Lingua::EN::Inflect, > you don't actually ever need to use both methods together. > You can just write: > > noun(3)->cardinal # "three" > noun(3)->ordinal # "third"
I didn't realize that! I've been using NUMWORDS(ORD()) from Inflect for so long now that I just assumed it would be the same with Inflexion where ordinal would return "3rd" as ORD does. ORD(3) # "3rd" noun(3)->ordinal # "third" Lady Aleena
Subject: Re: [rt.cpan.org #133089] Gotcha found when using ordinal and cardinal together
Date: Sat, 1 Aug 2020 22:06:44 +0000
To: bug-Lingua-EN-Inflexion [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Show quoted text
> I didn't realize that! I've been using NUMWORDS(ORD()) from Inflect > for so long now that I just assumed it would be the same with > Inflexion where ordinal would return "3rd" as ORD does. > > ORD(3) # "3rd" > noun(3)->ordinal # "third"
Both ->cardinal() and ->ordinal() take an optional argument that selects whether they return words or numerals. Or, more precisely: that selects *where* they switch from words back to numerals. For example: noun(42)->ordinal # "forty-second" (words, because 42 <= ∞) noun(42)->ordinal(99) # "forty-second" (words, because 42 <= 99) noun(42)->ordinal(10) # "42nd" (numerals, because 42 > 10) The idea is to make it easy to apply whatever rules for spelling out numbers that are appropriate to the style guide you are using (MLA, APA, CMS, etc.) Some mandate spelling out any number less than 10, others say less than 11, or less than 101...so I made the words-or-numerals threshold a parameter. Of course, this doesn't cater for the MLA style, which is: "Use numerals unless the number appears infrequently and can be written in no more than two words", but no-one has ever actually asked for that. :-) Damian