number and words

D

Daniel

Hi Everybody,
I am looking for library (open source or liberal license) which enable
me to solve the fallowing problem in Java.


I need to convert numbers into words in different languages for
example:

in english:
123 one hundred twenty three

in german:
123 eins hudrer deiund zwanzig

in polish:
123 sto dwadzieścia trzy
and similar in the most common languages:
Italian, German, English, etc.

I have tried to find.... but without results... in php I have found
this kind of lib, but now I have to write software in Java ;-) Do you
have any suggestions? Do you know this kind of libs?

regards,
Daniel
 
A

Arne Vajhøj

I am looking for library (open source or liberal license) which enable
me to solve the fallowing problem in Java.

I need to convert numbers into words in different languages for
example:

in english:
123 one hundred twenty three

in german:
123 eins hudrer deiund zwanzig

in polish:
123 sto dwadzieścia trzy
and similar in the most common languages:
Italian, German, English, etc.

I have tried to find.... but without results... in php I have found
this kind of lib, but now I have to write software in Java ;-) Do you
have any suggestions? Do you know this kind of libs?

I have never seen one in Java either.

I can rewrite the C# code to Java, but ...

:)

Arne
 
R

Roedy Green

in english:
123 one hundred twenty three

in german:
123 eins hudrer deiund zwanzig

see http://mindprod.com/applet/inwords.html

includes source.
there are about 100 languages, though some are not languages in the
usual sense.
--
Roedy Green Canadian Mind Products
http://mindprod.com
Programmers love to create simplified replacements for HTML.
They forget that the simplest language is the one you
already know. They also forget that their simple little
markup language will bit by bit become even more convoluted
and complicated than HTML because of the unplanned way it grows.
..
 
L

Lew

Roedy said:
Daniel wrote, quoted or indirectly quoted someone who said :
in english [sic]:
123 one hundred twenty three

"One hundred twenty-three"
in german [sic]:
123 eins hudrer deiund zwanzig

see http://mindprod.com/applet/inwords.html

includes source.
there are about 100 languages, though some are not languages in the
usual sense.

Another approach would be to expand into one language, e.g., English, then use resource bundles to translate those words into other languages. I don'tknow how effective this would be.

Yet another approach would be to use a database to store translations. The finite approaches are limited, though, for example they might not work wellfor some words, such as "quatre-vingt" in French, which you might not wanttranslated as "four-twenty" in English.

Sorry, I'm not aware of any free code, but does Google Translate have a Webservice? If so, do they charge for it?
 
A

Arne Vajhøj

Roedy said:
Daniel wrote, quoted or indirectly quoted someone who said :
in english [sic]:
123 one hundred twenty three

"One hundred twenty-three"
in german [sic]:
123 eins hudrer deiund zwanzig

see http://mindprod.com/applet/inwords.html

includes source.
there are about 100 languages, though some are not languages in the
usual sense.

Another approach would be to expand into one language, e.g., English, then use resource bundles to translate those words into other languages. I don't know how effective this would be.

It will not work.

The order of the part vary between languages and some languages
has multiple words for the same depending on what it is counting
(gender).
Sorry, I'm not aware of any free code, but does Google Translate have a Web service? If so, do they charge for it?

Not free.

https://developers.google.com/translate/v2/faq#access

But rather cheap.

https://developers.google.com/translate/v2/pricing

(20 USD per 1 M characters seems cheap to me)

Arne
 
D

Daniel

seehttp://mindprod.com/applet/inwords.html

includes source.
there are about 100 languages, though some are not languages in the
usual sense.
--
Roedy Green Canadian Mind Productshttp://mindprod.com
Programmers love to create simplified replacements for HTML.
They forget that the simplest language is the one you
already know. They also forget that their simple little
markup language will bit by bit become even more convoluted
and complicated than HTML because of the unplanned way it grows.
.

"First look", looks REALLY GREAT !!! I will test it. Thanks for
help ;-)
Regards,
Daniel
 
G

Gene Wirchenko

On 5/2/2012 7:13 PM, Lew wrote:
[snip]
Another approach would be to expand into one language, e.g., English,
then use resource bundles to translate those words into other
languages. I don't know how effective this would be.
It will not work.

... and with a vengeance!
The order of the part vary between languages and some languages
has multiple words for the same depending on what it is counting
(gender).

... or how many one is counting. Some languages have special
forms for two of something.

More complexity:

French has some numbers that are in scores. 74 is
"soixante-quatorze" (60 14).

In Chinese, 1) the digits are grouped in fours -- one hundred
thousand is literally "ten ten-thousand" -- and 2) in some cases, one
has to insert the word for zero in mid-number.

I understand that some languages reverse the order of some of
number words.

[snip]

Sincerely,

Gene Wirchenko
 
G

Gene Wirchenko

You'd quickly run into issues with different languages constructing
large numbers in different ways. To point out a worst case scenario,
there are languages that are duodecimal, i.e. they form numbers in
base 12 rather than base 10.

Oh, my! I have not heard of that one. Which languages?

Sincerely,

Gene Wirchenko
 
M

Martin Gregorie

Surely "ein hundert drei und zwanzig"

or, as a simpler example 21 = "twenty one" or "ein und zwanzig", but it
wasn't all that long ago that English also used the German spoken number
order, as in "a maid of just one and twenty summers"
 
G

Gene Wirchenko

Fairly esoteric languages in this context I'll admit. Mostly some
Nigerian languages, but also the Chepal language in Nepal. There are
several other bases in use by languages though, with (in addition to
base 10) base 5 and base 20 the most common.

Are you sure about the spelling for "Chepal"? I tried to find
something on it to no avail.

