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:
429 Similarity();
430 virtual ~Similarity();
431
432 LUCENE_CLASS(Similarity);
433
434 protected:
435 static const int32_t NO_DOC_ID_PROVIDED;
436
437 protected:
438 static const Collection<double> NORM_TABLE();
439
440 public:
445 static SimilarityPtr getDefault();
446
449 static double decodeNorm(uint8_t b);
450
453 static const Collection<double> getNormDecoder();
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
571 virtual IDFExplanationPtr idfExplain(Collection<TermPtr> terms, const SearcherPtr& searcher);
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
Explanation.h
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Lucene::Collection< double >
Lucene::LuceneObject
Base class for all Lucene classes.
Definition: LuceneObject.h:31
Lucene::Similarity
Scoring API.
Definition: Similarity.h:427
Lucene::Similarity::idfExplain
virtual IDFExplanationPtr idfExplain(Collection< TermPtr > terms, const SearcherPtr &searcher)
Computes a score factor for a phrase.
Lucene::Similarity::NORM_TABLE
static const Collection< double > NORM_TABLE()
Lucene::Similarity::lengthNorm
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....
Lucene::Similarity::~Similarity
virtual ~Similarity()
Lucene::Similarity::computeNorm
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 ...
Lucene::Similarity::tf
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...
Lucene::Similarity::idfExplain
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.
Lucene::Similarity::idf
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...
Lucene::Similarity::getNormDecoder
static const Collection< double > getNormDecoder()
Returns a table for decoding normalization bytes.
Lucene::Similarity::encodeNorm
static uint8_t encodeNorm(double f)
Encodes a normalization factor for storage in an index.
Lucene::Similarity::decodeNorm
static double decodeNorm(uint8_t b)
Decodes a normalization factor stored in an index.
Lucene::Similarity::scorePayload
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...
Lucene::Similarity::sloppyFreq
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...
Lucene::Similarity::tf
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...
Lucene::Similarity::queryNorm
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...
Lucene::Similarity::NO_DOC_ID_PROVIDED
static const int32_t NO_DOC_ID_PROVIDED
Definition: Similarity.h:432
Lucene::Similarity::getDefault
static SimilarityPtr getDefault()
Return the default Similarity implementation used by indexing and search code. This is initially an i...
Lucene::Similarity::coord
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....
Lucene::Similarity::Similarity
Similarity()
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::SearcherPtr
boost::shared_ptr< Searcher > SearcherPtr
Definition: LuceneTypes.h:434
Lucene::FieldInvertStatePtr
boost::shared_ptr< FieldInvertState > FieldInvertStatePtr
Definition: LuceneTypes.h:128
Lucene::SimilarityPtr
boost::shared_ptr< Similarity > SimilarityPtr
Definition: LuceneTypes.h:435
Lucene::TermPtr
boost::shared_ptr< Term > TermPtr
Definition: LuceneTypes.h:233
Lucene::IDFExplanationPtr
boost::shared_ptr< IDFExplanation > IDFExplanationPtr
Definition: LuceneTypes.h:372

clucene.sourceforge.net