numerizer

package module
v0.0.0-...-026cdc6 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2015 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Go Numerizer

Numerizer is a library to help with parsing numbers in natural language from strings (ex forty two). It's a straight port of the Numerizer gem https://github.com/jduff/numerize.

Installation

$ go get github.com/dcu/go-numerizer

Usage

import("github.com/dcu/go-numerizer")

Numerizer.numerize('forty two') // "42"
Numerizer.numerize('two and a half') // "2.5"
Numerizer.numerize('three quarters') // "3/4"
Numerizer.numerize('two and three eighths') // "2.375"

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BIG_PREFIXES = bigPrefixes{
		NewBigPrefix("hundred", "100"),
		NewBigPrefix("thousand", "1000"),
		NewBigPrefix("million", "1000000"),
		NewBigPrefix("billion", "1000000000"),
		NewBigPrefix("trillion", "1000000000000"),
	}
)
View Source
var (
	DIRECT_NUMS = directNumbers{
		newDirectNumber("eleven", "11"),
		newDirectNumber("twelve", "12"),
		newDirectNumber("thirteen", "13"),
		newDirectNumber("fourteen", "14"),
		newDirectNumber("fifteen", "15"),
		newDirectNumber("sixteen", "16"),
		newDirectNumber("seventeen", "17"),
		newDirectNumber("eighteen", "18"),
		newDirectNumber("nineteen", "19"),
		newDirectNumber("ninteen", "19"),
		newDirectNumber("zero", "0"),
		newDirectNumber("ten", "10"),
		newDirectNumber("\ba[\b^$]", "1"),
	}
)
View Source
var (
	DIRECT_ORDINALS = directOrdinals{
		newDirectOrdinal("tenth", "10"),
		newDirectOrdinal("eleventh", "11"),
		newDirectOrdinal("twelfth", "12"),
		newDirectOrdinal("thirteenth", "13"),
		newDirectOrdinal("fourteenth", "14"),
		newDirectOrdinal("fifteenth", "15"),
		newDirectOrdinal("sixteenth", "16"),
		newDirectOrdinal("seventeenth", "17"),
		newDirectOrdinal("eighteenth", "18"),
		newDirectOrdinal("nineteenth", "19"),
		newDirectOrdinal("twentieth", "20"),
		newDirectOrdinal("thirtieth", "30"),
		newDirectOrdinal("fourtieth", "40"),
		newDirectOrdinal("fiftieth", "50"),
		newDirectOrdinal("sixtieth", "60"),
		newDirectOrdinal("seventieth", "70"),
		newDirectOrdinal("eightieth", "80"),
		newDirectOrdinal("ninetieth", "90"),
	}
)
View Source
var (
	FRACTIONS = fractions{
		newFraction("half", "2"),
		newFraction("third(s)?", "3"),
		newFraction("fourth(s)?", "4"),
		newFraction("quarter(s)?", "4"),
		newFraction("fifth(s)?", "5"),
		newFraction("sixth(s)?", "6"),
		newFraction("seventh(s)?", "7"),
		newFraction("eighth(s)?", "8"),
		newFraction("nineth(s)?", "9"),
	}
)
View Source
var (
	SINGLE_NUMS = singleNumbers{
		newSingleNumber("one", "1"),
		newSingleNumber("two", "2"),
		newSingleNumber("three", "3"),
		newSingleNumber("four", "4"),
		newSingleNumber("five", "5"),
		newSingleNumber("six", "6"),
		newSingleNumber("seven", "7"),
		newSingleNumber("eight", "8"),
		newSingleNumber("nine", "9"),
	}
)
View Source
var (
	SINGLE_ORDINALS = singleOrdinals{
		newSingleOrdinal("first", "1"),
		newSingleOrdinal("third", "3"),
		newSingleOrdinal("fourth", "4"),
		newSingleOrdinal("fifth", "5"),
		newSingleOrdinal("sixth", "6"),
		newSingleOrdinal("seventh", "7"),
		newSingleOrdinal("eighth", "8"),
		newSingleOrdinal("ninth", "9"),
	}
)
View Source
var (
	TEN_PREFIXES = tenPrefixes{
		newTenPrefix("twenty", "20"),
		newTenPrefix("thirty", "30"),
		newTenPrefix("forty", "40"),
		newTenPrefix("fourty", "40"),
		newTenPrefix("fifty", "50"),
		newTenPrefix("sixty", "60"),
		newTenPrefix("seventy", "70"),
		newTenPrefix("eighty", "80"),
		newTenPrefix("ninety", "90"),
	}
)

Functions

func NewBigPrefix

func NewBigPrefix(name string, value string) *bigPrefix

func Numerize

func Numerize(text string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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