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

Source: Internet
Author: User
Teach you how to create a keyword matching Project (search engine) ---- 13th days, teach you how to do 13th days. Teach you how to create a keyword matching Project (search engine) ---- 13th days, teach you how to do 13th days 13th days since Shuai was replaced by a large number of old people, my heart is very uncomfortable, because you are taught to do keyword matching projects (search engines) ---- 13th days, and 13th days

13th days

Since Shuai was replaced by a large number of elders, he was very upset because of the following reason: I have already done what you want, why not be sure.

What kind of programmers are excellent? Shuai understands the design mode with such questions.

Although he has read the design pattern many times and even memorized the name of the design pattern, the singleton pattern, the abstract Factory pattern, the builder pattern, the factory pattern, and the prototype pattern....

But he still doesn't know how to use it. he has to ask the boss again. The boss gave him a piece of code to show him what design mode he used.

What kind of programmers are excellent? Some people say that good programmers write code that can be read, while ordinary programmers write code that can be run.

Yu's code is as follows:

 Item = $ item;} public function _ get ($ name) {if (isset ($ this-> item-> $ name )) {return $ this-> item-> $ name;} return null;} public static function createFromApi ($ num_iid) {$ client = new TopClient (); $ client-> appkey = 'XX'; $ client-> secretKey = 'XX'; $ req = new ItemGetRequest (); $ req-> setFields ('Props _ name, property_alias, detail_url, cid, TITLE'); $ req-> setNumIid ($ num_iid); $ resp = $ client-> execute ($ req ); If (isset ($ resp-> code) {# error handle throw new Exception ($ resp-> msg, $ resp-> code );} return new self ($ resp-> item) ;}} class CharList {private $ core = array (); private $ blacklist = array (); public function addCore ($ char) {if (! In_array ($ char, $ this-> core) $ this-> core [] = $ char;} public function getCore () {return $ this-> core ;} public function addBlacklist ($ char) {if (! In_array ($ char, $ this-> blacklist) $ this-> blacklist [] = $ char;} public function getBlacklist () {return $ this-> blacklist ;}} abstract class CharListHandle {protected $ charlist; public function _ construct ($ charlist) {$ this-> charlist = $ charlist;} abstract function exec ();} class MenCharListHandle extends CharListHandle {public function exec () {$ this-> charlist-> addCore ("men's wear "); $ this-> charlist-> addBlacklist ("female") ;}} class WomenCharListHandle extends CharListHandle {public function exec () {$ this-> charlist-> addCore ("women's wear"); $ this-> charlist-> addBlacklist ("male ");}} # Other CharList Handle completion class Selector {private static $ charListHandle = array ("men's wear" => "MenCharListHandle", "women's wear" => "WomenCharListHandle ", "Couples" => "LoversCharListHandle", "kids clothes" => "ChildrenCharListHandle"); public static function select ($ num_iid) {$ selectorItem = SelectorItem: createFromApi ($ num_iid ); logger: trace ($ selectorItem-> props_name); $ matchTitle = $ selectorItem-> title. $ selectorItem-> props_name; $ charlist = new CharList (); foreach (self: $ charListHandle as $ matchKey => $ className) {if (preg_match ("/$ matchKey/", $ matchTitle) {$ handle = self: createCharListHandle ($ className, $ charlist ); $ handle-> exec () ;}// do search things} public static function createCharListHandle ($ className, $ charlist) {if (class_exists ($ className )) {return new $ className ($ charlist);} throw new Exception ("class not exists", 0 );}}

After reading the code, Shuai can no longer afford it. this is the legendary boss, and it is not copied from my code...

If the boss heard the thoughts of Shuai, what would he do?

Shuai can't continue to study the secret of magical power.




NLP (search engine) ---- 13th days, teach you to do 13th days 13th days since Shuai was replaced by a large number of old people, my heart is very upset, because there is...

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.