AhoCorasick: Aho-Corasick string matching algorithm

[ bsd3, library, text ] [ Propose Tags ] [ Report a vulnerability ]

Aho-Corasick string matching algorithm.

See usage examples in Text.AhoCorasick.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.0.1, 0.0.2, 0.0.3, 0.0.4
Change log CHANGELOG.md
Dependencies array, base (>=4 && <5), hashable, mtl, unordered-containers [details]
Tested with ghc ==9.4.5
License BSD-3-Clause
Copyright Sergey S Lymar (c) 2012
Author Sergey S Lymar <sergey.lymar@gmail.com>
Maintainer Karl Ostmo <kostmo@gmail.com>
Category Text
Home page http://github.com/kostmo/AhoCorasick
Bug tracker http://github.com/kostmo/AhoCorasick/issues
Source repo head: git clone http://github.com/kostmo/AhoCorasick
Uploaded by kostmo at 2023-10-14T19:42:28Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 3860 total (36 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-10-14 [all 1 reports]

Readme for AhoCorasick-0.0.4

[back to package description]

AhoCorasick

Aho-Corasick string matching algorithm.

Installation

cabal update
cabal install AhoCorasick

Examples

Simplest example

example1 = mapM_ print $ findAll simpleSM "ushers" where
    simpleSM = makeSimpleStateMachine ["he","she","his","hers"]
Position {pIndex = 1, pLength = 3, pVal = "she"}
Position {pIndex = 2, pLength = 2, pVal = "he"}
Position {pIndex = 2, pLength = 4, pVal = "hers"}

With data

example2 = mapM_ print $ findAll sm "ushers" where
    sm = makeStateMachine [("he",0),("she",1),("his",2),("hers",3)]
Position {pIndex = 1, pLength = 3, pVal = 1}
Position {pIndex = 2, pLength = 2, pVal = 0}
Position {pIndex = 2, pLength = 4, pVal = 3}

Step-by-step state machine evaluation

example3 = mapM_ print $ next sm "ushers" where
    sm = makeSimpleStateMachine ["he","she","his","hers"]
    next _ [] = []
    next sm (s:n) = let (SMStepRes match nextSM) = stateMachineStep sm s in
        (s, match) : next nextSM n
('u',[])
('s',[])
('h',[])
('e',[(3,"she"),(2,"he")])
('r',[])
('s',[(4,"hers")])