Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PrefixMatcher ¶
type PrefixMatcher struct {
// contains filtered or unexported fields
}
PrefixMatcher helps find longest prefixes. See [FindPrefixLen].
func NewFromSet ¶
func NewFromSet(vocab map[string]bool) *PrefixMatcher
NewFromSet creates a new PrefixMatcher from a set of strings tha represent the vocabulary.
func (*PrefixMatcher) FindPrefixLen ¶
func (pm *PrefixMatcher) FindPrefixLen(text string) int
FindPrefixLen finds the longest prefix of text that matches a vocabulary word, and returns it. If 0 is returned, no prefix was found.
Click to show internal directories.
Click to hide internal directories.