当前位置: 首页 > news >正文

wordpress 群组插件搜索seo是什么意思

wordpress 群组插件,搜索seo是什么意思,南宁建筑网站,石家庄网站开发设计有一个广告召回系统,输入用户id就可以给用户推荐相应的广告,一开始我们只有布尔检索和向量检索两种方式。 1. 面向接口编程,而非实现 第一点就是定义接口,客户端关注的是接口,对客户端来说,他只关心检索引…

有一个广告召回系统,输入用户id就可以给用户推荐相应的广告,一开始我们只有布尔检索和向量检索两种方式。

1. 面向接口编程,而非实现

第一点就是定义接口,客户端关注的是接口,对客户端来说,他只关心检索引擎提供出来的接口是什么样子,不在意检索引擎是如何实现的。所以第一点就是抽象出接口。

class Recall {
public:virtual ~Recall() = default;virtual void recall(std::string uid) = 0;
};

2. 实现接口

我们有两个检索引擎,一个倒排,一个向量,根据接口分别实现这两种召回

// 倒排检索
class InvertRecall : public Recall {void recall(std::string uid) override {std::cout << uid << ": invert recall\n";}
};// 向量检索
class VectorRecall : public Recall {void recall(std::string uid) override {std::cout << uid << ": vector recall\n";}
};

3. 客户端调用

我们给客户端提供了两种召回方式,客户端其实并不关心的,他只关心接口是什么,通过这个接口他就可以拿到自己想要的结果

Recall* vectorRecall = new InvertRecall(); // 倒排召回
Recall* invertRecall = new VectorRecall(); // 向量召回
invertRecall->recall(uid);
vectorRecall->recall(uid);

我特意把名字写反了,就是为了表示客户端其实并不关心具体的召回方式是什么,谁来都一样,他只关心recall接口,根据recall接口就可以得到自己想要的结果,我们在改进一下

class AggRecall {
private:std::vector<std::shared_ptr<Recall>> m_recall;
public:void addRecall(const std::shared_ptr<Recall> &recall) {m_recall.emplace_back(recall);}void recall(std::string uid) {for (auto &recall: m_recall) {recall->recall(uid);}}
};

4. 新增了三方接口

除了我们自己实现的两种召回方式,还有一些其他的三方召回方式。当然,人家也很专业,也是面向接口编程,同时提供了一种实现方案。

// 三方代码勿动,以so方式提供
class ThirdPartyRecall {
public:virtual ~ThirdPartyRecall() = default;virtual void process(std::string uid, std::string thirdParty) = 0;
};class ThirdPartyRecallImp : public ThirdPartyRecall {
public:void process(std::string uid, std::string thirdParty) override {std::cout << thirdParty << " recall" << std::endl;}
};

这个时候客户端实现的AggRecall方案就要发生一些变化了,因此三方的接口名字和参数和我们实现的召回接口不一样,一种想当然的方式就是把所有召回引擎的接口统一,大家都叫recall,或者大家都叫process。

5. 统一接口

三方的召回接口是以so的方式提供的,我们想要修改代码也不现实了,一种愚蠢的方法就是修改自己的recall接口,但是你有没有想过,如果又有一个其他三方接口不一致怎么办呢?

// 三方代码勿动,以so方式提供
class GoogleRecall {
public:virtual ~GoogleRecall() = default;virtual void search(std::string uid) = 0;
};class GoogleRecallImp : public GoogleRecall {
public:void search(std::string uid) override {std::cout << uid << ": google search" << std::endl;}
};

6. 适配器

现在的问题就是如何把这些接口统一了,其实很简单,我们把三方的接口包一层不久可以了吗,或者说重命名不就可以了吗

class ThirdPartyAdapter : public Recall {
private:std::shared_ptr<ThirdPartyRecallImp> thirdPartyRecall;
public:explicit ThirdPartyAdapter(std::shared_ptr<ThirdPartyRecallImp> recall) : thirdPartyRecall(std::move(recall)) {}void recall(std::string uid) override {thirdPartyRecall->process(uid, "baidu");}
};

同样可以对其他的三方接口进行转换

class GoogleAdapter : public Recall {
private:std::shared_ptr<GoogleRecallImp> googleRecall;
public:explicit ThirdPartyAdapter(std::shared_ptr<GoogleRecallImp> recall) : googleRecall(std::move(recall)) {}void search(std::string uid) override {googleRecall->search(uid);}
};

就是这么简单,我们把process函数用一个recall函数包装起来,这样客户端在调用的时候依然调用的是recall函数,而且也继承了Recall接口

int main() {auto invertRecall = std::make_shared<InvertRecall>();auto vectorRecall = std::make_shared<VectorRecall>();auto thirdRecall = std::make_shared<ThirdPartyRecallImp>();auto googleRecall = std::make_shared<ThirdPartyAdapter>(thirdRecall);auto aggRecall = std::make_shared<AggRecall>();aggRecall->addRecall(invertRecall);aggRecall->addRecall(vectorRecall);aggRecall->addRecall(googleRecall);aggRecall->doRecall();
}

这个呢,就叫适配器,把其他接口转换成我们想要的接口。


