Skip to content

Go library for plurals of nouns, ordinalize numbers, parameterize/transliterate/camelize/underscore strings, convert numbers to words and more

License

Notifications You must be signed in to change notification settings

martinusso/inflect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inflect

Circle CI Build Status Coverage Status GoDoc Go Report Card

Installing

go get

$ go get -u github.com/martinusso/inflect

Using

IntoWords()

IntoWords convert numbers (float64) to words

func IntoWords(number float64) string 
got := IntoWords(42)  // -> forty-two
got := IntoWords(-147)  // -> Minus one hundred and forty-seven

IsConsonant

IsConsonant check if a character is a consonant

func IsConsonant(s string) bool

IsVowel

IsVowel check if a character is a vowel

func IsVowel(s string) bool

Ordinal

Ordinal returns the ordinal suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th...

func Ordinal(number int) string
got := Ordinal(-1)  // -> st
got := Ordinal(42)  // -> nd

Ordinalize

Ordinalize turns a number into an ordinal string

func Ordinalize(number int) string
got := Ordinal(-1)  // -> -1st
got := Ordinal(42)  // -> 42nd

Parameterize

Parameterize replaces special characters in a pretty string

func Parameterize(s string) string
got := Parameterize("J. R. R. Tolkien")  // -> "j-r-r-tolkien"

ParameterizeSep

ParameterizeSep replaces special characters, according to the separator, in a string

func ParameterizeSep(s, sep string) string
got := ParameterizeSep("J. R. R. Tolkien", "_")  // -> "j_r_r_tolkien"

Pluralize

Pluralize generates the plurals of nouns

func Pluralize(word string) string
got := Plural("word") // -> words
got := Plural("noun") // -> nouns

License

This software is open source, licensed under the The MIT License (MIT). See LICENSE for details.

About

Go library for plurals of nouns, ordinalize numbers, parameterize/transliterate/camelize/underscore strings, convert numbers to words and more

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages