Example #1
0
func newMatcher(d *dict, s string) (*matcher, error) {
	if d.inflator == nil {
		return nil, errors.New("Dictionary is not loaded")
	}
	m := &matcher{
		options: defaultMatcherOptions,
		trie:    trie.NewTernaryTrie(),
	}
	// Inflate s word, add those to trie.
	ch := d.inflator.Inflate(s)
	for w := range ch {
		m.add(w)
	}
	m.trie.Balance()
	return m, nil
}
Example #2
0
func New() *Dict {
	return &Dict{
		trie:     trie.NewTernaryTrie(),
		balanced: false,
	}
}
Example #3
0
func New() *Matcher {
	return &Matcher{
		trie: trie.NewTernaryTrie(),
	}
}
Example #4
0
func New() *Converter {
	return &Converter{
		trie:     trie.NewTernaryTrie(),
		balanced: false,
	}
}