[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/demos/quickstart/protected/index/Zend/Search/Lucene/Search/Weight/ -> Phrase.php (source)

   1  <?php
   2  /**
   3   * Zend Framework
   4   *
   5   * LICENSE
   6   *
   7   * This source file is subject to version 1.0 of the Zend Framework
   8   * license, that is bundled with this package in the file LICENSE, and
   9   * is available through the world-wide-web at the following URL:
  10   * http://www.zend.com/license/framework/1_0.txt. If you did not receive
  11   * a copy of the Zend Framework license and are unable to obtain it
  12   * through the world-wide-web, please send a note to license@zend.com
  13   * so we can mail you a copy immediately.
  14   *
  15   * @package    Zend_Search_Lucene
  16   * @subpackage Search
  17   * @copyright  Copyright (c) 2005-2006 Zend Technologies USA Inc. (http://www.zend.com)
  18   * @license    http://www.zend.com/license/framework/1_0.txt Zend Framework License version 1.0
  19   */
  20  
  21  
  22  /**
  23   * Zend_Search_Lucene_Search_Weight
  24   */
  25  require_once 'Zend/Search/Lucene/Search/Weight.php';
  26  
  27  /**
  28   * @package    Zend_Search_Lucene
  29   * @subpackage Search
  30   * @copyright  Copyright (c) 2005-2006 Zend Technologies USA Inc. (http://www.zend.com)
  31   * @license    http://www.zend.com/license/framework/1_0.txt Zend Framework License version 1.0
  32   */
  33  class Zend_Search_Lucene_Search_Weight_Phrase extends Zend_Search_Lucene_Search_Weight
  34  {
  35      /**
  36       * IndexReader.
  37       *
  38       * @var Zend_Search_Lucene
  39       */
  40      private $_reader;
  41  
  42      /**
  43       * The query that this concerns.
  44       *
  45       * @var Zend_Search_Lucene_Search_Query_Phrase
  46       */
  47      private $_query;
  48  
  49      /**
  50       * Weight value
  51       *
  52       * @var float
  53       */
  54      private $_value;
  55  
  56      /**
  57       * Score factor
  58       *
  59       * @var float
  60       */
  61      private $_idf;
  62  
  63      /**
  64       * Normalization factor
  65       *
  66       * @var float
  67       */
  68      private $_queryNorm;
  69  
  70  
  71      /**
  72       * Query weight
  73       *
  74       * @var float
  75       */
  76      private $_queryWeight;
  77  
  78  
  79      /**
  80       * Zend_Search_Lucene_Search_Weight_Phrase constructor
  81       *
  82       * @param Zend_Search_Lucene_Search_Query_Phrase $query
  83       * @param Zend_Search_Lucene $reader
  84       */
  85      public function __construct(Zend_Search_Lucene_Search_Query_Phrase $query, Zend_Search_Lucene $reader)
  86      {
  87          $this->_query  = $query;
  88          $this->_reader = $reader;
  89      }
  90  
  91  
  92      /**
  93       * The weight for this query
  94       *
  95       * @return float
  96       */
  97      public function getValue()
  98      {
  99          return $this->_value;
 100      }
 101  
 102  
 103      /**
 104       * The sum of squared weights of contained query clauses.
 105       *
 106       * @return float
 107       */
 108      public function sumOfSquaredWeights()
 109      {
 110          // compute idf
 111          $this->_idf = $this->_reader->getSimilarity()->idf($this->_query->getTerms(), $this->_reader);
 112  
 113          // compute query weight
 114          $this->_queryWeight = $this->_idf * $this->_query->getBoost();
 115  
 116          // square it
 117          return $this->_queryWeight * $this->_queryWeight;
 118      }
 119  
 120  
 121      /**
 122       * Assigns the query normalization factor to this.
 123       *
 124       * @param float $queryNorm
 125       */
 126      public function normalize($queryNorm)
 127      {
 128          $this->_queryNorm = $queryNorm;
 129  
 130          // normalize query weight
 131          $this->_queryWeight *= $queryNorm;
 132  
 133          // idf for documents
 134          $this->_value = $this->_queryWeight * $this->_idf;
 135      }
 136  }
 137  
 138  


Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7