NAME

Lingua::ID::Words2Nums - Convert Indonesian verbage to number

VERSION

version 0.14

SYNOPSIS

use Lingua::ID::Words2Nums qw(words2nums words2nums_simple);

print words2nums("seratus tiga koma dua");  # 103.2
print words2nums("minus 3 juta 100 ribu");  # 3100000
print words2nums("1,605 jt");               # 1605000 (abbreviations accepted)
print words2nums("-1.3e4");                 # 13000

print words2nums_simple("satu dua tiga");   # 123

DESCRIPTION

This module provides two functions, words2nums and words2nums_simple. They are the counterpart of Lingua::ID::Nums2Words's nums2words and nums2words_simple.

VARIABLES

None are exported by default, but they are exportable.

$Pat (REGEX)

A regex for quickly matching/extracting verbage from text; it looks for a string of words. It's not perfect (the extracted verbage might not be valid, e.g. "ribu tiga"), but it's simple and fast.

FUNCTIONS

None are exported, but they are exportable.

words2nums(STR) => NUM|undef

Parse Indonesian verbage and return number, or undef if failed (unknown verbage or 'syntax error'). In English, this is equivalent to converting "one hundred and twenty three" to 123. Currently can handle real numbers in normal and scientific form in the order of hundreds of trillions.

Will produce unexpected result if you feed it stupid verbage.

words2nums_simple(STR) => NUM|undef

Like words2nums, but can only handle spelled digits (like "one two three" => 123 in English).

SEE ALSO

Lingua::ID::Nums2Words

Parse::Number::ID is used to parse numbers in the verbage.

AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Steven Haryanto.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.