teach you to do keyword matching project (search engine)----22nd day, teach you to do the 22nd day _php Tutorial

Source: Internet
Author: User
Tags split words

teach you to do keyword matching project (search engine)----22nd day, teach you to do 22nd day


The latest interview experience: Interview Feelings (ii), interview feelings

Latest Architectures: Architecture applications for high concurrency data acquisition (Redis applications)

Spit Groove: Today is also just adjust the mentality, continue to write before the completion of the article, the recent months of their own recuperation for a period of time, go home to do labor, but also as a workout to exercise their body, after all, anything can not be returned to your health, I am also recommended to do IT industry handsome buddies more activities of your other parts.

22nd Day

Starting point: teach you to do keyword matching project (search engine)----first day

Review: Hand-taught you to do keyword matching project (search engine)----21st Day

Small handsome is willing to do summary of the person, according to the knowledge he had learned, he summed up the following:

1. The problem of the extension and type of the attributes of the baby has been well controlled, but there are still a lot of obstacles to the promotion and operation of maintenance.

2. The use of SCWS extension and their own native business-splitting scheme, the split words effectively solved the difficulty of matching the phrase.

3. All the initial work seems to have been completed, only the final finishing of the project should be able to formally run up.

Small handsome active consciousness is strong, he did not ask the eldest brother, he wrote a code, the code is mainly in order to connect all the steps together.

Baby properties of the extended charlist of the building please refer to: Hand-taught you to do keyword matching project (search engine)----12th Day ~ Hand teach you to do keyword matching project (search engine)----18th Day

Selector main steps are as follows:

1. Get the baby properties.

2. Use business knowledge to expand Baby attributes to form charlist

3. Get keywords from the thesaurus

4. Keyword splitting algorithm

5. Matching degree algorithm

6. Returns the list of keywords on the match

The code is as follows:

1 
 Php2 #@Filename: selector/selector.php3 #@Author: Oshine4 5 require_once dirname(__file__) . '/selectoritem.php ';6 require_once dirname(__file__) . '/charlist/charlist.php ';7 require_once dirname(__file__) . '/charlist/charlisthandle.php ';8 require_once dirname(dirname(__file__)) . '/lib/logger.php ';9 Ten classSelector One { A  -     Private Static $charListHandle=Array( -"Blacklist" = "Backlistcharlisthandle", the"Synonyms" = "Linklistcharlisthandle" -     ); -  -      Public Static functionSelect$num _iid) +     { -         $selectorItem= Selectoritem::createfromapi ($num _iid); +  ALogger::trace ($selectorItem-props_name); at  -         $charlist=NewCharList (); -  -         foreach(Self::$charListHandle  as $matchKey=$className) { -  -             $handle= Self::createcharlisthandle ($className,$charlist,$selectorItem); in             $handle-exec(); -  to         } +  -         $selectWords=Array(); the  *         $keywords= Db::makearray ("Select Word from keywords"); $         foreach($keywords  as $val) {Panax Notoginseng             #code ... -             $keywordEntity= Splitterapp::Split($val["word"]); the              +                 #code ... A             if(Macthexector::macth ($keywordEntity,$charlist)){ the                 $selectWords[] =$val["word"]; +             }            -  $         } $  -         return $selectWords; -     } the  -      Public Static functionCreatecharlisthandle ($className,$charlist,$selectorItem)Wuyi     { the         if(class_exists($className)) { -             return New $className($charlist,$selectorItem); Wu         } -         Throw New Exception("Class not exists", 0); About     } $}

For test-driven code programming, refer to:

Also use the same principle, first write the test code well, follow-up full Matchexector code.

Matchexector main function calculates the matching degree.

1. If there is only one word in the blacklist, the matching degree must be zero.

2. If it is the core word, then according to the previously mentioned algorithm to calculate, please refer to: teach you to do keyword matching project (search engine)----19th Day

1 
 Php2 #@Filename: mathes/matchexector.php3 #@Author: Oshine4 5 classMatchexector {6 7      Public Static functionMatch (keywordentity$keywordEntity, CharList$charlist){8 9         $matchingDegree= 0;Ten         $elementWords=$keywordEntity-getelementwords (); One         foreach($elementWords  as $word) { A             #code ... -             if(In_array($word,$charlist-getblacklist ())) -                 return false; the             if(In_array($word,$charlist-Getcore ())) -                 $matchingDegree+=$keywordEntity->calculateweight ($word); -  -         } +  -         if($matchingDegree>0.8) +             return true; A         return false; at  -     } -      -}

The whole code is relatively capable of doing that, and little handsome is very happy because the project was completed and there was definitely a bonus for the project, and maybe there was a meal full of dinner,

Think about it all started drooling.

Small handsome the code to the eldest brother, waiting for the boss of the final affirmation.

What happens when the boss looks at it? Please follow the third chapter: Key words matching project in-depth study (i)

Chapter Two is finished, source code address: teach you to do keyword matching project (Chapter two end)

http://www.bkjia.com/PHPjc/931389.html www.bkjia.com true http://www.bkjia.com/PHPjc/931389.html techarticle Hand- taught you to do keyword matching project (search engine)----22nd day, teach you to do the 22nd day of the latest interview experience: Interview Feelings (ii), the interview of the latest structure ...

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