This section is empty.


This section is empty.


This section is empty.


type Leafs

type Leafs []*PlainLeaf

    sorter interface

    func (Leafs) Len

    func (slice Leafs) Len() int

    func (Leafs) Less

    func (slice Leafs) Less(i, j int) bool

    func (Leafs) Swap

    func (slice Leafs) Swap(i, j int)

    type PlainLeaf

    type PlainLeaf struct {
    	Value    string
    	Category string
    	Weight   float64

    func (*PlainLeaf) String

    func (m *PlainLeaf) String() string

    type Trie

    type Trie struct {
    	// contains filtered or unexported fields

    func LoadFromFile

    func LoadFromFile(fname string) (tr *Trie, err error)

      LoadFromFile loads a gib encoded wordlist from a file and creates a new Trie by Add()ing all of them.

      func New

      func New() *Trie

        NewTrie returns the pointer to a new Trie with an initialized root Branch

        func (*Trie) Add

        func (t *Trie) Add(val, cat string, w float64)

          Add adds an entry to the trie

          func (*Trie) Find

          func (t *Trie) Find(prefix string) Leafs

            Find returns all entries of the Trie that have the given prefix with their counts as Leaf sorted by weights

            func (*Trie) FindFirstN

            func (t *Trie) FindFirstN(prefix string, n int) Leafs

              FindFirstN returns first N results for given prefix sorted by weights

              func (*Trie) SaveToFile

              func (t *Trie) SaveToFile(fname string) (err error)

                SaveToFile dumps all values into a slice of strings and writes that to a file using encoding/gob.

                The Trie itself can currently not be encoded directly because gob does not directly support structs with a sync.Mutex on them.