Jump to content

ECHO STOP WORDS BEFORE ENTER TO DB


williamh69

Recommended Posts

Hi guys, thank so much for all your help. I have this question: I have a two tables one is a content text, and the other one there are the stop words. I would like to match my content with those stop words and echo them, before submit to db.

  content                    stopwords

content_id                    words

content

 

any suggestion thank you

Link to comment
Share on other sites

i found this class to use it

<?php 
class Cleaner {

    var $stopwords = array(" find ", " about ", " me ", " ever ", " each ", " update ", " delete ", " add ", " insert ",
 " where ", " i ", " a ", " my ");//you need to extend this big time.

    var $symbols = array('/','\\','\'','"',',','.','<','>','?',';',':','[',']','{','}','|','=','+',
'-','_',')','(','*','&','^','%','$','#','@','!','~','`');

    function parseString($string) {
        $string = ' '.$string.' ';
        $string = $this->removeStopwords($string);
        $string = $this->removeSymbols($string);
        return $string;
    }

    function removeStopwords($string) {
        for ($i = 0; $i < sizeof($this->stopwords); $i++) {
            $string = str_replace($this->stopwords[$i],' ',$string);
        }

        return trim($string);
    }

    function removeSymbols($string) {
        for ($i = 0; $i < sizeof($this->symbols); $i++) {
            $string = str_replace($this->symbols[$i],' ',$string);
        }

        return trim($string);
    }
}
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.