System documentation of the GNU Image-Finding Tool

Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members

CQInvertedFile.h

00001 /* -*- mode: c++ -*- 
00002 */
00003 /* 
00004 
00005     GIFT, a flexible content based image retrieval system.
00006     Copyright (C) 1998, 1999, 2000, 2001, 2002, CUI University of Geneva
00007 
00008      Copyright (C) 2003, 2004 Bayreuth University
00009       2005 Bamberg University
00010     This program is free software; you can redistribute it and/or modify
00011     it under the terms of the GNU General Public License as published by
00012     the Free Software Foundation; either version 2 of the License, or
00013     (at your option) any later version.
00014 
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU General Public License for more details.
00019 
00020     You should have received a copy of the GNU General Public License
00021     along with this program; if not, write to the Free Software
00022     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 
00024 */
00025 // -*- mode: c++ -*-
00026 
00049 #ifndef _CINVERTEDFILEQUERY
00050 #define _CINVERTEDFILEQUERY
00051 #include "libGIFTQuInvertedFile/include/uses-declarations.h"
00052 #include <memory>
00053 #include <map>
00054 #include "libMRML/include/CSelfDestroyPointer.h"
00055 #include "libMRML/include/CRelevanceLevelList.h"
00056 #include "libMRML/include/CIDRelevanceLevelPairList.h"
00057 #include "libGIFTQuInvertedFile/include/CWeightingFunctionPointerList.h"
00058 #include "libGIFTQuInvertedFile/include/CWeightingFunctionPointerHash.h"
00059 #include "libMRML/include/CAlgorithm.h"
00060 #include "libMRML/include/CQuery.h"
00061 #include "libGIFTAcInvertedFile/include/CAcInvertedFile.h"
00062 #include "libGIFTQuInvertedFile/include/CWeightingFunction.h"
00063 #include "libGIFTQuInvertedFile/include/CQueryNormalizer.h"
00064 #include "libGIFTAcInvertedFile/include/WeightingFunctionsAndNormalizers.h"
00065 class CScoreBoard;
00066 class CAcInvertedFile;
00067 
00068 #include "libGIFTQuInvertedFile/include/CWeighter.h"
00069 
00074 class CWeighterFactory:protected map< string,CWeighter* >{
00075 public:
00085   CWeighter* newWeighter(const string& inID)const;
00089   CWeighterFactory();
00092   ~CWeighterFactory();
00093 };
00094 
00096 class CQInvertedFile:public CQuery{
00097 
00098 protected:
00099 
00100 
00101   CAlgorithm* mDeb;
00102 
00104   int mModulo;
00106   int mModuloClass;
00111   CWeighterFactory mWeighterFactory;
00115   CSelfDestroyPointer<CWeighter> mWeighter;
00116 
00118   CSelfDestroyPointer<CWeightingFunctionPointerHash> 
00119   mQueryFeatureWeighters;
00120 
00127   double keepScore(CScoreBoard& inoutScoreBoard,
00128                    const CWeightingFunctionPointerList& inFeatures,
00129                    bool lPositive)const;
00130 
00137   double keepScorePruning(CScoreBoard& inoutScoreBoard,
00138                           const CWeightingFunctionPointerList& inFeatures,
00139                           bool inPositive,
00140                           int inDesiredNumberOfDocuments)const;
00141 
00151   void buildQueryHash(CRelevanceLevelList& inQuery,
00152                       CWeightingFunctionPointerHash& 
00153                       outQueryFeatureWeighters)const;
00154 
00160   void buildNormalizedQueryList(double inPositiveRelevanceSum,
00161                                 double inNegativeRelevanceSum,
00162                                 CWeightingFunctionPointerHash& 
00163                                 inQFW,
00164                                 CWeightingFunctionPointerList& 
00165                                 outQFW)const;
00166 
00172   void buildNormalizedQueryHash(double inPositiveRelevanceSum,
00173                                 double inNegativeRelevanceSum,
00174                                 CWeightingFunctionPointerHash& 
00175                                 inQFW)const;
00176   
00177 protected:
00183   void init();
00184 
00185 public:
00190   void finishInit();
00198   CQInvertedFile(CAccessorAdminCollection& inAccessorAdminCollection,
00199                  CAlgorithm& inAlgorithm);
00205   ~CQInvertedFile();
00212   virtual bool setAlgorithm(CAlgorithm& inAlgorithm);
00213 
00214 
00223   virtual CIDRelevanceLevelPairList* fastQuery(const CXMLElement& inQuery,
00224                                                int inNumberOfInterestingImages,
00225                                                double inDifferenceToBest);
00226   
00233   virtual CIDRelevanceLevelPairList* fastQueryByFeature(const  CWeightingFunctionPointerList& inQuery,
00234                                                         int inNumberOfInterestingImages,
00235                                                         double inDifferenceToBest);
00236   
00242   double DIDToScore(TID inDID,
00243                     const CWeightingFunctionPointerHash& inQuery)const;
00244 
00245 
00251   double URLToScore(const string& inURL,
00252                     const CWeightingFunctionPointerHash& inQuery)const;
00253 
00259   double FeatureListToScore(TID inDID,
00260                             const CDocumentFrequencyList& inFeatureList,
00261                             const CWeightingFunctionPointerHash& inQuery)const;
00262 
00267   void buildNormalizedQueryHash(const CRelevanceLevel& inQuery,
00268                                 CWeightingFunctionPointerHash& 
00269                                 outQueryFeatureWeighters)const;
00270 
00271 
00272   /* variables needed for the blocking of special feature groups */
00273 
00274   /* the upper limit for the number of feature groups needed for the array for the blocking */
00275   static const int MAXIMUMNUMBEROFEATUREGROUPS=50; 
00276   /* you need to switch this on to activate the blocking of features */
00277   bool mBlockingOn;
00278   /* array with all the feature groups and an information if blocked or not */
00279   bool mBlockingArray[MAXIMUMNUMBEROFEATUREGROUPS];
00280 
00281 
00287   void activateBlockingFeatures();
00288 
00294   void releaseBlockingFeatures();
00295 
00301   bool featuresBlocked()const;
00302 
00308   void blockFeatureGroup(const int featureNumber);
00309 
00315   void unblockFeatureGroup(const int featureNumber);
00316 
00322   bool isBlocked(const int featureNumber)const;
00323 
00324 
00325 
00330   static const int MAX_SCOREBOARD_PRUNINGS=10; 
00331 
00334   bool mPruningUsed;
00335 
00338   bool mScoreBoardPruningUsed;
00343   typedef struct{ 
00347     double stopAfterFeature;
00352     double reduceTo;
00353   } parameterPruningType;
00355   parameterPruningType 
00356      mScoreBoardPruningArray[MAX_SCOREBOARD_PRUNINGS];
00358   int mNumberofUsedScoreBoardPrunings;
00359 
00360   /* true if feature pruning is used */
00361   bool mFeaturePruningUsed;
00363   double mPercentageofFeatures;
00364 
00365   /* true if time pruning is used */
00366   bool mTimePruningUsed;
00368   double mStoppingTime;
00369 
00370   /* if this variable is used with scoreboardpruning, the resulting 
00371      scoreboard will be evaluated with an uninverted file 
00372      @Author Henning Müller */
00373   bool mEvaluateAfterPruning;
00374 
00381   void releaseAllPrunings();
00382 
00383 
00391   void useFeaturePruning(double percentage);
00392 
00399   void releaseFeaturePruning();
00400 
00407   void useTimePruning(double inTimeCutoffPoint);
00408 
00415   void releaseTimePruning();
00416 
00423   void useScoreBoardPruning(double inCutAfterFraction,
00424                             double    inReduceToFactor);
00425 
00432   void releaseScoreBoardPruning();
00433 
00440   void useEvaluateAfterPruning();
00441 
00448   void releaseEvaluateAfterPruning();
00452   CWeighter& getWeighter();
00453 }; /* end of class */
00454 
00455 #endif
00456 

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