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 
287  void activateBlockingFeatures();
288 
294  void releaseBlockingFeatures();
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;
356  mScoreBoardPruningArray[MAX_SCOREBOARD_PRUNINGS];
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 
432  void releaseScoreBoardPruning();
433 
440  void useEvaluateAfterPruning();
441 
448  void releaseEvaluateAfterPruning();
452  CWeighter& getWeighter();
453 }; /* end of class */
454 
455 #endif
456 
~CWeighterFactory()
Destructor deletes the content it points to.
CSelfDestroyPointer< CWeightingFunctionPointerHash > mQueryFeatureWeighters
object of this type to have a list of the features with the weights
Definition: CQInvertedFile.h:119
Definition: CIDRelevanceLevelPairList.h:52
int mModuloClass
Every lModulo-th feature, starting at lModuloClass.
Definition: CQInvertedFile.h:106
CWeighter * newWeighter(const string &inID) const
clones a weighter from the factory and sets the pointers in a way, that normalizers etc...
CWeighterFactory()
constructor: initializes everything fills the map etc.
double mStoppingTime
Henning Müller
Definition: CQInvertedFile.h:368
int mNumberofUsedScoreBoardPrunings
Henning Müller
Definition: CQInvertedFile.h:358
This class captures the structure of an XML element.
Definition: CXMLElement.h:51
A factory for weighting functions with associated normalizers.
Definition: CQInvertedFile.h:74
A list of Document Frequency Elements (the main part of an inverted file)
Definition: CDocumentFrequencyList.h:58
CRELEVANCELEVEL.
Definition: CRelevanceLevel.h:60
int mModulo
You can choose to use only every lModulo-th feature.
Definition: CQInvertedFile.h:104
The Query manager for Queries on inverted Files.
Definition: CQInvertedFile.h:96
CSelfDestroyPointer< CWeighter > mWeighter
The weighter currently used.
Definition: CQInvertedFile.h:115
Definition: CScoreBoard.h:60
An algorithm is a CXMLElement which is linked to a CSessionManager together they are able to build CQ...
Definition: CAlgorithm.h:43
The Query manager for Queries on inverted Files.
Definition: CQuery.h:73
An accessor to an inverted file.
Definition: CAcInvertedFile.h:83
Definition: CRelevanceLevelList.h:48
This is in fact a collection of collections.
Definition: CAccessorAdminCollection.h:39
CWeighterFactory mWeighterFactory
This is a factory for weighters.
Definition: CQInvertedFile.h:111
A weighter is a set of WeightingFunction and normalizers which are going to be used together...
Definition: CWeighter.h:41
double reduceTo
reduce the scoreboard to a factor of the number of images you want to retrieve
Definition: CQInvertedFile.h:352
double mPercentageofFeatures
Henning Müller
Definition: CQInvertedFile.h:363
bool mScoreBoardPruningUsed
true if the scoreboardis Pruned
Definition: CQInvertedFile.h:338
double stopAfterFeature
this marks a fraction of the number of features used
Definition: CQInvertedFile.h:347
bool mPruningUsed
Shows if any pruning is used.
Definition: CQInvertedFile.h:334
Parameters for scoreboard pruning.
Definition: CQInvertedFile.h:343
A hash of weighting function pointers.
Definition: CWeightingFunctionPointerHash.h:59

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