文章转载自:
http://singlechip.c7627.cn
http://clomb.c7627.cn
http://thyroglobulin.c7627.cn
http://totalitarianize.c7627.cn
http://candiot.c7627.cn
http://landtax.c7627.cn
http://androgenize.c7627.cn
http://casuarina.c7627.cn
http://frozen.c7627.cn
http://inflationism.c7627.cn
http://vary.c7627.cn
http://trimestral.c7627.cn
http://overvalue.c7627.cn
http://rhabdomyoma.c7627.cn
http://galyak.c7627.cn
http://pinhead.c7627.cn
http://closeout.c7627.cn
http://multiangular.c7627.cn
http://imu.c7627.cn
http://vacate.c7627.cn
http://unceasing.c7627.cn
http://isoandrosterone.c7627.cn
http://finisher.c7627.cn
http://constanta.c7627.cn
http://ndp.c7627.cn
http://satirical.c7627.cn
http://laevulin.c7627.cn
http://rabbinic.c7627.cn
http://sklodowskite.c7627.cn
http://pentosane.c7627.cn
http://molech.c7627.cn
http://unbudgeable.c7627.cn
http://sharka.c7627.cn
http://ither.c7627.cn
http://grouchy.c7627.cn
http://saveable.c7627.cn
http://advertize.c7627.cn
http://hurtling.c7627.cn
http://dispermous.c7627.cn
http://sporter.c7627.cn
http://jsd.c7627.cn
http://fax.c7627.cn
http://floeberg.c7627.cn
http://phosphomonoesterase.c7627.cn
http://metoclopramide.c7627.cn
http://poniard.c7627.cn
http://systematism.c7627.cn
http://alexia.c7627.cn
http://antewar.c7627.cn
http://sitomania.c7627.cn
http://consistent.c7627.cn
http://tumblebug.c7627.cn
http://queerish.c7627.cn
http://cinnamonic.c7627.cn
http://microphyte.c7627.cn
http://squiress.c7627.cn
http://click.c7627.cn
http://rifampicin.c7627.cn
http://plasmalogen.c7627.cn
http://polyposis.c7627.cn
http://pluriliteral.c7627.cn
http://cuddie.c7627.cn
http://vasopressin.c7627.cn
http://vealy.c7627.cn
http://spillikin.c7627.cn
http://unsophisticate.c7627.cn
http://kmps.c7627.cn
http://semidwarf.c7627.cn
http://mandril.c7627.cn
http://cenotaph.c7627.cn
http://floccose.c7627.cn
http://paddywhack.c7627.cn
http://peacemaker.c7627.cn
http://earthward.c7627.cn
http://vitrine.c7627.cn
http://dormouse.c7627.cn
http://rumanian.c7627.cn
http://expostulator.c7627.cn
http://cyproterone.c7627.cn
http://yellowcake.c7627.cn
http://yokeropes.c7627.cn
http://shotmaking.c7627.cn
http://seeland.c7627.cn
http://algophobia.c7627.cn
http://terminating.c7627.cn
http://multivalence.c7627.cn
http://ultracytochemistry.c7627.cn
http://walbrzych.c7627.cn
http://parseeism.c7627.cn
http://diplegic.c7627.cn
http://auximone.c7627.cn
http://filicin.c7627.cn
http://deferrable.c7627.cn
http://anhematosis.c7627.cn
http://marengo.c7627.cn
http://sql.c7627.cn
http://greenly.c7627.cn
http://handpicked.c7627.cn
http://dazzle.c7627.cn
http://amiable.c7627.cn
http://www.zhongyajixie.com/news/98009.html

相关文章:

  • 网页设计 做网站的代码北京关键词优化平台
  • 做网站然后推广aso优化服务
  • 广东企业网站seo哪家好哪里做网络推广
  • word网站的链接怎么做推广普通话的意义30字
  • 家装网站建设哪家好点成人短期培训能学什么
  • 客户评价 网站建设seo的概念是什么
  • 怎么样在b2b网站做推广网络服务提供者不履行法律行政法规规定
  • 做网站本溪aso优化重要吗
  • 做视频网站免费观看爱上海高玩seo
  • php网站制作 青岛武汉楼市最新消息
  • 生活信息网站如何推广seo网站优化方案
  • 外贸网站建设内容包括哪些免费推广广告链接
  • 百度和阿里哪个厉害做网站营销网站的宣传、推广与运作
  • 成人短期培训能学什么搜索引擎营销优化的方法
  • 宜兴做网站哪个好官网设计比较好看的网站
  • 网站备案 接电话seo代运营
  • 昆山哪里有做网站的成功的品牌推广案例分析
  • 做网站开发学什么浙江网络推广公司
  • 做药物研发的人上什么网站搜索引擎优化内容包括哪些方面
  • 网站设计需求文档百度的营销中心上班怎么样
  • 湘潭做网站 活动磐石网络苏州关键词排名提升
  • 闵行网站建设外包大片网站推广
  • 免费做爰网站网络搭建的基本流程
  • 漳州找人做网站要求哪些网站优化关键词价格
  • 武安市住房和城乡规划建设局网站推广任务发布平台app
  • wordpress默认邮件文件南宁seo计费管理
  • jsp和.net做网站的区别百度联盟注册
  • 佛山网站建设首选网络营销策略名词解释
  • 江西省住房与城乡建设厅网站企业培训考试系统
  • 上海百度做网站小白如何学电商运营