Forum: Ruby Thanks Ruby Quiz!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
89d967359903c639d31e4cad4569f537?d=identicon&s=25 Charlie Bowman (Guest)
on 2006-05-10 14:21
(Received via mailing list)
The Rails Plugin is a direct result of the ruby quiz.  I just wanted to
say thanks to Ruby Quiz and Mathew Ross for his solution.


= numbersToWords - convert your integers and floats to english or
japaneese words,or translate it into american currency

- This plugin was created from a solution to the ruby quiz (english
numbers) by Matthew D Moss.  I modified the code to work as a rails
plugin and added the to_dollars method.
- the to_dollars method will work with integers and floats
- the to_english and to_japaneese methods will only work with integers.
If you have call these methods on a float, it will be converted to an
integer before translating.

= Examples
123.to_english == one hundred and twenty-three
123.to_japaneese == hyaku niju san
123.to_dollars == one hundred and twenty-three dollars
money = 123.23
money.to_dollars == one hundred and twenty-three dollars and
twenty-three cents
money = 1.01
money.to_dollars == one dollar and one cent

= Install script/plugin install
http://svn.recentrambles.com/plugins/numbersToWords

= License
Ruby's - Do whatever you want whenever you want, with any part or all of
this code.

= Contributions
you can send patches, questions, or feature requests to
anotherramble@recentrambles.com

= Thank You Ruby Quiz and Matthew D Moss

Charlie Bowman
www.recentrambles.com
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2006-05-10 15:04
(Received via mailing list)
On May 10, 2006, at 7:19 AM, Charlie Bowman wrote:

> = Thank You Ruby Quiz and Matthew D Moss

Awesome!  What a cool success story!

James Edward Gray II
81d609425e306219d54d793a0ad98bce?d=identicon&s=25 Matthew Moss (Guest)
on 2006-05-10 16:40
(Received via mailing list)
On 5/10/06, Charlie Bowman <charlie@castlebranch.com> wrote:
> numbers) by Matthew D Moss.  I modified the code to work as a rails
> money = 123.23
> money.to_dollars == one hundred and twenty-three dollars and
> twenty-three cents
> money = 1.01
> money.to_dollars == one dollar and one cent
>
> = Install script/plugin install
> http://svn.recentrambles.com/plugins/numbersToWords
>

> = Thank You Ruby Quiz and Matthew D Moss

Wow...  neat! You're welcome.

> = License
> Ruby's - Do whatever you want whenever you want, with any part or all of
> this code.

Just  fyi for the future... Submitted rubyquiz code isn't
automatically in the public domain nor automatically under any
particular license. I recommend in the future that you ask the author
before using the code and presenting it publicly.

I don't say this to be a hardass... In particular, with my
submissions, I'm pretty much going to be very lenient and say, "Do
what you like with it." I only say this because potentially there may
be some authors who, for one reason or another, will not want certain
submissions used.

Enough of that...

> - This plugin was created from a solution to the ruby quiz (english
> numbers) by Matthew D Moss.  I modified the code to work as a rails
> plugin and added the to_dollars method.
> - the to_dollars method will work with integers and floats
> - the to_english and to_japaneese methods will only work with integers.
> If you have call these methods on a float, it will be converted to an
> integer before translating.

Some minor comments on my code...

I wasn't particularly happy with the use of "and" in the final
results. It *usually* worked the way I wanted, but not always.

Also, as noted in the comments, my knowledge of counting in Japanese
is somewhat limited. I think it's correct, but could possibly be
improved.

Finally, it is funny that some of the joke comments and strings in the
code are still there... Things like "nothingtoseeheremovealong",
"hello world" and this line:

    x = [('and' if @conjunction and junction)]    # wyf?

