ahocorasick

package module
v0.0.0-...-054963e Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: BSD-3-Clause Imports: 3 Imported by: 82 modules, 65 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

ahocorasick

A Golang implementation of the Aho-Corasick string matching algorithm

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Matcher

type Matcher struct {
	// contains filtered or unexported fields
}

Matcher is returned by NewMatcher and contains a list of blices to match against

func NewMatcher

func NewMatcher(dictionary [][]byte) *Matcher

NewMatcher creates a new Matcher used to match against a set of blices

func NewStringMatcher

func NewStringMatcher(dictionary []string) *Matcher

NewStringMatcher creates a new Matcher used to match against a set of strings (this is a helper to make initialization easy)

func (*Matcher) Contains

func (m *Matcher) Contains(in []byte) bool

Contains returns true if any string matches. This can be faster than Match() when you do not need to know which words matched.

func (*Matcher) Match

func (m *Matcher) Match(in []byte) []int

Match searches in for blices and returns all the blices found as indexes into the original dictionary.

This is not thread-safe method, seek for MatchThreadSafe() instead.

func (*Matcher) MatchThreadSafe

func (m *Matcher) MatchThreadSafe(in []byte) []int

MatchThreadSafe provides the same result as Match() but does it in a thread-safe manner. Uses a sync.Pool of haystacks to track the uniqueness of the result items.

Jump to

Keyboard shortcuts

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