Keyword Matching project in-depth study-introduction of filters, in-depth study of filters-PHP Tutorial

Source: Internet
Author: User
Keyword Matching project in-depth research-introduction of filters, in-depth research of filters. Keyword Matching project in-depth research-introduction of filters, in-depth research of filter keyword matching project (I)-Introduction of filters at the beginning of this article, please first learn about the keyword matching Project in depth-introduction of filters, in-depth study of filters

Keyword Matching project (I)-Introduction of filters

When reading this article, please first learn how to teach you how to create a keyword matching Project (search engine) ---- day 1 ~ Teach you how to create a keyword matching Project (search engine) ---- 22nd days

Preface

After the code and test results were given, Shuai was asked to go online for a simple reason: everyone wants to contribute a little, and the welfare is indispensable. when we encounter things in the future, we will upgrade the meal later. the meal is very happy and satisfying. of course, our colleagues include Ding, Yu, the boss, director Wang.

Cause of the problem

With the running of the project, the application of keyword collection has become increasingly widespread. one day, Ding ran to find Shuai, who was very happy, but he heard the conversation later.

"Look, how are these words &,?, %, A lot of messy words are available, and these words are not very suitable. help me to see how to remove them ." Ding's eyes are also powerful enough, staring at handsome and straight trembling.

"Hello, big sister. let me check it out first. this is a package for me. then I will let you know ".

Shuai went back and checked and found many such strange words in the database. he was panic and had to find him again.

"Now the keywords in the dictionary contain &,?, % There are many such words, and these words are available based on the matching degree algorithm. what should we do ?".

After listening to Xiao Shuai's explanation, he came up with a solution. we controlled these keywords and we didn't want them to be written into the database, it not only reduces the number of keyword databases, but also ensures high keyword availability.

As soon as he heard it, the boss is different.

Solution

Adds a function that controls the input of the word source, the access to the rule, and the discarding of the filter that does not comply with the rule.

Design scheme

1 class Source { 2 3 public $keywords; 4 5 public function run() { 6 7 foreach ($this->keywords as $word) { 8 # code... 9 if(Filter::is($word)) continue;10 11 $keyword = new Keyword();12 $keyword->word = $word;13 $keyword->save();14 }15 }16 17 }

3. added the Filter code:

1
 

Summary

The code structure is good, and the new removal function is very simple, improving work efficiency. Shuai fell in love with this job.

Keywords matching project (I)-Introduction of filters first read this article...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.