当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Search_Lucene_Interface::getSimilarity方法代码示例

本文整理汇总了PHP中Zend_Search_Lucene_Interface::getSimilarity方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene_Interface::getSimilarity方法的具体用法?PHP Zend_Search_Lucene_Interface::getSimilarity怎么用?PHP Zend_Search_Lucene_Interface::getSimilarity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Search_Lucene_Interface的用法示例。


在下文中一共展示了Zend_Search_Lucene_Interface::getSimilarity方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sumOfSquaredWeights

 /**
  * The sum of squared weights of contained query clauses.
  *
  * @return float
  */
 public function sumOfSquaredWeights()
 {
     // compute idf
     $this->_idf = $this->_reader->getSimilarity()->idf($this->_query->getTerms(), $this->_reader);
     // compute query weight
     $this->_queryWeight = $this->_idf * $this->_query->getBoost();
     // square it
     return $this->_queryWeight * $this->_queryWeight;
 }
开发者ID:madberry,项目名称:WhiteLabelTransfer,代码行数:14,代码来源:Phrase.php

示例2: score

 public function score($docId, Zend_Search_Lucene_Interface $reader)
 {
     if (isset($this->_docVector[$docId])) {
         return $reader->getSimilarity()->tf($this->_termFreqs[$docId]) * $this->_weight->getValue() * $reader->norm($docId, $this->_term->field) * $this->getBoost();
     } else {
         return 0;
     }
 }
开发者ID:hackingman,项目名称:TubeX,代码行数:8,代码来源:Term.php

示例3: _nonConjunctionScore

 /**
  * Score calculator for non conjunction queries (not all terms are required)
  *
  * @param integer $docId
  * @param Zend_Search_Lucene_Interface $reader
  * @return float
  */
 public function _nonConjunctionScore($docId, $reader)
 {
     if ($this->_coord === null) {
         $this->_coord = array();
         $maxCoord = 0;
         foreach ($this->_signs as $sign) {
             if ($sign !== false) {
                 $maxCoord++;
             }
         }
         for ($count = 0; $count <= $maxCoord; $count++) {
             $this->_coord[$count] = $reader->getSimilarity()->coord($count, $maxCoord);
         }
     }
     $score = 0.0;
     $matchedTerms = 0;
     foreach ($this->_terms as $termId => $term) {
         // Check if term is
         if ($this->_signs[$termId] !== false && isset($this->_termsFreqs[$termId][$docId])) {
             $matchedTerms++;
             /**
              * We don't need to check that term freq is not 0
              * Score calculation is performed only for matched docs
              */
             $score += $reader->getSimilarity()->tf($this->_termsFreqs[$termId][$docId]) * $this->_weights[$termId]->getValue() * $reader->norm($docId, $term->field);
         }
     }
     return $score * $this->_coord[$matchedTerms] * $this->getBoost();
 }
开发者ID:sraj4,项目名称:EthicsPublicHtmlProd,代码行数:36,代码来源:MultiTerm.php

示例4: _nonConjunctionScore

 /**
  * Score calculator for non conjunction queries (not all subqueries are required)
  *
  * @param integer $docId
  * @param Zend_Search_Lucene_Interface $reader
  * @return float
  */
 public function _nonConjunctionScore($docId, Zend_Search_Lucene_Interface $reader)
 {
     if ($this->_coord === null) {
         $this->_coord = array();
         $maxCoord = 0;
         foreach ($this->_signs as $sign) {
             if ($sign !== false) {
                 $maxCoord++;
             }
         }
         for ($count = 0; $count <= $maxCoord; $count++) {
             $this->_coord[$count] = $reader->getSimilarity()->coord($count, $maxCoord);
         }
     }
     $score = 0;
     $matchedSubqueries = 0;
     foreach ($this->_subqueries as $subqueryId => $subquery) {
         $subscore = $subquery->score($docId, $reader);
         // Prohibited
         if ($this->_signs[$subqueryId] === false && $subscore != 0) {
             return 0;
         }
         // is required, but doen't match
         if ($this->_signs[$subqueryId] === true && $subscore == 0) {
             return 0;
         }
         if ($subscore != 0) {
             $matchedSubqueries++;
             $score += $subscore;
         }
     }
     return $score * $this->_coord[$matchedSubqueries] * $this->getBoost();
 }
