name: numerals version: 0.4 cabal-version: >= 1.8 build-type: Simple stability: experimental author: Roel van Dijk , Bas van Dijk maintainer: Roel van Dijk copyright: 2009–2014 Roel van Dijk, Bas van Dijk license: BSD3 license-file: LICENSE homepage: https://github.com/roelvandijk/numerals bug-reports: https://github.com/roelvandijk/numerals/issues category: Natural Language Processing, Numerical, Text synopsis: Convert numbers to number words description: Convert numbers to number words in a number of languages. Each language has its own module. The module name is based on one of the ISO 639 Alpha codes. Each module contains one or more 'cardinal' and 'ordinal' functions and a 'struct' function. The 'cardinal' functions directly convert cardinal numbers to a string-like representation of their spoken form. The 'ordinal' functions do the same but for ordinal numbers. The 'struct' functions convert numbers to a polymorphic representation of their grammatical structure. . The use of this package is best understood with some examples. First some English number names, both British and US variants: . >>> import qualified Text.Numeral.Language.EN as EN >>> EN.uk_cardinal defaultInflection 123 :: Maybe Text Just "one hundred and twenty-three" >>> EN.us_cardinal defaultInflection (10^50 + 42) :: Maybe Text Just "one hundred quindecillion forty-two" . French, which contains some traces of a base 20 system: . >>> import qualified Text.Numeral.Language.FR as FR >>> FR.cardinal defaultInflection (-99) :: Maybe Text Just "moins quatre-vingt-dix-neuf" . Conversions can fail. Alamblak, a language spoken by a few people in Papua New Guinea, has no representation for negative numbers: . >>> import qualified Text.Numeral.Language.AMP as AMP >>> AMP.cardinal defaultInflection (-3) :: Maybe Text Nothing . Some languages have multiple scripts and methods for writing number names. Take Chinese for example, which can be written using Han characters or transcribed to the Latin script using Pinyin. . Traditional Chinese characters: . >>> import qualified Text.Numeral.Language.ZH as ZH >>> ZH.trad_cardinal defaultInflection 123456 :: Maybe Text Just "十二萬三千四百五十六" . Simplified characters for use in financial contexts: . >>> ZH.finance_simpl_cardinal defaultInflection 123456 :: Maybe Text Just "拾贰万参仟肆伯伍拾陆" . Transcribed using Pinyin: . >>> ZH.pinyin_cardinal defaultInflection 123456 :: Maybe Text Just "shíèrwàn sānqiān sìbǎi wǔshí liù" . Using the 'struct' functions you can see the grammatical structure of number names. Because the results of these functions are polymorphic you need to specify a specific type. . >>> import qualified Text.Numeral.Language.NL as NL >>> NL.struct 123 :: Integer 123 >>> import Text.Numeral >>> NL.struct 123 :: Exp Add (Lit 100) (Add (Lit 3) (Mul (Lit 2) (Lit 10))) . Compare with: . >>> NL.cardinal defaultInflection 123 :: Maybe Text Just "honderddrieëntwintig" . 100 (honderd) + (3 (drie) + (ën) 2 (twin) * 10 (tig)) extra-source-files: ./README.markdown ------------------------------------------------------------------------------- source-repository head Type: git Location: git://github.com/roelvandijk/numerals.git ------------------------------------------------------------------------------- library hs-source-dirs: src ghc-options: -Wall build-depends: base >= 3.0.3.1 && < 4.7 , base-unicode-symbols >= 0.2.2 && < 0.3 , containers >= 0.4 && < 0.6 , containers-unicode-symbols >= 0.3 && < 0.4 , fingertree >= 0.0.1 && < 0.2 , text >= 0.11 && < 1.2 if impl(ghc >= 7.2.1) build-depends: integer-gmp >= 0.3 && < 0.6 exposed-modules: Text.Numeral , Text.Numeral.BigNum , Text.Numeral.Entry , Text.Numeral.Exp , Text.Numeral.Exp.Reified , Text.Numeral.Grammar , Text.Numeral.Grammar.Reified , Text.Numeral.Misc , Text.Numeral.Render , Text.Numeral.Rules , Text.Numeral.Language.Entries , Text.Numeral.Language.AF , Text.Numeral.Language.AMP , Text.Numeral.Language.BG , Text.Numeral.Language.CHN , Text.Numeral.Language.CHR , Text.Numeral.Language.CLM , Text.Numeral.Language.CS , Text.Numeral.Language.DE , Text.Numeral.Language.EN , Text.Numeral.Language.EO , Text.Numeral.Language.ES , Text.Numeral.Language.FI , Text.Numeral.Language.FR , Text.Numeral.Language.FUR , Text.Numeral.Language.GSW , Text.Numeral.Language.GV , Text.Numeral.Language.HE , Text.Numeral.Language.HOP , Text.Numeral.Language.IT , Text.Numeral.Language.JA , Text.Numeral.Language.LA , Text.Numeral.Language.LLD , Text.Numeral.Language.MG , Text.Numeral.Language.NL , Text.Numeral.Language.NO , Text.Numeral.Language.NQM , Text.Numeral.Language.OJ , Text.Numeral.Language.PDC , Text.Numeral.Language.PL , Text.Numeral.Language.PT , Text.Numeral.Language.RU , Text.Numeral.Language.SCO , Text.Numeral.Language.SV , Text.Numeral.Language.TR , Text.Numeral.Language.WO , Text.Numeral.Language.YOR , Text.Numeral.Language.ZH other-modules: Text.Numeral.Render.Utils ------------------------------------------------------------------------------- test-suite test-numerals type: exitcode-stdio-1.0 main-is: test.hs hs-source-dirs: src-test other-modules: Text.Numeral.Test , Text.Numeral.Language.ACH.TestData , Text.Numeral.Language.ADY.TestData , Text.Numeral.Language.AF.TestData , Text.Numeral.Language.AMP.TestData , Text.Numeral.Language.ARI.TestData , Text.Numeral.Language.AST.TestData , Text.Numeral.Language.AZ.TestData , Text.Numeral.Language.BA.TestData , Text.Numeral.Language.BG.TestData , Text.Numeral.Language.BM.TestData , Text.Numeral.Language.CA.TestData , Text.Numeral.Language.CAF.TestData , Text.Numeral.Language.CBK.TestData , Text.Numeral.Language.CHN.TestData , Text.Numeral.Language.CHR.TestData , Text.Numeral.Language.CLM.TestData , Text.Numeral.Language.CO.TestData , Text.Numeral.Language.COD.TestData , Text.Numeral.Language.COO.TestData , Text.Numeral.Language.CS.TestData , Text.Numeral.Language.CY.TestData , Text.Numeral.Language.DE.TestData , Text.Numeral.Language.DJK.TestData , Text.Numeral.Language.EN.TestData , Text.Numeral.Language.EO.TestData , Text.Numeral.Language.ES.TestData , Text.Numeral.Language.ET.TestData , Text.Numeral.Language.FI.TestData , Text.Numeral.Language.FO.TestData , Text.Numeral.Language.FR.TestData , Text.Numeral.Language.FUR.TestData , Text.Numeral.Language.GCF_MTQ.TestData , Text.Numeral.Language.GIL.TestData , Text.Numeral.Language.GL.TestData , Text.Numeral.Language.GSW.TestData , Text.Numeral.Language.GV.TestData , Text.Numeral.Language.HAI.TestData , Text.Numeral.Language.HE.TestData , Text.Numeral.Language.HOP.TestData , Text.Numeral.Language.HR.TestData , Text.Numeral.Language.HU.TestData , Text.Numeral.Language.HY.TestData , Text.Numeral.Language.IT.TestData , Text.Numeral.Language.JA.TestData , Text.Numeral.Language.KAP.TestData , Text.Numeral.Language.KEA.TestData , Text.Numeral.Language.LA.TestData , Text.Numeral.Language.LLD.TestData , Text.Numeral.Language.MG.TestData , Text.Numeral.Language.MOH.TestData , Text.Numeral.Language.NL.TestData , Text.Numeral.Language.NO.TestData , Text.Numeral.Language.NQM.TestData , Text.Numeral.Language.OJ.TestData , Text.Numeral.Language.PAA.TestData , Text.Numeral.Language.PDC.TestData , Text.Numeral.Language.PL.TestData , Text.Numeral.Language.PT.TestData , Text.Numeral.Language.RMN_DZA.TestData , Text.Numeral.Language.RO.TestData , Text.Numeral.Language.RU.TestData , Text.Numeral.Language.SCO.TestData , Text.Numeral.Language.SV.TestData , Text.Numeral.Language.TAR.TestData , Text.Numeral.Language.TR.TestData , Text.Numeral.Language.WO.TestData , Text.Numeral.Language.YOR.TestData , Text.Numeral.Language.ZAQ.TestData , Text.Numeral.Language.ZH.TestData , Text.Numeral.Language.ZPC.TestData ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N build-depends: base >= 3.0.3.1 && < 4.7 , base-unicode-symbols >= 0.2.2 && < 0.3 , HUnit >= 1.2.2 && < 1.3 , QuickCheck >= 2.4.2 && < 2.7 , test-framework >= 0.3.3 && < 0.9 , test-framework-hunit >= 0.2.6 && < 0.4 , test-framework-quickcheck2 >= 0.2.12 && < 0.4 , text >= 0.11 && < 1.2 , numerals if impl(ghc >= 7.2.1) build-depends: integer-gmp >= 0.3 && < 0.6