Custom Full-Text Search Against Stopwords Too Particular Characters Using Php Too Mysql
I'm non certain if this is the best way.
To construct clean I expire the information through this class, all it does is strip out whatsoever especial characters, together with a listing of halt words that I don't desire to include inwards searches:
To construct clean I expire the information through this class, all it does is strip out whatsoever especial characters, together with a listing of halt words that I don't desire to include inwards searches:
<?php shape Cleaner { var $stopwords = array(" detect ", " well-nigh ", " me ", " e'er ", " each ", " update ", " delete ", " add together ", " insert ", " where ", " i ", " a ", " my ");//you quest to extend this big time. var $symbols = array('/','\\','\'','"',',','.','<','>','?',';',':','[',']','{','}','|','=','+', '-','_',')','(','*','&','^','%','$','#','@','!',' ','`'); constituent parseString($string) { $string = ' '.$string.' '; $string = $this->removeStopwords($string); $string = $this->removeSymbols($string); provide $string; } constituent removeStopwords($string) { for ($i = 0; $i < sizeof($this->stopwords); $i++) { $string = str_replace($this->stopwords[$i],' ',$string); } provide trim($string); } constituent removeSymbols($string) { for ($i = 0; $i < sizeof($this->symbols); $i++) { $string = str_replace($this->symbols[$i],' ',$string); } provide trim($string); } }Source : http://stackoverflow.com/a/9082165 Sumber http://developer-paradize.blogspot.com
Comments
Post a Comment