当前位置: 首页>>代码示例>>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;未经允许,请勿转载。