ahocorasick

package
v0.0.0-...-a4a72b7 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayUnion

func ArrayUnion(to, from []int) (concat []int)

ArrayUnion Concats two arrays of int's into one.

func BoolArrayCapUp

func BoolArrayCapUp(old []bool) (new []bool)

BoolArrayCapUp Dynamically increases an array size of bool's by 1.

func BuildAc

func BuildAc(p []string) (acToReturn map[int]map[uint8]int, f map[int][]int, s []int)

Functions that builds Aho Corasick automaton.

func BuildExtendedAc

func BuildExtendedAc(p []string) (acToReturn map[int]map[uint8]int, f map[int][]int)

BuildExtendedAc Functions that builds extended Aho Corasick automaton.

func ComputeAlphabet

func ComputeAlphabet(p []string) (s string)

ComputeAlphabet Function that returns string of all the possible characters in given patterns.

func ConstructTrie

func ConstructTrie(p []string) (trie map[int]map[uint8]int, stateIsTerminal []bool, f map[int][]int)

ConstructTrie Function that constructs Trie as an automaton for a set of reversed & trimmed strings.

func Contains

func Contains(s []int, e int) bool

Contains Returns 'true' if array of int's 's' contains int 'e', 'false' otherwise.

func CreateNewState

func CreateNewState(state int, at map[int]map[uint8]int)

CreateNewState Automaton function for creating a new state 'state'.

func CreateTransition

func CreateTransition(fromState int, overChar uint8, toState int, at map[int]map[uint8]int)

CreateTransition Creates a transition for function σ(state,letter) = end.

func GetParent

func GetParent(state int, at map[int]map[uint8]int) (uint8, int)

GetParent Function that finds the first previous state of a state and returns it. Used for trie where there is only one parent.

func GetTransition

func GetTransition(fromState int, overChar uint8, at map[int]map[uint8]int) (toState int)

GetTransition Returns ending state for transition σ(fromState,overChar), '-1' if there is none.

func GetWord

func GetWord(begin, end int, t string) string

GetWord Function that returns word found in text 't' at position range 'begin' to 'end'.

func IntArrayCapUp

func IntArrayCapUp(old []int) (new []int)

IntArrayCapUp Dynamically increases an array size of int's by 1.

func StateExists

func StateExists(state int, at map[int]map[uint8]int) bool

StateExists Checks if state 'state' exists. Returns 'true' if it does, 'false' otherwise.

Types

type Result

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

Result structure to hold occurrences

func Advanced

func Advanced(t string, p []string) Result

Advanced Function performing the Advanced Aho-Corasick algorithm. Finds and prints occurrences of each pattern.

func AhoCorasick

func AhoCorasick(t string, p []string) Result

AhoCorasick Function performing the Basic Aho-Corasick algorithm. Finds and prints occurrences of each pattern.

Jump to

Keyboard shortcuts

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