mspm

module
Version: v0.0.0-...-2e8956b Latest Latest
Warning

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

Go to latest
Published: May 19, 2018 License: BSD-3-Clause

README

Multi-String Pattern Matching algorithm.

Go Report Card GoDoc

This implementation is inspired from Aho-Corasick algorithm

Getting Started

modelA = mspm.NewModel("mspm_model_A")
patternsToSearch = strings.NewReader(words) // words is newline seperated list of words/keywords

// build mspm model with patterns
modelA.Build(patternsToSearch)

inputString := "input document where the above pattern is searched for."
document := strings.NewReader(inputString)
output, err := modelA.MultiTermMatch(document)

// output ~= [{matched_word: n_count}, ..]

Test Coverage

TrieNode vs TrieHashNode benchmark

$ cd github.com/BlackRabbitt/mspm/ds/trie
$ go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/BlackRabbitt/mspm/ds/trie
BenchmarkTrieNodeInsert-4             500000          2582 ns/op
BenchmarkTrieNodeSearch-4           10000000           205 ns/op
BenchmarkTrieHashNodeInsert-4        1000000          1491 ns/op
BenchmarkTrieHashNodeSearch-4       10000000           206 ns/op
PASS
ok      github.com/BlackRabbitt/mspm/ds/trie	8.795s

Resources

  1. Trie
  2. mspm - Multi-String Pattern Matching algorithm. Generally used for Information Retrieval.
  3. Aho-Corasick algorithm

Directories

Path Synopsis
ds
trie
Package trie provides trie datastructure
Package trie provides trie datastructure
Package mspm provides model that will have collection of trieNodes that represent the patterns to be searched in a document.
Package mspm provides model that will have collection of trieNodes that represent the patterns to be searched in a document.

Jump to

Keyboard shortcuts

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