PHP Classes

PHP Aho-Corasick String Matching: Match string patterns using Aho-Corasick algorithm

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 201 All time: 8,459 This week: 105Up
Version License PHP version Categories
aho-corasick 0.1BSD License5.3Algorithms, PHP 5, Searching, Text pr...
Description 

Author

This class can match string patterns using the Aho-Corasick algorithm.

It can add several payload keys for the dictionary.

The class can match a given key text string and returns a list of all matches in a string separated by commas. An optional wildcard pattern text may be specified for the matching.

Picture of Chi H.
  Performance   Level  
Name: Chi H. <contact>
Classes: 28 packages by
Country: France France
Age: 39
All time rank: 34222 in France France
Week rank: 45 Up3 in France France Up
Innovation award
Innovation award
Nominee: 22x

Winner: 3x

Example

<?php
/***************************************************************
*
* (c) 2015 Chi Hoang (info@chihoang.de)
* All rights reserved
*
***************************************************************/

require_once ("ahocorasick.php");
//////////////////////////////
//$tree = new Ahocorasick\Ahocorasick();
//$tree->add ("a");
//$tree->add ("ab");
//$tree->add ("bab");
//$tree->add ("bc");
//$tree->add ("bca");
//$tree->add ("c");
//$tree->add ("caa");
//echo $tree->match ("abccab");

//////////////////////////////
//$tree = new Ahocorasick\ahocorasick();
//$tree->add ("bc");
//$tree->add ("abc");
//echo $tree->match ("tabc");

//////////////////////////////
//$tree = new Ahocorasick\Ahocorasick();
//$tree->add("ananas");
//$tree->add("antani");
//$tree->add("assassin");
//echo $tree->match("banananassata");

//////////////////////////////
//$tree = new Ahocorasick\ahocorasick();
//$tree->add("he");
//$tree->add("she");
//$tree->add("his");
//$tree->add("hers");
//echo $tree->match("ushers");

/////////////////////////////
//$tree = new Ahocorasick\Ahocorasick();
//$tree->add("bot");
//$tree->add("otis");
//$tree->add("ott");
//$tree->add("otto");
//$tree->add("tea");
//echo $tree->match("botttea");


//$tree = new Ahocorasick\Ahocorasick();
//$tree->add("fast");
//$tree->add("sofa");//$tree = new Ahocorasick\Ahocorasick();
//$tree->add("fast");
//$tree->add("sofa");
//$tree->add("so");
//$tree->add("take");
//echo $tree->match("takesofasofastfassofatakesossosofastakeso");
//$tree->add("so");
//$tree->add("take");
//echo $tree->match("takesofasofastfassofatakesossosofastakeso");

//$tree = new Ahocorasick\Ahocorasick();
//$tree->add("one");
//$tree->add("two");
//$tree->add("three");
//$tree->add("four");
//echo $tree->match("Hey one! How are you?");

//$tree = new Ahocorasick\Ahocorasick();
//$tree->add("hi");
//$tree->add("hips");
//$tree->add("hip");
//$tree->add("hit");
//$tree->add("chip");
//echo $tree->match("microchips");

//$tree = new Ahocorasick\Ahocorasick();
//$tree->add("ab");
//$tree->add("bc");
//$tree->add("bab");
//$tree->add("d");
//$tree->add("abcde");
//echo $tree->match("xbabcdex");

//$tree = new Ahocorasick\Ahocorasick();
//$tree->add("The");
//$tree->add("han");
//$tree->add("and");
//$tree->add("pork");
//$tree->add("port");
//$tree->add("pot");
//$tree->add("ha");
//$tree->add("e");
//echo $tree->match("The pot had a handle");

//$tree = new Ahocorasick\Ahocorasick();
//$tree->add("mercury");
//$tree->add("venus");
//$tree->add("earth");
//$tree->add("mars");
//$tree->add("jupiter");
//$tree->add("saturn");
//$tree->add("uranus");
//$tree->add("pluto");
//echo $tree->match("XXearthXXvenusaturnXXmarsaturn","ea*turn");

//$tree = new Ahocorasick\Ahocorasick();
//$tree->add("say");
//$tree->add("she");
//$tree->add("shr");
//$tree->add("he");
//$tree->add("her");
//echo $tree->match("yasherhs");

$tree = new Ahocorasick\Ahocorasick();
$tree->add("AC");
$tree->add("GTG");
$tree->add("AACT");
//////echo $tree->match("ACCGAGTGCGTGGACAAACTACGATTGTGGAATGAACT");
echo $tree->match("ACCGAGTGCGTGGACAAACTACGATTGTGGAATGAACT","AC*GT");

?>


  Files folder image Files  
File Role Description
Plain text file ahocorasick.php Class main class
Accessible without login Plain text file example.php Example example class
Accessible without login Plain text file unittest.php Test unittest class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:201
This week:0
All time:8,459
This week:105Up