00001
00019 #ifndef __D_T_QUERY_RESULTS__
00020 #define __D_T_QUERY_RESULTS__
00021
00022 #include <vector>
00023
00024 namespace DBoW2 {
00025
00027 typedef unsigned int EntryId;
00028
00030 class Result
00031 {
00032 public:
00033
00035 EntryId Id;
00036
00038 double Score;
00039
00041 int nWords;
00042
00043
00044
00045 double bhatScore, chiScore;
00047
00048
00049 double sumCommonVi;
00050 double sumCommonWi;
00051 double expectedChiScore;
00053
00057 inline Result(){}
00058
00064 inline Result(EntryId _id, double _score): Id(_id), Score(_score){}
00065
00070 inline bool operator<(const Result &r) const
00071 {
00072 return this->Score < r.Score;
00073 }
00074
00079 inline bool operator>(const Result &r) const
00080 {
00081 return this->Score > r.Score;
00082 }
00083
00088 inline bool operator==(EntryId id) const
00089 {
00090 return this->Id == id;
00091 }
00092
00098 inline bool operator<(double s) const
00099 {
00100 return this->Score < s;
00101 }
00102
00108 inline bool operator>(double s) const
00109 {
00110 return this->Score > s;
00111 }
00112
00119 static inline bool gt(const Result &a, const Result &b)
00120 {
00121 return a.Score > b.Score;
00122 }
00123
00128 inline static bool ge(const Result &a, const Result &b)
00129 {
00130 return a.Score > b.Score;
00131 }
00132
00139 static inline bool geq(const Result &a, const Result &b)
00140 {
00141 return a.Score >= b.Score;
00142 }
00143
00150 static inline bool geqv(const Result &a, double s)
00151 {
00152 return a.Score >= s;
00153 }
00154
00155
00162 static inline bool ltId(const Result &a, const Result &b)
00163 {
00164 return a.Id < b.Id;
00165 }
00166
00172 friend std::ostream & operator<<(std::ostream& os, const Result& ret );
00173 };
00174
00176 class QueryResults: public std::vector<Result>
00177 {
00178 public:
00179
00184 inline void scaleScores(double factor);
00185
00191 friend std::ostream & operator<<(std::ostream& os, const QueryResults& ret );
00192
00197 void saveM(const std::string &filename) const;
00198
00199 };
00200
00201
00202
00203 inline void QueryResults::scaleScores(double factor)
00204 {
00205 for(QueryResults::iterator qit = begin(); qit != end(); ++qit)
00206 qit->Score *= factor;
00207 }
00208
00209
00210
00211 }
00212
00213 #endif
00214