... which should be familiar to anyone who watched Schoolhouse Rock
growing up.
89d967359903c639d31e4cad4569f537?d=identicon&s=25 Charlie Bowman (Guest)
on 2006-05-10 17:02
(Received via mailing list)
You're right, I should have asked before using the code.  I assumed that
any code available as a download off the ruby quiz site was part of the
public domain.  I choose to use your solution because of it terseness.
I haven't found a problem with "ands".  Can you give a test case where
it fails?  I left in the comments because I felt it was ruby to modify
your code when I wasn't actually adding any new features.  Thanks again
for doing the hard work on this plugin.  It only took me about 20
minutes to make it a plugin, add another method, and write the README.
Now I just have to make myself disciplined enough to write test cdoe!

Charlie
www.recentramble.com
Cff9eed5d8099e4c2d34eae663aae87e?d=identicon&s=25 Jacob Fugal (Guest)
on 2006-05-10 18:05
(Received via mailing list)
On 5/10/06, Charlie Bowman <charlie@castlebranch.com> wrote:
> You're right, I should have asked before using the code.  I assumed that
> any code available as a download off the ruby quiz site was part of the
> public domain.

On this point, would it drive away many potential quiz solvers if
submission of a RubyQuiz solution implied a BSD style attribution
license?

Jacob Fugal
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2006-05-10 18:11
(Received via mailing list)
On May 10, 2006, at 11:03 AM, Jacob Fugal wrote:

> On 5/10/06, Charlie Bowman <charlie@castlebranch.com> wrote:
>> You're right, I should have asked before using the code.  I
>> assumed that
>> any code available as a download off the ruby quiz site was part
>> of the
>> public domain.
>
> On this point, would it drive away many potential quiz solvers if
> submission of a RubyQuiz solution implied a BSD style attribution
> license?

I don't think I feel comfortable choosing a license for other
people's code.

I assume that posting it where I can see it means you don't mind me
talking about it, but anything else seems like I would be making too
many decisions for you.

James Edward Gray II
784481e009179262d133db1f1eb3bfb1?d=identicon&s=25 Edwin Van leeuwen (blackedder)
on 2006-05-10 18:14
Charlie Bowman wrote:
> I left in the comments because I felt it was ruby to modify
> your code when I wasn't actually adding any new features.

Are you trying to imply that ruby is the same as rude..

Edwin
81d609425e306219d54d793a0ad98bce?d=identicon&s=25 Matthew Moss (Guest)
on 2006-05-10 20:26
(Received via mailing list)
I think the front page of Ruby Quiz provides all that's needed:

"All quizzes, summaries, solutions, and discussion is assumed to be
under copyright by the author, all rights reserved. If a solution is
sent to me or posted to Ruby Talk for all to see, I assume it's okay
to show in the summary. (Just add a note to the submission message if
this is not the case.) All other material on this site is used with
author permission."

That leaves licensing issues to the author.

Truly, if someone really wants to use quiz material as part of a
larger product, it's usually simple and wisest just to contact the
author.
F3b7109c91841c7106784d229418f5dd?d=identicon&s=25 Justin Collins (justincollins)
on 2006-05-10 22:08
(Received via mailing list)
Matthew Moss wrote:
>> - This plugin was created from a solution to the ruby quiz (english
>> numbers) by Matthew D Moss.  I modified the code to work as a rails
>> plugin and added the to_dollars method.
>> - the to_dollars method will work with integers and floats
>> - the to_english and to_japaneese methods will only work with integers.
>> If you have call these methods on a float, it will be converted to an
>> integer before translating.
>>
>> = Examples
>> 123.to_english == one hundred and twenty-three
>>

I know this is really nit-picky, but the "proper" way to say 123 is "one
hundred twenty-three."  "And" is only used for decimal points:

> money.to_dollars == one hundred and twenty-three dollars and
> twenty-three cents

would be "one hundred twenty-three dollars and twenty-three cents."


(Feels the need to insert pun about this being my 0.02.to_dollars)


-Justin
06de0a44d184a590a8f446a9fa1d2d59?d=identicon&s=25 Kerry Buckley (Guest)
on 2006-05-10 22:23
(Received via mailing list)
On 10 May 2006, at 9:08 pm, Justin Collins wrote:
>>>
>>> = Examples
>>> 123.to_english == one hundred and twenty-three
>>>
>
> I know this is really nit-picky, but the "proper" way to say 123 is
> "one hundred twenty-three."  "And" is only used for decimal points:

