NAME

Parse::Number::ID - Parse number from Indonesian text

VERSION

This document describes version 0.08 of Parse::Number::ID (from Perl distribution Parse-Number-ID), released on 2015-09-03.

SYNOPSIS

use Parse::Number::ID qw(parse_number_id);

my @a = map {parse_number_id(text=>$_)}
    ("12.345,67", "-1,2e3", "x123", "1.23");
# @a = (12345.67, -1200, undef, 1.23)

DESCRIPTION

The goal of this module is to parse/extract numbers commonly found in Indonesian text. It currently parses numbers according to Indonesian rule of decimal- and thousand separators ("," and "." respectively) as well as English ("." and ","), since English numbers are more widespread and sometimes mixed within.

12.3     # 12.3
12.34    # 12.34
12.345   # 12345

In the future this module might also parse fractions (e.g. 1/3, 2 1/2) and percentages (e.g. 1,2%).

This module does not parse numbers that are written as Indonesian words, e.g. "seratus dua puluh tiga" (123). See Lingua::ID::Words2Nums and Regexp::ID::NumVerbage for that.

FUNCTIONS

parse_number_id(%args) -> any

Parse number from Indonesian text.

Arguments ('*' denotes required arguments):

  • text* => str

    The input text that contains number.

Return value: (any)

VARIABLES

None are exported by default, but they are exportable.

$Pat (regex)

A regex for quickly matching/extracting number from text. It's not 100% perfect (the extracted number might not be valid), but it's simple and fast.

FAQ

How does this module differ from other number-parsing modules?

This module uses a single regex and provides the regex for you to use. Other modules might be more accurate and/or faster. But this module is pretty fast.

Also, since English text are often found in Indonesian text, parsing English numbers (which uses periods for decimals and commas for thousand separators instead of the other way around) is also done, as long as it is not ambiguous.

SEE ALSO

Lingua::ID::Words2Nums

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Parse-Number-ID.

SOURCE

Source repository is at https://github.com/perlancar/perl-Parse-Number-ID.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Parse-Number-ID

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.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by perlancar@cpan.org.

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