ahocorasick

package module
v0.0.0-...-3496d9d Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: BSD-3-Clause Imports: 1 Imported by: 0

README

ahocorasick

A Golang implementation of the Aho-Corasick string matching algorithm.

This is a fork of CloudFlare's ahocorasick package, modified to return all matches of all keywords, and the exact index at which they were found in the text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hit

type Hit struct {
	// The index in the original dict of the keyword that was found.
	Index int
	// The start index in the text where the keyword was found.
	TextIndex int
}

Hit describes a match.

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) []Hit

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

Jump to

Keyboard shortcuts

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