ahocorasick

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: MIT Imports: 1 Imported by: 0

README

Aho-Corasick Automaton

Aho-Corasick Multi-pattern Matching Algorithm for Golang

Example:

package main

import (
	"fmt"
	ahocorasick "github.com/HansenH/Aho-Corasick"
)

func main() {
	dictionary := []string{"hello", "world", "世界", "google", "golang", "c++", "love", " ", "l", "!!"}
	s := "hello世界, hello google, hello world, I love golang!!!"
	ac := ahocorasick.NewACAutomaton(dictionary)
	fmt.Println(ac.FindAllIndex(s))
}

Output:

map[ :[12 18 26 32 39 41 46] !!:[53 54] golang:[47] google:[19] hello:[0 13 27] l:[42] love:[42] world:[33] 世界:[5]]

LICENSE

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ACAutomaton

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

func NewACAutomaton

func NewACAutomaton(dictionary []string) *ACAutomaton

Construct the Model with a certain dictionary

func (*ACAutomaton) FindAllIndex

func (m *ACAutomaton) FindAllIndex(s string) map[string][]int

Search all the matched positions of all patterns

Jump to

Keyboard shortcuts

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