Skip to content
/ php-aho Public

A php extension for the multifast's Aho–Corasick algorithm. Only Support PHP 7.

License

Notifications You must be signed in to change notification settings

taoso/php-aho

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-aho

php-aho is a PHP Extension for the multifast's Aho–Corasick algorithm.

Installation

phpize
./configure
make
sudo make install

API overview

define int aho_match(string $subject, &$matches) method.

Usage

Enable php-aho and set dict path in the ini file:

[aho]
extension=aho.so
aho.dict=/tmp/foo.dict

An example dict is like this:

apple`fruit
china`nation
smile`emotion

Use the ` as the separator.

And then:

Psy Shell v0.7.2 (PHP 7.0.8 — cli) by Justin Hileman
>>> aho_match ('apple from china make me smile', $matches)
=> 3
>>> $matches
=> [
     [
       0,        # keyword offset
       "apple",  # keyword
       "fruit",  # keyword type
     ],
     [
       11,
       "china",
       "nation",
     ],
     [
       25,
       "smile",
       "emotion",
     ],
   ]

Enjoy yourself :).

About

A php extension for the multifast's Aho–Corasick algorithm. Only Support PHP 7.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages