Lingua::ID::Words2Nums - Convert Indonesian verbage to number
This document describes version 0.17 of Lingua::ID::Words2Nums (from Perl distribution Lingua-ID-Words2Nums), released on 2015-09-03.
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
This module provides two functions, words2nums and words2nums_simple. They are the counterpart of Lingua::ID::Nums2Words's nums2words and nums2words_simple.
Convert Indonesian verbage to number.
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.
Arguments ('*' denotes required arguments):
str* => str
The verbage to convert.
Return value: (any)
Like words2nums, but can only parse sequence of digits.
In English, this is equivalent to converting "one two three" to 123.
None are exported by default, but they are exportable.
A regex for quickly matching/extracting number verbage from text; it looks for a string of words. It's not perfect (improper verbage might be allowed, e.g. "dua ribu tiga juta"), but it's convenient.
Currently only multipliers up to trillions ("triliun") are recognized. Bigger multipliers are usually only found in scientific text.
Parse::Number::ID is used to parse numbers in the verbage.
Please visit the project's homepage at https://metacpan.org/release/Lingua-ID-Words2Nums.
Source repository is at https://github.com/perlancar/perl-Lingua-ID-Words2Nums.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Lingua-ID-Words2Nums
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
This software is copyright (c) 2015 by email@example.com.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Lingua::ID::Words2Nums, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.