I'm sure that says to_english, not to_american ;-)

Kerry
F3b7109c91841c7106784d229418f5dd?d=identicon&s=25 Justin Collins (justincollins)
on 2006-05-10 22:45
(Received via mailing list)
Kerry Buckley wrote:
>
> Kerry
>
Good call on the distinction...if the OP could take that into
consideration...we need a to_american method as well... :)

-Justin
2ffac40f8a985a2b2749244b8a1c4161?d=identicon&s=25 Mike Stok (Guest)
on 2006-05-10 22:48
(Received via mailing list)
On 10-May-06, at 4:42 PM, Justin Collins wrote:

>>
>> I'm sure that says to_english, not to_american ;-)
>>
>> Kerry
>>
> Good call on the distinction...if the OP could take that into
> consideration...we need a to_american method as well... :)

Indeed, there is a difference between a British/European billion and
trillion and their American counterparts too. 0.5 :-)

Mike

--

Mike Stok <mike@stok.ca>
http://www.stok.ca/~mike/

The "`Stok' disclaimers" apply.
89d967359903c639d31e4cad4569f537?d=identicon&s=25 Charlie Bowman (Guest)
on 2006-05-10 23:15
(Received via mailing list)
Is there a time at all where and is appropriate with integers?  I know
that and represents a . in a float (this has already been fixed with the
plugin)

Charlie Bowman
www.recentrambles.com
E28c35323f624b8b9ed8712e25105454?d=identicon&s=25 Ray Baxter (Guest)
on 2006-05-11 00:05
(Received via mailing list)
Charlie Bowman wrote:

> Is there a time at all where and is appropriate with integers?  I know
> that and represents a . in a float (this has already been fixed with the
> plugin)

Yes. There is prior art on this. Unfortunately is might be hard to
Google because it is older and the word "and" is a Google stop word. I'm
pretty sure that there is a paper or chapter by Knuth that addresses
both this issue and the English versus American usage of billion. Maybe
this is part of TeX?

Generally, for any number z = x + y where neither x, nor y is zero and
either x or y is a power of ten, then it is acceptable to say either

x.to_English + " " + y.to_english

or

x.to_english + " and " + y.to_english

This is recursive on x and y, but you would only want to use the second
form once per z for numbers less than one hundred thousand. So "one
hundred and twenty and three" is less preferred to "one hundred and
twenty three," but "one hundred and seventy six thousand, three hundred
and thirty two" is idiomatic.

In American speech, a single "and" usually falls in the penultimate
position, so "one hundred and twenty three" is preferred to "one hundred
twenty and three." The second seems more common in British English, but
perhaps this is archaic. If there are two "ands" then they are typically
in the first and penultimate positions.

Numbers greater than 10^8 can have up to three "ands", etc.

--

Ray
A9b6a93b860020caf9d2d1d58c32478f?d=identicon&s=25 Ross Bamford (Guest)
on 2006-05-11 09:11
(Received via mailing list)
On Thu, 2006-05-11 at 07:03 +0900, Ray Baxter wrote:
> this is part of TeX?
>

Billions are now unified, with even the BBC now using it to mean 1000
million. Previously, a billion here was one million million, while one
thousand million was sometimes a 'milliard' but this isn't used anymore.
Lots of other countries still use the 'old' definition, however, so it's
still shaky ground for making assumptions.

> Generally, for any number z = x + y where neither x, nor y is zero and
> either x or y is a power of ten, then it is acceptable to say either
>
> x.to_English + " " + y.to_english
>
> or
>
> x.to_english + " and " + y.to_english
>

I think for an international audience, the second option is the best,
since I don't know anyone here in England who would consider the first
to be correct.

> in the first and penultimate positions.
>

I've never heard e.g 'one hundred twenty and three' spoken - you may be
thinking of stuff like 'three and twenty' for 23, but that is archaic
and in any event doesn't fit with the 'one-hundred'. I guess it'd be a
bit like you guys saying "Six thousand, two hundred four-score and
seven".
This topic is locked and can not be replied to.