Documentation
¶
Overview ¶
Package dictionary provides utilities for working with dictionary words.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultDictionaryNotFound is an error returned when the default system dictionary // cannot be found or loaded. DefaultDictionaryNotFound = errors.New("Unable to find default dictionary") )
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface {
// Contains determines if the provided word is contained within the dictionary.
Contains(string) bool
// Words returns a slice of all of the words contained in the dictionary.
Words() []string
}
Interface defines the interface that all dictionaries implement.
func Filter ¶
Filter creates a new dictionary only containing words for which filterFunc returns true.
type PrefixTree ¶
type PrefixTree struct {
Valid bool
// contains filtered or unexported fields
}
PrefixTree is a prefix tree/trie implementation that can be constructed from a dictionary.Interface.
func BuildPrefixTree ¶
func BuildPrefixTree(d Interface) *PrefixTree
BuildPrefixTree contructs a new prefix tree from the provided dictionary.
func (*PrefixTree) Contains ¶
func (t *PrefixTree) Contains(word string) bool
Contains returns true if the provided word is contained within the prefix tree.
func (*PrefixTree) Insert ¶
func (t *PrefixTree) Insert(s string)
Insert inserts a new word into the prefix tree.
func (*PrefixTree) Next ¶
func (t *PrefixTree) Next(c rune) *PrefixTree
Next returns a new prefix tree, rooted at the next character.
func (*PrefixTree) Words ¶
func (t *PrefixTree) Words() (words []string)
Words returns a slice of all words contained within the prefix tree.