Documentation ¶
Overview ¶
Package fakeword allows to generate fake words. Adding words of a certain language, allows to generate language like words.
Index ¶
Examples ¶
Constants ¶
View Source
const (
// MaxSequencesDefault contains the default for Generator.MaxSequences.
MaxSequencesDefault = 2
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dictionary ¶
type Dictionary struct { PrefixLength int // contains filtered or unexported fields }
Dictionary stores words to be used to create a Generator.
func (*Dictionary) Add ¶
func (w *Dictionary) Add(words ...string) *Dictionary
Add words to a Dictionary.
func (*Dictionary) Generator ¶
func (w *Dictionary) Generator() Generator
Generator returns a new Generator based on the words added to the dictionary.
func (*Dictionary) Read ¶
func (w *Dictionary) Read(in io.Reader) *Dictionary
Read from an io.Reader and adds those words to a Dictionary. Lines prefixed with # are skipped.
type Generator ¶
type Generator struct { // Probabilities stores the probabilities of characters following on a string. Probabilities map[string]map[string]float32 // MaxSequences defines how far back the algorithm looks // to predict the next character. A smaller value icreases randomness // and a higher value creates words that are closer to the dictionary words. // The default value is defined in MaxSequencesDefault. MaxSequences int // Random should return a 32-bit value as a uint32. // Uses math/rand/v2's Uint32 if Random is nil. Random func() uint32 }
Generator allows to generate fake words.
func (Generator) Word ¶
Word generates a fake word with arbitrary length.
Example ¶
package main import ( "fmt" "thde.io/fakeword" ) func main() { words := []string{ "Psychotomimetic", "Pulchritudinous", "Consanguineous", "Trichotillomania", } dict := fakeword.Dictionary{} dict.Add(words...) gen := dict.Generator() fmt.Println(gen.Word()) }
Output:
Click to show internal directories.
Click to hide internal directories.