Help us shape the future of Go! Take the 2026 Go Developer Survey

ahocorasick

package module
v0.0.0-...-5d2fc27 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2017 License: BSD-3-Clause Imports: 6 Imported by: 0

README

ahocorasick

A Golang implementation of the Aho-Corasick string matching algorithm

Documentation

Index

Constants

View Source
const (
	EnumHitTypeNone = iota // none, match时不支持此选项

	EnumHitTypeWord //[]int 命中的单词index

	EnumHitTypeWordCount //map[string]int  命中单词的数量

	EnumHitTypeWordIndex //map[string][]int  命中单词的位置

	EnumHitTypeIndexWord //map[int]string  内容中命中次的index以及内容
)

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) 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

func (*Matcher) Re2

func (m *Matcher) Re2(in string, replacer string) string

benchmark

func (*Matcher) Replace

func (m *Matcher) Replace(inStr string, replacerStr string, isReplace bool, hitType int) (string, interface{}, error)

Jump to

Keyboard shortcuts

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