Weight.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Search_Lucene
  17. * @subpackage Search
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * Calculate query weights and build query scorers.
  23. *
  24. * A Weight is constructed by a query Query->createWeight().
  25. * The sumOfSquaredWeights() method is then called on the top-level
  26. * query to compute the query normalization factor Similarity->queryNorm(float).
  27. * This factor is then passed to normalize(float). At this point the weighting
  28. * is complete.
  29. *
  30. * @category Zend
  31. * @package Zend_Search_Lucene
  32. * @subpackage Search
  33. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. abstract class Zend_Search_Lucene_Search_Weight
  37. {
  38. /**
  39. * Normalization factor.
  40. * This value is stored only for query expanation purpose and not used in any other place
  41. *
  42. * @var float
  43. */
  44. protected $_queryNorm;
  45. /**
  46. * Weight value
  47. *
  48. * Weight value may be initialized in sumOfSquaredWeights() or normalize()
  49. * because they both are invoked either in Query::_initWeight (for top-level query) or
  50. * in corresponding methods of parent query's weights
  51. *
  52. * @var float
  53. */
  54. protected $_value;
  55. /**
  56. * The weight for this query.
  57. *
  58. * @return float
  59. */
  60. public function getValue()
  61. {
  62. return $this->_value;
  63. }
  64. /**
  65. * The sum of squared weights of contained query clauses.
  66. *
  67. * @return float
  68. */
  69. abstract public function sumOfSquaredWeights();
  70. /**
  71. * Assigns the query normalization factor to this.
  72. *
  73. * @param $norm
  74. */
  75. abstract public function normalize($norm);
  76. }