Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/taoso/php-aho
A php extension for the multifast's Aho–Corasick algorithm. Only Support PHP 7.
https://github.com/taoso/php-aho
Last synced: 9 days ago
JSON representation
A php extension for the multifast's Aho–Corasick algorithm. Only Support PHP 7.
- Host: GitHub
- URL: https://github.com/taoso/php-aho
- Owner: taoso
- License: apache-2.0
- Created: 2016-07-17T16:02:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-25T15:05:02.000Z (over 7 years ago)
- Last Synced: 2024-11-11T08:38:58.084Z (2 months ago)
- Language: C
- Homepage:
- Size: 33.2 KB
- Stars: 1
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# php-aho
php-aho is a PHP Extension for the [multifast](http://multifast.sourceforge.net/)'s [Aho–Corasick algorithm](https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_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:
```ini
[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 :).