Natural Language Processing of Integer Values
I just pushed my most recent changes to NaturalNum - a python library for natural language representation of integer values. E.g. usage:
$ python example.py 123456 en_GB [‘one’, ‘hundred’, ‘and’, ’twenty’, ’three’, ’thousand’, ‘four’, ‘hundred’,‘and’, ‘fifty’, ‘six’] $ python example.py 123456 fr_FR [‘cent’, ‘vingt’, ’trois’, ‘mille’, ‘quatre’, ‘cent’, ‘cinquante’, ‘six’]
Currently, only English and French are supported, for values up to hundreds of thousands. More languages will be added as inspiration strikes. The library can be downloaded from github. I stress that the implementation is a Proof of Concept, and is not a shining example of best practices. Really, it took far too much work to parse and validate the rules. I didn’t want to write a full-blown DSL as I thought the requirements were fairly simple. In future, I would not attempt this kind of thing with manually hand-crafted code. There is heavy use of regexps for validation, and it is probably quite hard to understand what the code is doing. Pyparsing could perhaps yield an alternative implementation. NaturalNum NaturalNum is a python module for easy conversion of numeric values to natural language, with full internationalization. E.g. “2100” can be mapped to “two thousand one hundred”, “deux mille cent”, “2.wav,1000.wav,1.wav,100.wav”, or any other representation, according to rules-based configuration. Quick Start The script example.py provides an example usage of the library, allowing command line evaluation of natural language. E.g.: