The AhoCorasick package

[Tags: bsd3, library]

Aho-Corasick string matching algorithm.

See homepage for examples of usage: http://github.com/lymar/AhoCorasick


[Skip to ReadMe]

Properties

Versions0.0.1, 0.0.2, 0.0.3
Change logNone available
Dependenciesarray, base (==4.*), hashable, mtl, unordered-containers [details]
LicenseBSD3
CopyrightSergey S Lymar (c) 2012
AuthorSergey S Lymar <sergey.lymar@gmail.com>
MaintainerSergey S Lymar <sergey.lymar@gmail.com>
Stabilityexperimental
CategoryText
Home pagehttp://github.com/lymar/AhoCorasick
Bug trackerhttp://github.com/lymar/AhoCorasick/issues
Source repositoryhead: git clone http://github.com/lymar/AhoCorasick
UploadedFri Nov 9 05:36:49 UTC 2012 by SergeyLymar
DistributionsNixOS:0.0.3
Downloads806 total (26 in last 30 days)
Votes
0 []
StatusDocs uploaded by user
Build status unknown [no reports yet]

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for AhoCorasick-0.0.3

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")])