00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef _MATCHINFO_HPP_
00016 #define _MATCHINFO_HPP_
00017 #include <vector>
00018 #include <algorithm>
00019
00020 #include "RetrievalMethod.hpp"
00021
00023 class TMatch {
00024 public:
00025 TMatch(TERMID_T t, int s, int e, int p): tid(t), start(s), end(e),
00026 position(p) { }
00028 TERMID_T tid;
00030 int start;
00032 int end;
00034 int position;
00035 };
00036
00042 class MatchInfo : public vector<TMatch> {
00043 public:
00045 virtual ~MatchInfo() {}
00046
00048 int count() const {return size();}
00049
00051
00053
00054
00056
00057
00062 static MatchInfo *getMatches(const Index &ind, const Query &qry, DOCID_T docID);
00063
00064 private:
00066 MatchInfo() {}
00067
00069 void add(TERMID_T tid, int position, int start=-1, int end=-1) {
00070 TMatch t(tid, start, end, position);
00071
00072 push_back(t);
00073 }
00074
00076 class TMatchAscending {
00077 public:
00078 bool operator()(const TMatch & a, const TMatch & b) {
00079 return a.position < b.position;
00080 }
00081 };
00082
00084 void sort() {
00085 TMatchAscending tma;
00086
00087 std::sort(this->begin(), this->end(), tma);
00088 }
00089
00091
00093
00094 };
00095 #endif