Lucene++ - a full-featured, c++ search engine
API Documentation


Similarity.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2014 Alan Wright. All rights reserved.
3 // Distributable under the terms of either the Apache License (Version 2.0)
4 // or the GNU Lesser General Public License.
6 
7 #ifndef SIMILARITY_H
8 #define SIMILARITY_H
9 
10 #include "Explanation.h"
11 
12 namespace Lucene {
13 
427 class LPPAPI Similarity : public LuceneObject {
428 public:
430  virtual ~Similarity();
431 
433 
434 protected:
435  static const int32_t NO_DOC_ID_PROVIDED;
436 
437 protected:
439 
440 public:
446 
449  static double decodeNorm(uint8_t b);
450 
454 
467  virtual double computeNorm(const String& fieldName, const FieldInvertStatePtr& state);
468 
484  virtual double lengthNorm(const String& fieldName, int32_t numTokens) = 0;
485 
497  virtual double queryNorm(double sumOfSquaredWeights) = 0;
498 
508  static uint8_t encodeNorm(double f);
509 
521  virtual double tf(int32_t freq);
522 
533  virtual double sloppyFreq(int32_t distance) = 0;
534 
544  virtual double tf(double freq) = 0;
545 
561  virtual IDFExplanationPtr idfExplain(const TermPtr& term, const SearcherPtr& searcher);
562 
572 
583  virtual double idf(int32_t docFreq, int32_t numDocs) = 0;
584 
595  virtual double coord(int32_t overlap, int32_t maxOverlap) = 0;
596 
611  virtual double scorePayload(int32_t docId, const String& fieldName, int32_t start, int32_t end, ByteArray payload, int32_t offset, int32_t length);
612 };
613 
614 }
615 
616 #endif
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Base class for all Lucene classes.
Definition: LuceneObject.h:31
Scoring API.
Definition: Similarity.h:427
virtual IDFExplanationPtr idfExplain(Collection< TermPtr > terms, const SearcherPtr &searcher)
Computes a score factor for a phrase.
static const Collection< double > NORM_TABLE()
virtual double lengthNorm(const String &fieldName, int32_t numTokens)=0
Computes the normalization value for a field given the total number of terms contained in a field....
virtual ~Similarity()
virtual double computeNorm(const String &fieldName, const FieldInvertStatePtr &state)
Compute the normalization value for a field, given the accumulated state of term processing for this ...
virtual double tf(int32_t freq)
Computes a score factor based on a term or phrase's frequency in a document. This value is multiplied...
virtual IDFExplanationPtr idfExplain(const TermPtr &term, const SearcherPtr &searcher)
Computes a score factor for a simple term and returns an explanation for that score factor.
virtual double idf(int32_t docFreq, int32_t numDocs)=0
Computes a score factor based on a term's document frequency (the number of documents which contain t...
static const Collection< double > getNormDecoder()
Returns a table for decoding normalization bytes.
static uint8_t encodeNorm(double f)
Encodes a normalization factor for storage in an index.
static double decodeNorm(uint8_t b)
Decodes a normalization factor stored in an index.
virtual double scorePayload(int32_t docId, const String &fieldName, int32_t start, int32_t end, ByteArray payload, int32_t offset, int32_t length)
Calculate a scoring factor based on the data in the payload. Overriding implementations are responsib...
virtual double sloppyFreq(int32_t distance)=0
Computes the amount of a sloppy phrase match, based on an edit distance. This value is summed for eac...
virtual double tf(double freq)=0
Computes a score factor based on a term or phrase's frequency in a document. This value is multiplied...
virtual double queryNorm(double sumOfSquaredWeights)=0
Computes the normalization value for a query given the sum of the squared weights of each of the quer...
static const int32_t NO_DOC_ID_PROVIDED
Definition: Similarity.h:432
static SimilarityPtr getDefault()
Return the default Similarity implementation used by indexing and search code. This is initially an i...
virtual double coord(int32_t overlap, int32_t maxOverlap)=0
Computes a score factor based on the fraction of all query terms that a document contains....
Definition: AbstractAllTermDocs.h:12
boost::shared_ptr< Searcher > SearcherPtr
Definition: LuceneTypes.h:434
boost::shared_ptr< FieldInvertState > FieldInvertStatePtr
Definition: LuceneTypes.h:128
boost::shared_ptr< Similarity > SimilarityPtr
Definition: LuceneTypes.h:435
boost::shared_ptr< Term > TermPtr
Definition: LuceneTypes.h:233
boost::shared_ptr< IDFExplanation > IDFExplanationPtr
Definition: LuceneTypes.h:372

clucene.sourceforge.net