| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
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-2007 Zend Technologies USA Inc. (http://www.zend.com) 19 * @license http://framework.zend.com/license/new-bsd New BSD License 20 */ 21 22 23 /** Zend_Search_Lucene_Search_Weight */ 24 require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Search/Weight.php'; 25 26 27 /** 28 * @category Zend 29 * @package Zend_Search_Lucene 30 * @subpackage Search 31 * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com) 32 * @license http://framework.zend.com/license/new-bsd New BSD License 33 */ 34 class Zend_Search_Lucene_Search_Weight_Term extends Zend_Search_Lucene_Search_Weight 35 { 36 /** 37 * IndexReader. 38 * 39 * @var Zend_Search_Lucene_Interface 40 */ 41 private $_reader; 42 43 /** 44 * Term 45 * 46 * @var Zend_Search_Lucene_Index_Term 47 */ 48 private $_term; 49 50 /** 51 * The query that this concerns. 52 * 53 * @var Zend_Search_Lucene_Search_Query 54 */ 55 private $_query; 56 57 /** 58 * Score factor 59 * 60 * @var float 61 */ 62 private $_idf; 63 64 /** 65 * Query weight 66 * 67 * @var float 68 */ 69 private $_queryWeight; 70 71 72 /** 73 * Zend_Search_Lucene_Search_Weight_Term constructor 74 * reader - index reader 75 * 76 * @param Zend_Search_Lucene_Index_Term $term 77 * @param Zend_Search_Lucene_Search_Query $query 78 * @param Zend_Search_Lucene_Interface $reader 79 */ 80 public function __construct(Zend_Search_Lucene_Index_Term $term, 81 Zend_Search_Lucene_Search_Query $query, 82 Zend_Search_Lucene_Interface $reader) 83 { 84 $this->_term = $term; 85 $this->_query = $query; 86 $this->_reader = $reader; 87 } 88 89 90 /** 91 * The sum of squared weights of contained query clauses. 92 * 93 * @return float 94 */ 95 public function sumOfSquaredWeights() 96 { 97 // compute idf 98 $this->_idf = $this->_reader->getSimilarity()->idf($this->_term, $this->_reader); 99 100 // compute query weight 101 $this->_queryWeight = $this->_idf * $this->_query->getBoost(); 102 103 // square it 104 return $this->_queryWeight * $this->_queryWeight; 105 } 106 107 108 /** 109 * Assigns the query normalization factor to this. 110 * 111 * @param float $queryNorm 112 */ 113 public function normalize($queryNorm) 114 { 115 $this->_queryNorm = $queryNorm; 116 117 // normalize query weight 118 $this->_queryWeight *= $queryNorm; 119 120 // idf for documents 121 $this->_value = $this->_queryWeight * $this->_idf; 122 } 123 } 124
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |