prefixmatcher

package
v0.13.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: Apache-2.0, Apache-2.0 Imports: 1 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL