[Haskell-cafe] ANN: numerals

Rogan Creswick creswick at gmail.com
Fri Sep 16 19:16:02 CEST 2011


2011/9/16 Roel van Dijk <vandijk.roel at gmail.com>:
> 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
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



More information about the Haskell-Cafe mailing list