Words2Nums(3)
π¦ Lingua::EN::Words2Nums β Words2Nums(3) π¦
okay bestie, welcome to the User Contributed Perl Documentation page for Lingua::EN::Words2Nums β manual name Words2Nums(3) π
. This one is lowkey iconic: it takes English text and turns it into numbers, and itβs giving βmath but make it textβ β¨.
π NAME π
Lingua::EN::Words2Nums β convert English text to numbers π
πΈ SYNOPSIS πΈ
use Lingua::EN::Words2Nums;
$num=words2nums("two thousand and one");
$num=words2nums("twenty-second");
$num=words2nums("15 billion, 6 million, and nintee");
π DESCRIPTION π
This module converts English text into numbers. It supports both ordinal and cardinal numbers, negative numbers, and very large numbers. Periodt. π
The main subroutine, which is exported by default, is words2nums(). Feed it a string and it will attempt to convert it into a number. If it succeeds, the number will be returned. If it fails, it returns undef β no cap, thatβs the deal π.
π VARIABLES π
There are a number of variables that can be used to tweak the behavior of this module. For example, debugging can be enabled by setting $Lingua::EN::Words2Nums::debug=1 π. These are your lilβ knobs, bestie:
$Lingua::EN::Words2Nums::debugβ Default:0. If set to a true value, outputs on standard error some useful messages if parsing fails for some reason. So when parsing is doing a whole mystery era, this tells you whatβs up π.$Lingua::EN::Words2Nums::billionβ Default:10 ** 9. This is the number that will be returned for"one billion". It defaults to the American version; the English will want to set it to10 ** 12. Setting this number automatically changes all the larger numbers (trillion, quadrillion, etc) to match. Big-number behavior? Automatically upgraded π«.
π§ NOTES π§
vibe check on the edge cases:
- It does not understand decimals or fractions, yet. π Thatβs the whole note; donβt come for me.
- Scores are supported, eg:
"four score and ten". So are dozens. So is a bakerβs dozen. And a gross. Math with range, honestly π―. - Various mispellings of numbers are understood. π«Ά Itβs forgiving like that.
- While it handles
googolcorrectly,googolplexis too large to fit inperl's standard scalar type, and"inf"will be returned. π Thatβs the limit, bestie.
π AUTHOR π
Copyright 2001-2003 Joey Hess <joey@kitenet.net> π
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. π«Ά
mwah π β this pageβs source/version is perl v5.42.0, its date is 2014-12-02, and the manual is Words2Nums(3). Byeeee β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Lingua-EN-Words2Nums 0.18-bp160.1.11 Β· GPL-1.0+ or Artistic-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms