drmg17928 2011-06-11 04:23
浏览 50
已采纳

需要有关在PHP中扩展的指导

I have a class which makes use of regular expression for Natural Language Processing and the time spend processing the large amount of data it is fed does not look promising.

I'm looking into having it scaled out, have the means of doing things in parallel, which I have yet to have any experience of.

I was hoping someone could explain what I am trying to get myself into, pros and cons of doing this in php. Also if you could provide good resources on scaling in general or much better scaling in php. Thanks.

EDIT:

foreach ($sentences as $sentence) { 
  // for each sentence check if a keyword or any of its synonyms
  // appear together with any sentiment applicable to the keyword
  foreach ($this->keywords as $keyword => $synonyms) {              
    foreach ($this->sentiments[$keyword] as $sentiment => $weight) {
      $match = $this->check($sentence, $synonyms, $sentiment);
    }
  }
}

// regex part of the code
$keywords = implode('|', $keywords);
$pattern = "/(\b$sentiment\b(.*|\s)\b($keywords)\b|\b($keywords)\b(.*|\s)\b$sentiment\b)/i";

preg_match_all($pattern, $sentence, $matches);
  • 写回答

2条回答 默认 最新

  • duancashi1362 2011-06-11 05:11
    关注

    PHP may not be a great choice for that type of application. Its a rather high level language and with it comes overhead that may slow down any significant processing.

    Now if you want to stick to PHP, you can do it with some sort of job managing application. There may already be some applications you could use like gearman, or even hadoop. You break your data down into chunks and feed it to the application. With those tools you can scale your processing over one or more servers.

    If you use Amazon web services, you may want to look at Elastic Map Reduce and see if it fits your needs.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置