当前位置: 首页>>代码示例>>PHP>>正文


PHP SearchEngine::normalizeText方法代码示例

本文整理汇总了PHP中SearchEngine::normalizeText方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchEngine::normalizeText方法的具体用法?PHP SearchEngine::normalizeText怎么用?PHP SearchEngine::normalizeText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SearchEngine的用法示例。


在下文中一共展示了SearchEngine::normalizeText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getNormalizedTitle

 /**
  * Get a normalized string representation of a title suitable for
  * including in a search index
  *
  * @param SearchEngine $search
  * @return string A stripped-down title string ready for the search index
  */
 private function getNormalizedTitle(SearchEngine $search)
 {
     global $wgContLang;
     $ns = $this->title->getNamespace();
     $title = $this->title->getText();
     $lc = $search->legalSearchChars() . '&#;';
     $t = $wgContLang->normalizeForSearch($title);
     $t = preg_replace("/[^{$lc}]+/", ' ', $t);
     $t = $wgContLang->lc($t);
     # Handle 's, s'
     $t = preg_replace("/([{$lc}]+)'s( |\$)/", "\\1 \\1's ", $t);
     $t = preg_replace("/([{$lc}]+)s'( |\$)/", "\\1s ", $t);
     $t = preg_replace("/\\s+/", ' ', $t);
     if ($ns == NS_FILE) {
         $t = preg_replace("/ (png|gif|jpg|jpeg|ogg)\$/", "", $t);
     }
     return $search->normalizeText(trim($t));
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:25,代码来源:SearchUpdate.php

示例2: normalizeText

 /**
  * Converts some characters for MySQL's indexing to grok it correctly,
  * and pads short words to overcome limitations.
  */
 function normalizeText($string)
 {
     global $wgContLang;
     wfProfileIn(__METHOD__);
     $out = parent::normalizeText($string);
     // MySQL fulltext index doesn't grok utf-8, so we
     // need to fold cases and convert to hex
     $out = preg_replace_callback("/([\\xc0-\\xff][\\x80-\\xbf]*)/", array($this, 'stripForSearchCallback'), $wgContLang->lc($out));
     // And to add insult to injury, the default indexing
     // ignores short words... Pad them so we can pass them
     // through without reconfiguring the server...
     $minLength = $this->minSearchLength();
     if ($minLength > 1) {
         $n = $minLength - 1;
         $out = preg_replace("/\\b(\\w{1,{$n}})\\b/", "\$1u800", $out);
     }
     // Periods within things like hostnames and IP addresses
     // are also important -- we want a search for "example.com"
     // or "192.168.1.1" to work sanely.
     //
     // MySQL's search seems to ignore them, so you'd match on
     // "example.wikipedia.com" and "192.168.83.1" as well.
     $out = preg_replace("/(\\w)\\.(\\w|\\*)/u", "\$1u82e\$2", $out);
     wfProfileOut(__METHOD__);
     return $out;
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:30,代码来源:SearchMySQL.php


注:本文中的SearchEngine::normalizeText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。