ANN: numerals

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ANN: numerals

Roel van Dijk-3
Hello everyone,

I would like to announce the release of the numerals and
numerals-base packages.


* Numerals

The numerals package contains functions to convert numbers to
number words in a number of languages. For now the package only
supports cardinal numbers.

Example:
>>> import qualified Text.Numeral.Language.EN as EN
>>> EN.uk_cardinal 123 :: Maybe String
Just "one hundred and twenty-three"

You can also inspect the underlying structure of a number word:
>>> import Text.Numerals
>>> EN.shortScaleStruct 123 :: Exp
Add (Mul (Lit 1) (Lit 100)) (Add (Mul (Lit 2) (Lit 10)) (Lit 3))

Compare this structure with the number word:
1 (one) * 100 (hundred) + (and) 2 (twen) * 10 (ty) + 3 (three)

The package also comes with a test suite:
>>> cabal configure --enable-tests
>>> cabal build
>>> ./dist/build/test-numerals/test-numerals --hide-successes

I recommend the "--hide-successes" option of test-framework (>=0.4)
because there are many tests (3383).


* Numerals-base

The numerals-base package contains all the machinery upon which
numerals is build. Using this package you can write conversion
functions for your own language(s). It is documented, although
the documentation can be improved. For now the numerals package
is probably the best documentation.


* Resources:

Hackage:
http://hackage.haskell.org/package/numerals
http://hackage.haskell.org/package/numerals-base

Github:
http://github.com/roelvandijk/numerals
http://github.com/roelvandijk/numerals-base


* Help wanted

Currently I support 24 languages. But I only have some experience with
4 of them. The rest is scraped together with information I found
online. For most languages I can find online how to form the first 100
cardinal numbers. But after that information is sparse. You can help
by checking and expanding the test suite. This is very simple because
the test suite consists only of numbers combined with the expected
cardinal number word.


Regards,
Roel van Dijk

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: ANN: numerals

Rogan Creswick
2011/9/16 Roel van Dijk <[hidden email]>:

> Hello everyone,
>
> I would like to announce the release of the numerals and
> numerals-base packages.
>
>
> * Numerals
>
> The numerals package contains functions to convert numbers to
> number words in a number of languages. For now the package only
> supports cardinal numbers.

Cool!

Are you familiar with the Grammatical Framework [1]? It is a Haskell
library and language for natural language parsing and translation --
If you need to do a lot of translation or string localization, you
should take a look at it as much of the complexity has been addressed
there.

That said, the numeral libraries for GF are somewhat limited (and/or
somewhat undocumented) so there is probably a lot your experience and
library could bring to that project.

[1] http://www.grammaticalframework.org

--Rogan

>
> Example:
>>>> import qualified Text.Numeral.Language.EN as EN
>>>> EN.uk_cardinal 123 :: Maybe String
> Just "one hundred and twenty-three"
>
> You can also inspect the underlying structure of a number word:
>>>> import Text.Numerals
>>>> EN.shortScaleStruct 123 :: Exp
> Add (Mul (Lit 1) (Lit 100)) (Add (Mul (Lit 2) (Lit 10)) (Lit 3))
>
> Compare this structure with the number word:
> 1 (one) * 100 (hundred) + (and) 2 (twen) * 10 (ty) + 3 (three)
>
> The package also comes with a test suite:
>>>> cabal configure --enable-tests
>>>> cabal build
>>>> ./dist/build/test-numerals/test-numerals --hide-successes
>
> I recommend the "--hide-successes" option of test-framework (>=0.4)
> because there are many tests (3383).
>
>
> * Numerals-base
>
> The numerals-base package contains all the machinery upon which
> numerals is build. Using this package you can write conversion
> functions for your own language(s). It is documented, although
> the documentation can be improved. For now the numerals package
> is probably the best documentation.
>
>
> * Resources:
>
> Hackage:
> http://hackage.haskell.org/package/numerals
> http://hackage.haskell.org/package/numerals-base
>
> Github:
> http://github.com/roelvandijk/numerals
> http://github.com/roelvandijk/numerals-base
>
>
> * Help wanted
>
> Currently I support 24 languages. But I only have some experience with
> 4 of them. The rest is scraped together with information I found
> online. For most languages I can find online how to form the first 100
> cardinal numbers. But after that information is sparse. You can help
> by checking and expanding the test suite. This is very simple because
> the test suite consists only of numbers combined with the expected
> cardinal number word.
>
>
> Regards,
> Roel van Dijk
>
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: ANN: numerals

Roel van Dijk-3
> Are you familiar with the Grammatical Framework [1]? It is a Haskell
> library and language for natural language parsing and translation --
> If you need to do a lot of translation or string localization, you
> should take a look at it as much of the complexity has been addressed
> there.

Yes. Someone mentioned it to me in the Haskell IRC channel
approximately a year ago when I was discussing some problems I
had with my numerals package. I am not really in need to
translation or string localization. The numerals package is
merely a hobby project that got a bit out of hand :-)

> That said, the numeral libraries for GF are somewhat limited (and/or
> somewhat undocumented) so there is probably a lot your experience and
> library could bring to that project.

I am interested in the ways the two projects could work
together. Maybe they could check each other's results.

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe