Teach you how to create a keyword matching Project (search engine) ---- 22nd days, teach you how to do 22nd days _ PHP Tutorial

Source: Internet
Author: User
Teach you how to create a keyword matching Project (search engine) ---- 22nd days, teach you how to do 22nd days. Teach you how to create a keyword matching Project (search engine) ---- 22nd days, teach you how to do the latest interview experience on 22nd days: interview feelings (2) interview experience the latest architecture hands-on teaches you how to do keyword matching projects (search engines)-22nd days, teach you how to do 22nd days

Latest interview experience: interview feelings (2) interview feelings

Latest architecture: High-concurrency data collection architecture application (Redis application)

Tucao: Today, I have just adjusted my mind and continued to write unfinished articles. I have been taking a rest for some time in the past few months. I have worked hard to go home, IT can also be used to exercise your own health. after all, nothing can be changed back to your health. I also recommend that you be a handsome guy in the IT industry to engage in other activities.

22nd days

Start point: Teach you how to create a keyword matching Project (search engine) ---- day 1

Review: experts teach you how to perform keyword matching projects (search engines)-21st days

Shuai is a person who is happy to make a summary. based on his previous knowledge, he summarized the following:

1. the expansion and type of baby attributes have been well controlled, but there are still many obstacles to promotion and operation maintenance.

2. scws extension and native business Word splitting solutions are used for keyword splitting, effectively solving the difficulty of phrase matching.

3. all the initial work seems to have been completed. you only need to organize the project to be officially run.

Shuai has a strong sense of initiative. he did not ask the boss, but he wrote the code by himself. the code is mainly used to connect all the steps.

For details about how to build the CharList extension for baby attributes, refer to: how to teach you how to create a keyword matching Project (search engine) ---- 12th days ~ Teach you how to create a keyword matching Project (search engine) ---- 18th days

The main steps of Selector are as follows:

1. get the baby attributes.

2. use business knowledge to expand baby attributes to form CharList

3. obtain keywords from the dictionary

4. keyword splitting algorithm

5. matching algorithm

6. return the list of matched keywords.

The code is as follows:

1
 "BacklistCharListHandle", 15 "synonyms" => "LinklistCharListHandle" 16); 17 18 public static function select ($ num_iid) 19 {20 $ selectorItem = SelectorItem :: createFromApi ($ num_iid); 21 22 Logger: trace ($ selectorItem-> props_name); 23 24 $ charlist = new CharList (); 25 26 foreach (self :: $ charListHandle as $ matchKey => $ className) {27 28 $ handle = self: createCharListHandle ($ className, $ charlist, $ selectorItem); 29 $ handle-> exec (); 30 31} 32 33 $ selectWords = array (); 34 35 $ keywords = DB: makeArray ("select word from keywords"); 36 foreach ($ keywords as $ val) {37 # code... 38 $ keywordEntity = SplitterApp: split ($ val ["word"]); 39 40 # code... 41 if (MacthExector: macth ($ keywordEntity, $ charlist) {42 $ selectWords [] = $ val ["word"]; 43} 44 45} 46 47 return $ selectWords; 48} 49 50 public static function createCharListHandle ($ className, $ charlist, $ selectorItem) 51 {52 if (class_exists ($ className )) {53 return new $ className ($ charlist, $ selectorItem); 54} 55 throw new Exception ("class not exists", 0); 56} 57}

For test-driven code programming, see:

The same principle is also used. First, write the test code and then complete the MatchExector code.

MatchExector is mainly used to calculate the matching degree.

1. if there is a word in the blacklist, the matching degree must be zero.

2. if it is a core word, you can calculate it based on the algorithm mentioned earlier. for details, refer to: Teach you how to create a keyword matching Project (search engine) ---- 19th days.

 1 
 getElementWords();11         foreach ($elementWords as $word) {12             # code...13             if(in_array($word, $charlist->getBlacklist()))14                 return false;15             if(in_array($word, $charlist->getCore()))16                 $matchingDegree+=$keywordEntity->calculateWeight($word);17 18         }19 20         if($matchingDegree>0.8)21             return true;22         return false;23 24     }25     26 }

The entire code has relatively implemented this function, and Shuai is very happy, because the project is completed and the project bonus is indispensable, maybe there is a rich dinner,

I think it's getting drool.

Shuai handed the code to the boss, waiting for the boss's final affirmation with expectation.

What will the boss do after reading it? Please pay attention to Chapter 3: in-depth research on keyword matching project (I)

Chapter 2 is complete, and the source code address: Teach you how to perform keyword matching projects (Chapter 2 is complete)

Tips (search engine) ---- 22nd days, teach you to do the latest interview experience in 22nd days: interview feelings (2), interview feelings about the latest architecture...

Related 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.