humannumbers

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 3 Imported by: 0

README

humannumbers

Build codecov Go Report Card Go Reference

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

  • English Only

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)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(humanString string) (int, error)

Parse takes an english string containing numbers in the form of words and converts it to an integer. Examples: forty three, two hundred and forty six thousand three hundred and eighty seven.

func ParseFloat added in v0.4.0

func ParseFloat(humanString string) (float64, error)

ParseFloat takes an english string containing numbers in the form of words and converts it to float64. Examples: forty three, two hundred and forty six thousand three hundred and eighty seven.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL