#include "CLucene/StdHeader.h" #include "ExactPhraseScorer.h" #include "PhraseScorer.h" #include "CLucene/index/Terms.h" using namespace lucene::index; namespace lucene{ namespace search{ ExactPhraseScorer::ExactPhraseScorer(TermPositions** tps, int_t tpsLength, l_byte_t* n, float_t w): PhraseScorer(tps, tpsLength, n, w) { } float_t ExactPhraseScorer::phraseFreq(){ // sort list with pq for (PhrasePositions* pp = first; pp != NULL; pp = pp->next) { pp->firstPosition(); pq.put(pp); // build pq from list } pqToList(); // rebuild list from pq int_t freq = 0; do { // find position w/ all terms while (first->position < last->position) { // scan forward in first do { if (!first->nextPosition()) return (float_t)freq; } while (first->position < last->position); firstToLast(); } freq++; // all equal: a match } while (last->nextPosition()); return (float_t)freq; } }}