File indexing completed on 2024-06-23 05:55:39

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Search_Lucene
0017  * @subpackage Search
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 
0024 /**
0025  * Calculate query weights and build query scorers.
0026  *
0027  * A Weight is constructed by a query Query->createWeight().
0028  * The sumOfSquaredWeights() method is then called on the top-level
0029  * query to compute the query normalization factor Similarity->queryNorm(float).
0030  * This factor is then passed to normalize(float).  At this point the weighting
0031  * is complete.
0032  *
0033  * @category   Zend
0034  * @package    Zend_Search_Lucene
0035  * @subpackage Search
0036  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0037  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0038  */
0039 abstract class Zend_Search_Lucene_Search_Weight
0040 {
0041     /**
0042      * Normalization factor.
0043      * This value is stored only for query expanation purpose and not used in any other place
0044      *
0045      * @var float
0046      */
0047     protected $_queryNorm;
0048 
0049     /**
0050      * Weight value
0051      *
0052      * Weight value may be initialized in sumOfSquaredWeights() or normalize()
0053      * because they both are invoked either in Query::_initWeight (for top-level query) or
0054      * in corresponding methods of parent query's weights
0055      *
0056      * @var float
0057      */
0058     protected $_value;
0059 
0060 
0061     /**
0062      * The weight for this query.
0063      *
0064      * @return float
0065      */
0066     public function getValue()
0067     {
0068         return $this->_value;
0069     }
0070 
0071     /**
0072      * The sum of squared weights of contained query clauses.
0073      *
0074      * @return float
0075      */
0076     abstract public function sumOfSquaredWeights();
0077 
0078     /**
0079      * Assigns the query normalization factor to this.
0080      *
0081      * @param float $norm
0082      */
0083     abstract public function normalize($norm);
0084 }
0085