number and words

Discussion in 'Java' started by Daniel, May 2, 2012.

  1. Daniel

    Daniel Guest

    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
    Daniel, May 2, 2012
    #1
    1. Advertising

  2. On 5/2/2012 4:55 PM, Daniel wrote:
    > 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
    Arne Vajhøj, May 2, 2012
    #2
    1. Advertising

  3. Daniel

    Roedy Green Guest

    On Wed, 2 May 2012 13:55:00 -0700 (PDT), Daniel
    <> wrote, quoted or indirectly quoted
    someone who said :

    >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.
    ..
    Roedy Green, May 2, 2012
    #3
  4. Daniel

    Lew Guest

    Roedy Green wrote:
    > 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?

    --
    Lew
    Lew, May 3, 2012
    #4
  5. Daniel

    Arne Vajhøj Guest

    On 5/2/2012 7:13 PM, Lew wrote:
    > Roedy Green wrote:
    >> 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
    Arne Vajhøj, May 3, 2012
    #5
  6. Daniel

    Daniel Guest

    On 2 Maj, 23:23, Roedy Green <> wrote:
    > On Wed, 2 May 2012 13:55:00 -0700 (PDT), Daniel
    > <> wrote, quoted or indirectly quoted
    > someone who said :
    >
    > >in english:
    > >123 one hundred twenty three

    >
    > >in german:
    > >123 eins hudrer deiund zwanzig

    >
    > 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
    Daniel, May 3, 2012
    #6
  7. On Wed, 02 May 2012 19:19:34 -0400, Arne Vajhøj <>
    wrote:

    >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
    Gene Wirchenko, May 3, 2012
    #7
  8. On Wed, 02 May 2012 18:41:19 -0500, Leif Roar Moldskred
    <> wrote:

    >Lew <> wrote:
    >
    >> 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.

    >
    >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
    Gene Wirchenko, May 3, 2012
    #8
  9. On 03/05/2012 00:13, Lew wrote:
    > Roedy Green wrote:
    >> 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"

    --
    RGB
    † English English, as it is spoken in England. This bit anyway. Currently.
    RedGrittyBrick, May 3, 2012
    #9
  10. On 12-05-03 06:03 AM, RedGrittyBrick wrote:
    > On 03/05/2012 00:13, Lew wrote:
    >> Roedy Green wrote:
    >>> 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"
    >

    One hundred and EIGHTY!!! is preferable. :)

    AHS
    --
    A fly was very close to being called a "land," cause that's what they do
    half the time.
    -- Mitch Hedberg
    Arved Sandstrom, May 3, 2012
    #10
  11. On Wed, 02 May 2012 16:20:48 -0700, Daniel wrote:

    > On 2 Maj, 23:23, Roedy Green <> wrote:
    >> On Wed, 2 May 2012 13:55:00 -0700 (PDT), Daniel
    >> <> wrote, quoted or indirectly quoted
    >> someone who said :
    >>
    >> >in english:
    >> >123 one hundred twenty three

    >>
    >> >in german:
    >> >123 eins hudrer deiund zwanzig

    >>

    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"


    --
    martin@ | Martin Gregorie
    gregorie. | Essex, UK
    org |
    Martin Gregorie, May 3, 2012
    #11
  12. On Thu, 03 May 2012 00:06:24 -0500, Leif Roar Moldskred
    <> wrote:

    >Gene Wirchenko <> wrote:
    >>
    >> Oh, my! I have not heard of that one. Which languages?

    >
    >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
    Gene Wirchenko, May 3, 2012
    #12
  13. On Thu, 03 May 2012 12:00:16 -0500, Leif Roar Moldskred
    <> wrote:

    >Gene Wirchenko <> wrote:
    >>
    >> Are you sure about the spelling for "Chepal"? I tried to find
    >> something on it to no avail.

    >
    >My bad, it's "Chepang."


    Thank you.

    Sincerely,

    Gene Wirchenko
    Gene Wirchenko, May 3, 2012
    #13
  14. Daniel

    Lew Guest

    On Thursday, May 3, 2012 2:03:16 AM UTC-7, RedGrittyBrick wrote:
    > On 03/05/2012 00:13, Lew wrote:
    > > Roedy Green wrote:
    > >> 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"
    >
    > --
    > RGB
    > † English English, as it is spoken in England. This bit anyway. Currently.


    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.

    --
    Lew
    Lew, May 3, 2012
    #14
  15. Daniel

    Roedy Green Guest

    On Wed, 2 May 2012 16:13:48 -0700 (PDT), Lew <>
    wrote, quoted or indirectly quoted someone who said :

    >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.
    ..
    Roedy Green, May 3, 2012
    #15
  16. Daniel

    Roedy Green Guest

    On Thu, 3 May 2012 15:12:25 +0000 (UTC), Martin Gregorie
    <> wrote, quoted or indirectly quoted
    someone who said :

    >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.
    ..
    Roedy Green, May 3, 2012
    #16
  17. Daniel

    Tom McGlynn Guest

    On May 3, 5:28 pm, Roedy Green <>
    wrote:
    > On Thu, 3 May 2012 15:12:25 +0000 (UTC), Martin Gregorie
    > <> wrote, quoted or indirectly quoted
    > someone who said :
    >
    > >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.
    >
    >

    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
    Tom McGlynn, May 3, 2012
    #17
  18. Lew <> wrote:

    (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
    glen herrmannsfeldt, May 4, 2012
    #18
  19. Daniel

    Lew Guest

    glen herrmannsfeldt wrote:
    > Lew wrote:
    >
    > (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.


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

    --
    Lew
    Lew, May 4, 2012
    #19
  20. Lew <> wrote:
    (snip, someone wrote)

    >>> "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.


    > 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
    glen herrmannsfeldt, May 4, 2012
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Strøiman
    Replies:
    1
    Views:
    2,082
    Peter Strøiman
    Aug 23, 2005
  2. Richard Heathfield
    Replies:
    7
    Views:
    358
    Barry Schwarz
    Oct 5, 2003
  3. utab

    Words Words

    utab, Feb 16, 2006, in forum: C++
    Replies:
    6
    Views:
    419
    Daniel T.
    Feb 16, 2006
  4. BerlinBrown
    Replies:
    6
    Views:
    4,476
  5. Lasse Edsvik

    replace words with bold words

    Lasse Edsvik, Oct 5, 2003, in forum: ASP General
    Replies:
    9
    Views:
    234
Loading...

Share This Page