Documentation ¶
Index ¶
- Variables
- func Clean(input string) string
- func CleanToken(input string) string
- func IsLower(s string) bool
- func IsTitle(s string) bool
- func IsUpper(s string) bool
- func LoadModels(dirname string) (map[string]Model, error)
- func SaveModel(m Model, path string, basename string) error
- func ToSameCase(s string, like string) string
- type DictDefinition
- type DictModel
- type Generator
- type MarkovDefinition
- type MarkovModel
- func (m *MarkovModel) Generate(seed string) string
- func (m *MarkovModel) MarshalJSON() ([]byte, error)
- func (m *MarkovModel) Recognize(input string) float64
- func (m *MarkovModel) Train(input string)
- func (m *MarkovModel) UnmarshalJSON(b []byte) error
- func (m *MarkovModel) Validate(md MarkovDefinition) error
- type MatchDefinition
- type MatchModel
- type Model
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidModel = fmt.Errorf(`Mismatch between model configuration and persisted model.`)
Functions ¶
func Clean ¶
Clean returns the lower-case representation of input with whitespace trimmed and normalized to a single 0x20 (SPC) character.
func CleanToken ¶
CleanToken calls Clean on input, then removes all non-alphanumeric characters from it. The result is useful for seeding a PRNG in a way that disregards punctuation and case.
func ToSameCase ¶
Converts s to the same case as like. Handles upper, lower, and title case.
Types ¶
type DictDefinition ¶
type DictDefinition struct { }
type DictModel ¶
type DictModel struct {
// contains filtered or unexported fields
}
func NewDictModel ¶
func NewDictModel() *DictModel
func (*DictModel) MarshalText ¶
func (*DictModel) UnmarshalText ¶
type MarkovDefinition ¶
type MarkovModel ¶
type MarkovModel struct {
// contains filtered or unexported fields
}
func NewMarkovModel ¶
func NewMarkovModel(order int, separator string) *MarkovModel
func (*MarkovModel) Generate ¶
func (m *MarkovModel) Generate(seed string) string
Generate derives a random string deterministically from the seed. The length is guaranteed to be between the min and max lengths seen during training.
func (*MarkovModel) MarshalJSON ¶
func (m *MarkovModel) MarshalJSON() ([]byte, error)
func (*MarkovModel) Recognize ¶
func (m *MarkovModel) Recognize(input string) float64
func (*MarkovModel) Train ¶
func (m *MarkovModel) Train(input string)
func (*MarkovModel) UnmarshalJSON ¶
func (m *MarkovModel) UnmarshalJSON(b []byte) error
func (*MarkovModel) Validate ¶
func (m *MarkovModel) Validate(md MarkovDefinition) error
type MatchDefinition ¶
type MatchDefinition struct{}
type MatchModel ¶
type MatchModel struct {
// contains filtered or unexported fields
}
func NewMatchModel ¶
func NewMatchModel(patterns []*regexp.Regexp) *MatchModel
func (*MatchModel) MarshalText ¶
func (m *MatchModel) MarshalText() ([]byte, error)
func (*MatchModel) Recognize ¶
func (m *MatchModel) Recognize(input string) float64
func (*MatchModel) Train ¶
func (m *MatchModel) Train(input string)
func (*MatchModel) UnmarshalText ¶
func (m *MatchModel) UnmarshalText(b []byte) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.