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

Loading...
Searching...
No Matches
PhraseScorer.h
Go to the documentation of this file.
1
2// 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 PHRASESCORER_H
8#define PHRASESCORER_H
9
10#include "Scorer.h"
11#include <vector>
12
13 namespace Lucene {
14
22 class PhraseScorer : public Scorer {
23 public:
24 PhraseScorer(const WeightPtr& weight, Collection<TermPositionsPtr> tps, Collection<int32_t> offsets, const SimilarityPtr& similarity, ByteArray norms);
25 virtual ~PhraseScorer();
26
27 LUCENE_CLASS(PhraseScorer);
28
29 protected:
30 WeightPtr weight;
31 Weight* __weight = nullptr;
32 ByteArray norms;
33 double value;
34
35 bool firstTime;
36 bool more;
37 PhraseQueuePtr pq;
38 std::vector<PhrasePositionsPtr> _holds;
39 PhrasePositions* __first = nullptr;
40 PhrasePositions* __last = nullptr;
41
42 double freq; // phrase frequency in current doc as computed by phraseFreq().
43
44 public:
45 virtual int32_t docID();
46 virtual int32_t nextDoc();
47 virtual double score();
48 virtual int32_t advance(int32_t target);
49
51 double currentFreq();
52 virtual float termFreq(){
53 return currentFreq();
54 }
55
56 virtual String toString();
57
58 protected:
60 bool doNext();
61
67 virtual double phraseFreq() = 0;
68
69 void init();
70 void sort();
71 void pqToList();
72 void firstToLast();
73};
74
75}
76
77#endif
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
Scorer.h
Lucene::Collection
Utility template class to handle collections that can be safely copied and shared.
Definition Collection.h:17
Lucene::PhrasePositions
Position of a term in a document that takes into account the term offset within the phrase.
Definition PhrasePositions.h:15
Lucene::PhraseScorer::termFreq
virtual float termFreq()
Definition PhraseScorer.h:52
Lucene::PhraseScorer::norms
ByteArray norms
Definition PhraseScorer.h:32
Lucene::PhraseScorer::firstToLast
void firstToLast()
Lucene::PhraseScorer::__weight
Weight * __weight
Definition PhraseScorer.h:31
Lucene::PhraseScorer::init
void init()
Lucene::PhraseScorer::weight
WeightPtr weight
Definition PhraseScorer.h:30
Lucene::PhraseScorer::docID
virtual int32_t docID()
Returns the following:
Lucene::PhraseScorer::pq
PhraseQueuePtr pq
Definition PhraseScorer.h:37
Lucene::PhraseScorer::phraseFreq
virtual double phraseFreq()=0
For a document containing all the phrase query terms, compute the frequency of the phrase in that doc...
Lucene::PhraseScorer::pqToList
void pqToList()
Lucene::PhraseScorer::currentFreq
double currentFreq()
Phrase frequency in current doc as computed by phraseFreq().
Lucene::PhraseScorer::__last
PhrasePositions * __last
Definition PhraseScorer.h:40
Lucene::PhraseScorer::_holds
std::vector< PhrasePositionsPtr > _holds
Definition PhraseScorer.h:38
Lucene::PhraseScorer::score
virtual double score()
Returns the score of the current document matching the query. Initially invalid, until nextDoc() or a...
Lucene::PhraseScorer::nextDoc
virtual int32_t nextDoc()
Advances to the next document in the set and returns the doc it is currently on, or NO_MORE_DOCS if t...
Lucene::PhraseScorer::firstTime
bool firstTime
Definition PhraseScorer.h:35
Lucene::PhraseScorer::PhraseScorer
PhraseScorer(const WeightPtr &weight, Collection< TermPositionsPtr > tps, Collection< int32_t > offsets, const SimilarityPtr &similarity, ByteArray norms)
Lucene::PhraseScorer::doNext
bool doNext()
Next without initial increment.
Lucene::PhraseScorer::more
bool more
Definition PhraseScorer.h:36
Lucene::PhraseScorer::value
double value
Definition PhraseScorer.h:33
Lucene::PhraseScorer::__first
PhrasePositions * __first
Definition PhraseScorer.h:39
Lucene::PhraseScorer::freq
double freq
Definition PhraseScorer.h:42
Lucene::PhraseScorer::sort
void sort()
Lucene::PhraseScorer::toString
virtual String toString()
Returns a string representation of the object.
Lucene::PhraseScorer::advance
virtual int32_t advance(int32_t target)
Advances to the first beyond the current whose document number is greater than or equal to target....
Lucene::PhraseScorer::~PhraseScorer
virtual ~PhraseScorer()
Lucene::Scorer::similarity
SimilarityPtr similarity
Definition Scorer.h:45
Lucene::Scorer::Scorer
Scorer(const SimilarityPtr &similarity)
Constructs a Scorer.
Lucene::Weight
Calculate query weights and build query scorers.
Definition Weight.h:30
Lucene
Definition AbstractAllTermDocs.h:12
Lucene::WeightPtr
boost::shared_ptr< Weight > WeightPtr
Definition LuceneTypes.h:480
Lucene::SimilarityPtr
boost::shared_ptr< Similarity > SimilarityPtr
Definition LuceneTypes.h:435
Lucene::PhraseQueuePtr
boost::shared_ptr< PhraseQueue > PhraseQueuePtr
Definition LuceneTypes.h:412

clucene.sourceforge.net