當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FinderIndexerHelper::isCommon方法代碼示例

本文整理匯總了PHP中FinderIndexerHelper::isCommon方法的典型用法代碼示例。如果您正苦於以下問題:PHP FinderIndexerHelper::isCommon方法的具體用法?PHP FinderIndexerHelper::isCommon怎麽用?PHP FinderIndexerHelper::isCommon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在FinderIndexerHelper的用法示例。


在下文中一共展示了FinderIndexerHelper::isCommon方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Method to construct the token object.
  *
  * @param   mixed   $term    The term as a string for words or an array for phrases.
  * @param   string  $lang    The simple language identifier.
  * @param   string  $spacer  The space separator for phrases. [optional]
  *
  * @since   2.5
  */
 public function __construct($term, $lang, $spacer = ' ')
 {
     $this->language = $lang;
     // Tokens can be a single word or an array of words representing a phrase.
     if (is_array($term)) {
         // Populate the token instance.
         $this->term = implode($spacer, $term);
         $this->stem = implode($spacer, array_map(array('FinderIndexerHelper', 'stem'), $term, array($lang)));
         $this->numeric = false;
         $this->common = false;
         $this->phrase = true;
         $this->length = JString::strlen($this->term);
         /*
          * Calculate the weight of the token.
          *
          * 1. Length of the token up to 30 and divide by 30, add 1.
          * 2. Round weight to 4 decimal points.
          */
         $this->weight = ($this->length >= 30 ? 30 : $this->length) / 30 + 1;
         $this->weight = round($this->weight, 4);
     } else {
         // Populate the token instance.
         $this->term = $term;
         $this->stem = FinderIndexerHelper::stem($this->term, $lang);
         $this->numeric = is_numeric($this->term) || (bool) preg_match('#^[0-9,.\\-\\+]+$#', $this->term);
         $this->common = $this->numeric ? false : FinderIndexerHelper::isCommon($this->term, $lang);
         $this->phrase = false;
         $this->length = JString::strlen($this->term);
         /*
          * Calculate the weight of the token.
          *
          * 1. Length of the token up to 15 and divide by 15.
          * 2. If common term, divide weight by 8.
          * 3. If numeric, multiply weight by 1.5.
          * 4. Round weight to 4 decimal points.
          */
         $this->weight = ($this->length >= 15 ? 15 : $this->length) / 15;
         $this->weight = $this->common == true ? $this->weight / 8 : $this->weight;
         $this->weight = $this->numeric == true ? $this->weight * 1.5 : $this->weight;
         $this->weight = round($this->weight, 4);
     }
 }
開發者ID:adjaika,項目名稱:J3Base,代碼行數:51,代碼來源:token.php

示例2: testIsCommon

 /**
  * Tests the isCommon method
  *
  * @return  void
  *
  * @since   3.1
  */
 public function testIsCommon()
 {
     $this->assertTrue(FinderIndexerHelper::isCommon('the', 'en'), 'Tests that FinderIndexerHelper::isCommon() returns true for a common term.');
     $this->assertFalse(FinderIndexerHelper::isCommon('joomla', 'en'), 'Tests that FinderIndexerHelper::isCommon() returns false for an uncommon term.');
 }
開發者ID:shoffmann52,項目名稱:install-from-web-server,代碼行數:12,代碼來源:FinderIndexerHelperTest.php


注:本文中的FinderIndexerHelper::isCommon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。