types

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: May 10, 2015 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package types contains common types useful to the inflect package.

Package types contains common types useful to the inflect package.

Package types contains common types useful to the inflect package.

Package types contains common types useful to the inflect package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IrregularType

type IrregularType struct {
	Singular string // The singular form of the irregular word.
	Plural   string // The plural form of the irregular word.
}

IrregularType provides a structure for irregular words that do not follow standard rules.

func Irregular

func Irregular(singular, plural string) (irregular *IrregularType)

Irregular if a factory method to a new IrregularType.

type IrregularsType

type IrregularsType []*IrregularType

IrregularsType defines a slice of pointers to IrregularType.

func (IrregularsType) IsIrregular

func (self IrregularsType) IsIrregular(str string) (*IrregularType, bool)

IsIrregular returns an IrregularType and bool if the IrregularsType slice contains the word.

type LanguageType

type LanguageType struct {
	Short            string           // The short hand form represention the language, ex. `en` (English).
	Pluralizations   RulesType        // Rules for pluralizing standard words.
	Singularizations RulesType        // Rules for singularizing standard words.
	Irregulars       IrregularsType   // Slice containing irregular words that do not follow standard rules.
	Uncountables     UncountablesType // Words that are uncountable, having the same form for both singular and plural.
}

LanguageType provides a structure for storing inflections rules of a language.

func Language

func Language(short string) (language *LanguageType)

Language if a factory method to a new LanguageType.

func (*LanguageType) Irregular

func (self *LanguageType) Irregular(singular, plural string) *LanguageType

Plural defines an irregular word for a langauge.

func (*LanguageType) Plural

func (self *LanguageType) Plural(matcher, replacer string) *LanguageType

Plural defines a pluralization rule for a language.

func (*LanguageType) Pluralize

func (self *LanguageType) Pluralize(str string) string

Pluralize converts the given string to the languages plural form.

func (*LanguageType) Singular

func (self *LanguageType) Singular(matcher, replacer string) *LanguageType

Plural defines a singularization rule for a language.

func (*LanguageType) Singularize

func (self *LanguageType) Singularize(str string) string

Singularize converts the given string to the languages singular form.

func (*LanguageType) Uncountable

func (self *LanguageType) Uncountable(uncountable string) *LanguageType

Plural defines an uncountable word for a langauge.

type RuleType

type RuleType struct {
	Regexp   *regexp.Regexp // The regular expression the rule must match.
	Replacer string         // The replacement to use if the RuleType's Regexp is matched.
}

RuleType provides a structure for pluralization/singularizations rules of a language.

func Rule

func Rule(matcher, replacer string) (rule *RuleType)

Rule if a factory method to a new RuleType.

type RulesType

type RulesType []*RuleType

RulesType defines a slice of pointers to RuleType.

type UncountablesType

type UncountablesType []string

UncountablesType is an array of strings

func (UncountablesType) Contains

func (self UncountablesType) Contains(str string) bool

Contains returns a bool if the str is found in the UncountablesType.

Jump to

Keyboard shortcuts

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