/src/3rdparty/clucene/src/CLucene/search/PhraseScorer.h

https://bitbucket.org/ultra_iter/qt-vtl · C Header · 65 lines · 43 code · 12 blank · 10 comment · 0 complexity · 8e5927d53b46560bf0424c46c32bd920 MD5 · raw file

  1. /*------------------------------------------------------------------------------
  2. * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
  3. *
  4. * Distributable under the terms of either the Apache License (Version 2.0) or
  5. * the GNU Lesser General Public License, as specified in the COPYING file.
  6. ------------------------------------------------------------------------------*/
  7. #ifndef _lucene_search_PhraseScorer_
  8. #define _lucene_search_PhraseScorer_
  9. #if defined(_LUCENE_PRAGMA_ONCE)
  10. # pragma once
  11. #endif
  12. #include "PhraseQueue.h"
  13. #include "PhrasePositions.h"
  14. #include "Scorer.h"
  15. #include "Similarity.h"
  16. CL_NS_DEF(search)
  17. class PhraseScorer: public Scorer {
  18. private:
  19. Weight* weight;
  20. qreal freq;
  21. bool firstTime;
  22. bool more;
  23. protected:
  24. uint8_t* norms;
  25. qreal value;
  26. PhraseQueue* pq; //is used to order the list point to by first and last
  27. PhrasePositions* first; //Points to the first in the list of PhrasePositions
  28. PhrasePositions* last; //Points to the last in the list of PhrasePositions
  29. public:
  30. //Constructor
  31. PhraseScorer(Weight* weight, CL_NS(index)::TermPositions** tps,
  32. int32_t* positions, Similarity* similarity, uint8_t* norms);
  33. virtual ~PhraseScorer();
  34. int32_t doc() const { return first->doc; }
  35. bool next();
  36. qreal score();
  37. bool skipTo(int32_t target);
  38. void explain(int32_t doc, Explanation* ret);
  39. TCHAR* toString();
  40. protected:
  41. virtual qreal phraseFreq() =0;
  42. //Transfers the PhrasePositions from the PhraseQueue pq to
  43. //the PhrasePositions list with first as its first element
  44. void pqToList();
  45. //Moves first to the end of the list
  46. void firstToLast();
  47. private:
  48. bool doNext();
  49. void init();
  50. void sort();
  51. };
  52. CL_NS_END
  53. #endif