I recall one science fiction novel with parallel universes that
had one that had a base 8 numbering system. <look look> "The Coming
of the Quantum Cats" by Frederik Pohl.

Sincerely,

Gene Wirchenko
 
L

Lew

Roedy said:
Daniel wrote, quoted or indirectly quoted someone who said :

in english [sic]:
123 one hundred twenty three

"One hundred twenty-three" [sic]

In English†:
"One hundred *and* twenty three"

In American English the "and" is optional, but the hyphen in "twenty-three"is part of the spelling.

From <http://en.wikipedia.org/wiki/English_numerals>:
"Note that in American English, many students are taught not to use the word and anywhere in the whole part of a number, so it is not used before the tens and ones. It is instead used as a verbal delimiter when dealing with compound numbers. Thus, instead of "three hundred and seventy-three", one would say "three hundred seventy-three". For details, see American and British English differences."

So the usage /sic/ /supra/ is legit in my part of the world.
 
R

Roedy Green

Another approach would be to expand into one language, e.g., English, then =
use resource bundles to translate those words into other languages. I don't=
know how effective this would be.

That's what I hoped would be true when I started writing that code. I
thought I would need a common skeleton just with different constants
for thousand etc.

But it turns out they are crazy irregular.

Have a look at Icelandic.
https://wush.net/websvn/mindprod/fi...rod&path=/com/mindprod/inwords/Icelandic.java

or Polish.
https://wush.net/websvn/mindprod/fi...rod&path=/com/mindprod/inwords/Icelandic.java

compared with AmericanEnglish
https://wush.net/websvn/mindprod/fi...th=/com/mindprod/inwords/AmericanEnglish.java

compared with the regularity of Esperanto
https://wush.net/websvn/mindprod/fi...rod&path=/com/mindprod/inwords/Esperanto.java

I have not done it yet, but I suspect Mandarin may be simpler still.

you can play with these only at
http://mindprod.com/inwords/InWords.html
typing in number to see the words in any language.
--
Roedy Green Canadian Mind Products
http://mindprod.com
Programmers love to create simplified replacements for HTML.
They forget that the simplest language is the one you
already know. They also forget that their simple little
markup language will bit by bit become even more convoluted
and complicated than HTML because of the unplanned way it grows.
..
 
R

Roedy Green

or, as a simpler example 21 = "twenty one" or "ein und zwanzig", but it
wasn't all that long ago that English also used the German spoken number
order, as in "a maid of just one and twenty summers"

not all that long ago...

A. E. Housman (1859 1936). A Shropshire Lad. 1896.

XIII. When I was one-and-twenty


WHEN I was one-and-twenty
I heard a wise man say,
‘Give crowns and pounds and guineas
But not your heart away;

Give pearls away and rubies
But keep your fancy free
But I was one-and-twenty,
No use to talk to me.

When I was one-and-twenty
I heard him say again,
‘The heart out of the bosom
Was never given in vain;
’Tis paid with sighs a plenty
And sold for endless rue.’
And I am two-and-twenty,
And oh, ’tis true, ’tis true.

When I wrote InWords, I found native speakers arguing about how
various numbers should be expressed. Perhaps these rules are not
written down in some official place. They may be like local dialects.

For Dutch, to settle the disputes I ended up writing Dutch, Old Dutch
and Bankers' Dutch variants. Similarly there are two Spanish variants.

Naming pairs of groups of animals is called the art of venery, e.g. a
brace of pheasants. Knights would haze pages for not having this all
memorized. See http://mindprod.com/jgloss/venery.html

I wonder why number pronunciations are so needlessly complicated. It
could be for similar hazing, class distinction, or perhaps to make
numbers more distinct so they could be communicated under less than
ideal conditions. It is not just numbers. It is grammar, pronouns,
irregular verbs. They are more complicated that necessary lacking
symmetry. Children, when they are learning the language try to
correct it.

--
Roedy Green Canadian Mind Products
http://mindprod.com
Programmers love to create simplified replacements for HTML.
They forget that the simplest language is the one you
already know. They also forget that their simple little
markup language will bit by bit become even more convoluted
and complicated than HTML because of the unplanned way it grows.
..
 
T

Tom McGlynn

not all that long ago...

A. E. Housman (1859 1936).  A Shropshire Lad.  1896.
Naively, I'd have suggested that formal poetry may not be the best
place to see what common usage was. However Google's Ngram viewer
suggests that it is only after the world wars that twenty one became
more common than one and twenty. (Same for one and thirty versus
thirty one). This shift may really be quite recent.

Regards,
Tom McGlynn
 
G

glen herrmannsfeldt

(snip)
From <http://en.wikipedia.org/wiki/English_numerals>:
"Note that in American English, many students are taught not to
use the word and anywhere in the whole part of a number,
so it is not used before the tens and ones. It is instead
used as a verbal delimiter when dealing with compound numbers.

Specifically, for writing the number of dollars on checks.
(Maybe different on cheques.) The cents (xx/100) comes after the and.
Thus, instead of "three hundred and seventy-three", one would
say "three hundred seventy-three". For details, see American and
British English differences."

-- glen
 
L

Lew

glen said:
Lew wrote:

(snip)


Specifically, for writing the number of dollars on checks.
(Maybe different on cheques.) The cents (xx/100) comes after the and.

That's not "and" inside a number name, but between a number name and a numeral representation. Different case.
 
G

glen herrmannsfeldt

That's not "and" inside a number name, but between a number name
and a numeral representation. Different case.

Yes, but it only works if you don't put an "and" inside the number.
(That is, "and" is the delimiter for the dollar amount.)

-- glen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top