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(int t, int s, int e, int p): tid(t), start(s), end(e),
00026 position(p) { }
00028 int tid;
00030 int start;
00032 int end;
00034 int position;
00035 };
00036
00042 class MatchInfo {
00043 public:
00045 virtual ~MatchInfo() {}
00046
00048 int count() {return matchList.size();}
00049
00051 void startIteration() {iter = matchList.begin();}
00053 bool hasMore() {return(iter != matchList.end());}
00054
00056 TMatch nextMatch() {TMatch ret = *iter; iter++; return ret;}
00057
00062 static MatchInfo *getMatches(Index &ind, Query &qry, int docID);
00063
00064 private:
00066 MatchInfo() { }
00067
00069 void add(int tid, int position, int start=-1, int end=-1) {
00070 TMatch t(tid, start, end, position);
00071 matchList.push_back(t);
00072 }
00073
00075 class TMatchAscending {
00076 public:
00077 bool operator()(const TMatch & a, const TMatch & b) {
00078 return a.position < b.position;
00079 }
00080 };
00081
00083 void sort() {
00084 TMatchAscending tma;
00085 std::sort(matchList.begin(), matchList.end(), tma);
00086 }
00087
00089 vector<TMatch> matchList;
00091 vector<TMatch>::iterator iter;
00092 };
00093 #endif