System documentation of the GNU Image-Finding Tool

CQInvertedFile.h
1 /* -*- mode: c++ -*-
2 */
3 /*
4 
5  GIFT, a flexible content based image retrieval system.
6  Copyright (C) 1998, 1999, 2000, 2001, 2002, CUI University of Geneva
7 
8  Copyright (C) 2003, 2004 Bayreuth University
9  2005 Bamberg University
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 
24 */
25 // -*- mode: c++ -*-
26 
49 #ifndef _CINVERTEDFILEQUERY
50 #define _CINVERTEDFILEQUERY
51 #include "libGIFTQuInvertedFile/include/uses-declarations.h"
52 #include <memory>
53 #include <map>
54 #include "libMRML/include/CSelfDestroyPointer.h"
55 #include "libMRML/include/CRelevanceLevelList.h"
56 #include "libMRML/include/CIDRelevanceLevelPairList.h"
57 #include "libGIFTQuInvertedFile/include/CWeightingFunctionPointerList.h"
58 #include "libGIFTQuInvertedFile/include/CWeightingFunctionPointerHash.h"
59 #include "libMRML/include/CAlgorithm.h"
60 #include "libMRML/include/CQuery.h"
61 #include "libGIFTAcInvertedFile/include/CAcInvertedFile.h"
62 #include "libGIFTQuInvertedFile/include/CWeightingFunction.h"
63 #include "libGIFTQuInvertedFile/include/CQueryNormalizer.h"
64 #include "libGIFTAcInvertedFile/include/WeightingFunctionsAndNormalizers.h"
65 class CScoreBoard;
66 class CAcInvertedFile;
67 
68 #include "libGIFTQuInvertedFile/include/CWeighter.h"
69 
74 class CWeighterFactory:protected map< string,CWeighter* >{
75 public:
85  CWeighter* newWeighter(const string& inID)const;
93 };
94 
96 class CQInvertedFile:public CQuery{
97 
98 protected:
99 
100 
101  CAlgorithm* mDeb;
102 
104  int mModulo;
116 
120 
127  double keepScore(CScoreBoard& inoutScoreBoard,
128  const CWeightingFunctionPointerList& inFeatures,
129  bool lPositive)const;
130 
137  double keepScorePruning(CScoreBoard& inoutScoreBoard,
138  const CWeightingFunctionPointerList& inFeatures,
139  bool inPositive,
140  int inDesiredNumberOfDocuments)const;
141 
151  void buildQueryHash(CRelevanceLevelList& inQuery,
153  outQueryFeatureWeighters)const;
154 
160  void buildNormalizedQueryList(double inPositiveRelevanceSum,
161  double inNegativeRelevanceSum,
163  inQFW,
164  CWeightingFunctionPointerList&
165  outQFW)const;
166 
172  void buildNormalizedQueryHash(double inPositiveRelevanceSum,
173  double inNegativeRelevanceSum,
175  inQFW)const;
176 
177 protected:
183  void init();
184 
185 public:
190  void finishInit();
198  CQInvertedFile(CAccessorAdminCollection& inAccessorAdminCollection,
199  CAlgorithm& inAlgorithm);
205  ~CQInvertedFile();
212  virtual bool setAlgorithm(CAlgorithm& inAlgorithm);
213 
214 
223  virtual CIDRelevanceLevelPairList* fastQuery(const CXMLElement& inQuery,
224  int inNumberOfInterestingImages,
225  double inDifferenceToBest);
226 
233  virtual CIDRelevanceLevelPairList* fastQueryByFeature(const CWeightingFunctionPointerList& inQuery,
234  int inNumberOfInterestingImages,
235  double inDifferenceToBest);
236 
242  double DIDToScore(TID inDID,
243  const CWeightingFunctionPointerHash& inQuery)const;
244 
245 
251  double URLToScore(const string& inURL,
252  const CWeightingFunctionPointerHash& inQuery)const;
253 
259  double FeatureListToScore(TID inDID,
260  const CDocumentFrequencyList& inFeatureList,
261  const CWeightingFunctionPointerHash& inQuery)const;
262 
267  void buildNormalizedQueryHash(const CRelevanceLevel& inQuery,
269  outQueryFeatureWeighters)const;
270 
271 
272  /* variables needed for the blocking of special feature groups */
273 
274  /* the upper limit for the number of feature groups needed for the array for the blocking */
275  static const int MAXIMUMNUMBEROFEATUREGROUPS=50;
276  /* you need to switch this on to activate the blocking of features */
277  bool mBlockingOn;
278  /* array with all the feature groups and an information if blocked or not */
279  bool mBlockingArray[MAXIMUMNUMBEROFEATUREGROUPS];
280 
281 
288 
295 
301  bool featuresBlocked()const;
302 
308  void blockFeatureGroup(const int featureNumber);
309 
315  void unblockFeatureGroup(const int featureNumber);
316 
322  bool isBlocked(const int featureNumber)const;
323 
324 
325 
330  static const int MAX_SCOREBOARD_PRUNINGS=10;
331 
335 
343  typedef struct{
352  double reduceTo;
359 
360  /* true if feature pruning is used */
361  bool mFeaturePruningUsed;
364 
365  /* true if time pruning is used */
366  bool mTimePruningUsed;
369 
370  /* if this variable is used with scoreboardpruning, the resulting
371  scoreboard will be evaluated with an uninverted file
372  @Author Henning Müller */
373  bool mEvaluateAfterPruning;
374 
381  void releaseAllPrunings();
382 
383 
391  void useFeaturePruning(double percentage);
392 
399  void releaseFeaturePruning();
400 
407  void useTimePruning(double inTimeCutoffPoint);
408 
415  void releaseTimePruning();
416 
423  void useScoreBoardPruning(double inCutAfterFraction,
424  double inReduceToFactor);
425 
433 
441 
453 }; /* end of class */
454 
455 #endif
456 

Need for discussion? Want to contribute? Contact
help-gift@gnu.org Generated using Doxygen