Discover Packages
github.com/kmulvey/humannumbers
package
module
Version:
v0.3.0
Opens a new window with list of versions in this module.
Published: May 26, 2024
License: MIT
Opens a new window with license information.
Imports: 3
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
README
¶
humannumbers
Convert numbers in the form of words to float64
Example:
var number, err = humannumbers.Parse("three million eight hundred and ninety four thousand seven hundred and sixty five")
// number == 3,894,765.0
Limitations
How it works
input: "three million eight hundred ninety four thousand seven hundred five"
Remove unnecessary words (and)
if there are decimals, just smash them together behind a '.' and add it to the result of below
Parse each word into a number (int)
[]int{3, 1e6, 8, 100, 90, 4, 1000, 7, 100, 5}
Go though this array and apply rules for addition and multiplication
result: float64(3_894_705)
Expand ▾
Collapse ▴
Documentation
¶
Parse takes a string containing numbers in the form
of words, currently only English, and converts it
to float64. Examples:
two
forty three
eight thousand
eight hundred and six
one thousand six hundred and forty
two thousand three hundred and eighty seven
two hundred and forty six thousand three hundred and eighty seven.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.