System documentation of the GNU Image-Finding Tool

Main Page | Class Hierarchy | Alphabetical List | Class List | 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 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 00022 */ 00023 // -*- mode: c++ -*- 00024 00047 #ifndef _CINVERTEDFILEQUERY 00048 #define _CINVERTEDFILEQUERY 00049 #include "libGIFTQuInvertedFile/include/uses-declarations.h" 00050 #include <memory> 00051 #include <map> 00052 #include "libMRML/include/CSelfDestroyPointer.h" 00053 #include "libMRML/include/CRelevanceLevelList.h" 00054 #include "libMRML/include/CIDRelevanceLevelPairList.h" 00055 #include "libGIFTQuInvertedFile/include/CWeightingFunctionPointerList.h" 00056 #include "libGIFTQuInvertedFile/include/CWeightingFunctionPointerHash.h" 00057 #include "libMRML/include/CAlgorithm.h" 00058 #include "libMRML/include/CQuery.h" 00059 #include "libGIFTAcInvertedFile/include/CAcInvertedFile.h" 00060 #include "libGIFTQuInvertedFile/include/CWeightingFunction.h" 00061 #include "libGIFTQuInvertedFile/include/CQueryNormalizer.h" 00062 #include "libGIFTAcInvertedFile/include/WeightingFunctionsAndNormalizers.h" 00063 class CScoreBoard; 00064 class CAcInvertedFile; 00065 00066 #include "libGIFTQuInvertedFile/include/CWeighter.h" 00067 00072 class CWeighterFactory:protected map< string,CWeighter* >{ 00073 public: 00083 CWeighter* newWeighter(const string& inID)const; 00087 CWeighterFactory(); 00090 ~CWeighterFactory(); 00091 }; 00092 00094 class CQInvertedFile:public CQuery{ 00095 00096 protected: 00097 00098 00099 CAlgorithm* mDeb; 00100 00102 int mModulo; 00104 int mModuloClass; 00109 CWeighterFactory mWeighterFactory; 00113 CSelfDestroyPointer<CWeighter> mWeighter; 00114 00116 CSelfDestroyPointer<CWeightingFunctionPointerHash> 00117 mQueryFeatureWeighters; 00118 00125 double keepScore(CScoreBoard& inoutScoreBoard, 00126 const CWeightingFunctionPointerList& inFeatures, 00127 bool lPositive)const; 00128 00135 double keepScorePruning(CScoreBoard& inoutScoreBoard, 00136 const CWeightingFunctionPointerList& inFeatures, 00137 bool inPositive, 00138 int inDesiredNumberOfDocuments)const; 00139 00149 void buildQueryHash(CRelevanceLevelList& inQuery, 00150 CWeightingFunctionPointerHash& 00151 outQueryFeatureWeighters)const; 00152 00158 void buildNormalizedQueryList(double inPositiveRelevanceSum, 00159 double inNegativeRelevanceSum, 00160 CWeightingFunctionPointerHash& 00161 inQFW, 00162 CWeightingFunctionPointerList& 00163 outQFW)const; 00164 00170 void buildNormalizedQueryHash(double inPositiveRelevanceSum, 00171 double inNegativeRelevanceSum, 00172 CWeightingFunctionPointerHash& 00173 inQFW)const; 00174 00175 protected: 00181 void init(); 00182 00183 public: 00188 void finishInit(); 00196 CQInvertedFile(CAccessorAdminCollection& inAccessorAdminCollection, 00197 CAlgorithm& inAlgorithm); 00203 ~CQInvertedFile(); 00210 virtual bool setAlgorithm(CAlgorithm& inAlgorithm); 00211 00212 00221 virtual CIDRelevanceLevelPairList* fastQuery(const CXMLElement& inQuery, 00222 int inNumberOfInterestingImages, 00223 double inDifferenceToBest); 00224 00231 virtual CIDRelevanceLevelPairList* fastQueryByFeature(const CWeightingFunctionPointerList& inQuery, 00232 int inNumberOfInterestingImages, 00233 double inDifferenceToBest); 00234 00240 double DIDToScore(TID inDID, 00241 const CWeightingFunctionPointerHash& inQuery)const; 00242 00243 00249 double URLToScore(const string& inURL, 00250 const CWeightingFunctionPointerHash& inQuery)const; 00251 00257 double FeatureListToScore(TID inDID, 00258 const CDocumentFrequencyList& inFeatureList, 00259 const CWeightingFunctionPointerHash& inQuery)const; 00260 00265 void buildNormalizedQueryHash(const CRelevanceLevel& inQuery, 00266 CWeightingFunctionPointerHash& 00267 outQueryFeatureWeighters)const; 00268 00269 00270 /* variables needed for the blocking of special feature groups */ 00271 00272 /* the upper limit for the number of feature groups needed for the array for the blocking */ 00273 static const int MAXIMUMNUMBEROFEATUREGROUPS=50; 00274 /* you need to switch this on to activate the blocking of features */ 00275 bool mBlockingOn; 00276 /* array with all the feature groups and an information if blocked or not */ 00277 bool mBlockingArray[MAXIMUMNUMBEROFEATUREGROUPS]; 00278 00279 00285 void activateBlockingFeatures(); 00286 00292 void releaseBlockingFeatures(); 00293 00299 bool featuresBlocked()const; 00300 00306 void blockFeatureGroup(const int featureNumber); 00307 00313 void unblockFeatureGroup(const int featureNumber); 00314 00320 bool isBlocked(const int featureNumber)const; 00321 00322 00323 00328 static const int MAX_SCOREBOARD_PRUNINGS=10; 00329 00332 bool mPruningUsed; 00333 00336 bool mScoreBoardPruningUsed; 00341 typedef struct{ 00345 double stopAfterFeature; 00350 double reduceTo; 00351 } parameterPruningType; 00353 parameterPruningType 00354 mScoreBoardPruningArray[MAX_SCOREBOARD_PRUNINGS]; 00356 int mNumberofUsedScoreBoardPrunings; 00357 00358 /* true if feature pruning is used */ 00359 bool mFeaturePruningUsed; 00361 double mPercentageofFeatures; 00362 00363 /* true if time pruning is used */ 00364 bool mTimePruningUsed; 00366 double mStoppingTime; 00367 00368 /* if this variable is used with scoreboardpruning, the resulting 00369 scoreboard will be evaluated with an uninverted file 00370 @Author Henning Müller */ 00371 bool mEvaluateAfterPruning; 00372 00379 void releaseAllPrunings(); 00380 00381 00389 void useFeaturePruning(double percentage); 00390 00397 void releaseFeaturePruning(); 00398 00405 void useTimePruning(double inTimeCutoffPoint); 00406 00413 void releaseTimePruning(); 00414 00421 void useScoreBoardPruning(double inCutAfterFraction, 00422 double inReduceToFactor); 00423 00430 void releaseScoreBoardPruning(); 00431 00438 void useEvaluateAfterPruning(); 00439 00446 void releaseEvaluateAfterPruning(); 00450 CWeighter& getWeighter(); 00451 }; /* end of class */ 00452 00453 #endif 00454

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