开发者ID:sraj4,项目名称:EthicsPublicHtmlProd,代码行数:40,代码来源:Boolean.php

示例5: getSimilarity

 /**
  * Retrive similarity used by index reader
  *
  * @return Zend_Search_Lucene_Search_Similarity
  */
 public function getSimilarity()
 {
     return $this->_index->getSimilarity();
 }
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:9,代码来源:Proxy.php

示例6: _sloppyPhraseFreq

 /**
  * Score calculator for sloppy phrase queries (terms sequence is fixed)
  *
  * @param integer $docId
  * @param Zend_Search_Lucene_Interface $reader
  * @return float
  */
 public function _sloppyPhraseFreq($docId, Zend_Search_Lucene_Interface $reader)
 {
     $freq = 0;
     $phraseQueue = array();
     $phraseQueue[0] = array();
     // empty phrase
     $lastTerm = null;
     // Walk through the terms to create phrases.
     foreach ($this->_terms as $termId => $term) {
         $queueSize = count($phraseQueue);
         $firstPass = true;
         // Walk through the term positions.
         // Each term position produces a set of phrases.
         foreach ($this->_termsPositions[$termId][$docId] as $termPosition) {
             if ($firstPass) {
                 for ($count = 0; $count < $queueSize; $count++) {
                     $phraseQueue[$count][$termId] = $termPosition;
                 }
             } else {
                 for ($count = 0; $count < $queueSize; $count++) {
                     if ($lastTerm !== null && abs($termPosition - $phraseQueue[$count][$lastTerm] - ($this->_offsets[$termId] - $this->_offsets[$lastTerm])) > $this->_slop) {
                         continue;
                     }
                     $newPhraseId = count($phraseQueue);
                     $phraseQueue[$newPhraseId] = $phraseQueue[$count];
                     $phraseQueue[$newPhraseId][$termId] = $termPosition;
                 }
             }
             $firstPass = false;
         }
         $lastTerm = $termId;
     }
     foreach ($phraseQueue as $phrasePos) {
         $minDistance = null;
         for ($shift = -$this->_slop; $shift <= $this->_slop; $shift++) {
             $distance = 0;
             $start = reset($phrasePos) - reset($this->_offsets) + $shift;
             foreach ($this->_terms as $termId => $term) {
                 $distance += abs($phrasePos[$termId] - $this->_offsets[$termId] - $start);
                 if ($distance > $this->_slop) {
                     break;
                 }
             }
             if ($minDistance === null || $distance < $minDistance) {
                 $minDistance = $distance;
             }
         }
         if ($minDistance <= $this->_slop) {
             $freq += $reader->getSimilarity()->sloppyFreq($minDistance);
         }
     }
     return $freq;
 }
开发者ID:MexinaD,项目名称:SuiteCRM,代码行数:60,代码来源:Phrase.php

示例7: _conjunctionScore

 public function _conjunctionScore($docId, Zend_Search_Lucene_Interface $reader)
 {
     if ($this->_coord === null) {
         $this->_coord = $reader->getSimilarity()->coord(count($this->_terms), count($this->_terms));
     }
     $score = 0.0;
     foreach ($this->_terms as $termId => $term) {
         $score += $reader->getSimilarity()->tf($this->_termsFreqs[$termId][$docId]) * $this->_weights[$termId]->getValue() * $reader->norm($docId, $term->field);
     }
     return $score * $this->_coord * $this->getBoost();
 }
开发者ID:hackingman,项目名称:TubeX,代码行数:11,代码来源:MultiTerm.php


注:本文中的Zend_Search_Lucene_Interface::getSimilarity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。