André Fernandes dos Santos > Text-Math-NumExp-0.01_12 > Text::Math::NumExp

Download:
Text-Math-NumExp-0.01_12.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.01_12   Source  

NAME ^

Text::Math::NumExp - Text::Math::NumExp - Find numeric expressions in text.

VERSION ^

version 0.01_12

SYNOPSIS ^

 use Text::Math::NumExp;
 
 my $text = "Light travels at 3x10[8] m/s."
 norm_numexp($text); 
 # "Light travels at 3x10^8 m/s."

 $text = "The program used for the amplification was as follows: 
                5 min at 94°C, followed by 50 cycles consisting of 30s 
                at 94°C, 30s at 62°C, and 30s at 72°C";

 find_numexp($text);

 # [ { length => 1, offset =>  54, text => 5,           value => 5     },
 #   { length => 2, offset =>  63, text => 94,          value => 94    },
 #   { length => 2, offset =>  81, text => 50,          value => 50    },
 #   { length => 9, offset => 105, text => "30s at 94", value => undef },
 #   { length => 9, offset => 119, text => "30s at 62", value => undef },
 #   { length => 9, offset => 137, text => "30s at 72", value => undef },
 # ] 
 
 $text = "One plus one equals two.";
 find_numwords($text);
 
 # [ { length => 3, offset =>  0, text => "One", value => 1 },
 #   { length => 3, offset =>  9, text => "one", value => 1 },
 #   { length => 3, offset => 20, text => "two", value => 2 },
 # ] 

DESCRIPTION ^

This module searches for numbers and numeric expressions in a text, including:

- numbers (e.g 30.000, 3.4, -20)
- spelled-out numbers (e.g. "one million", "three")
- complex numeric expressions (e.g. 1.5x10^-5)

SUBROUTINES/METHODS ^

find_numexp

Finds numeric expressions in text.

find_numwords

Finds spelled-out numbers in text.

solve

Returns the value of a numerical expression. Retuns undef if expression is not solvable.

norm_numexp

Normalizes common numerical expression patterns (including Unicode characters).

AUTHOR ^

Andre Santos <andrefs@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2012 by Andre Santos.

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

syntax highlighting: