PHP Classes

PHP Fast Pattern Matching: Match text patterns using ternary tries

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
StarStarStarStar 64%Total: 480 All time: 5,947 This week: 673Up
Version License PHP version Categories
fastpm 0.1Free for non-comm...5.0Algorithms, PHP 5, Searching, Text pr...
Description 

Author

This package can match text patterns using ternary tries.

The main class can add text strings as symbol keys and it builds a ternary trie.

The class can also take a key string to match by searching the ternary trie. It returns an array with all the matches.

Innovation Award
PHP Programming Innovation award nominee
February 2015
Number 4


Prize: One year server license IP to country, region, city, latitude, longitude, ZIP code, time zone, area code database
Text pattern matching is a process of determining if a given text string contains sequences of characters that match a given pattern.

In PHP text pattern matching can be done using regular expressions and the preg extension.

This class provides a pure PHP approach for implementing text pattern matching by the use ternary tries.

Manuel Lemos
Picture of Chi H.
  Performance   Level  
Name: Chi H. <contact>
Classes: 28 packages by
Country: France France
Age: 39
All time rank: 34122 in France France
Week rank: 286 Up8 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 ( "fastpm.php" );

//////////////////////////////
//$tree = new Fastpm\Fastpm ();
//$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 Fastpm\Fastpm ();
//$tree->add ("bc");
//$tree->add ("abc");
//echo $tree->match("tabc");

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

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

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

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

?>


  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example example script
Plain text file fastpm.php Class Main class
Accessible without login Plain text file unittest.php Test Unit Test

 Version Control Unique User Downloads Download Rankings  
 0%
Total:480
This week:0
All time:5,947
This week:673Up
 User Ratings  
 
 All time
Utility:81%StarStarStarStarStar
Consistency:81%StarStarStarStarStar
Documentation:-
Examples:81%StarStarStarStarStar
Tests:75%StarStarStarStar
Videos:-
Overall:64%StarStarStarStar
Rank:709