Пример #1
0
 /**
  * Computes a score factor for a simple term or a phrase.
  *
  * The default implementation is:
  *   return idfFreq(searcher.docFreq(term), searcher.maxDoc());
  *
  * input - the term in question or array of terms
  * reader - reader the document collection being searched
  * Returns a score factor for the term
  *
  * @param mixed $input
  * @param \Zend\Search\Lucene\IndexInterface $reader
  * @return a score factor for the term
  */
 public function idf($input, \Zend\Search\Lucene\IndexInterface $reader)
 {
     if (!is_array($input)) {
         return $this->idfFreq($reader->docFreq($input), $reader->count());
     } else {
         $idf = 0.0;
         foreach ($input as $term) {
             $idf += $this->idfFreq($reader->docFreq($term), $reader->count());
         }
         return $idf;
     }
 }