PHP Classes

File: sqlite_fulltextsearchex.class.php

Recommend this page to a friend!
  Classes of Filippo Toso   SQLite Full Text Search   sqlite_fulltextsearchex.class.php   Download  
File: sqlite_fulltextsearchex.class.php
Role: Class source
Content type: text/plain
Description: Extended class with exponential word prominence calculation
Class: SQLite Full Text Search
Add Full Text Search SQL commands to SQLite
Author: By
Last change: Added the code of wordpreparation method
Date: 18 years ago
Size: 1,114 bytes
 

Contents

Class file image Download
<?php

require_once (dirname (__FILE__) . '/sqlite_fulltextsearch.class.php');

class
sqlite_fulltextsearchex extends sqlite_fulltextsearch {

    var
$striptags = false;

    function
sqlite_fulltextsearchex () {
       
parent::sqlite_fulltextsearch ();
       
$this->striptags = false;
    }

   
/* override */
   
function prominence ($position, $string_words_count, $against_words_count) {
       
// exponential prominence
       
return (($position * $position) / $string_words_count);
    }

   
/* override */
   
function wordspreparation (&$string, &$against) {
        if (
$this->striptags) {
           
$string = preg_replace ('/<script.*?\>.*?<\/script>/si', ' ', $string);
           
$string = preg_replace ('/<style.*?\>.*?<\/style>/si', ' ', $string);
           
$string = preg_replace ('/<.*?\>/si', ' ', $string);
           
$string = html_entity_decode ($string);
       
           
$against = preg_replace ('/<script.*?\>.*?<\/script>/si', ' ', $against);
           
$against = preg_replace ('/<style.*?\>.*?<\/style>/si', ' ', $against);
           
$against = preg_replace ('/<.*?\>/si', ' ', $against);
           
$against = html_entity_decode ($against);
        }
    }

}

?>