This file is indexed.

/usr/include/libGIFTQuInvertedFile/include/CWeightingFunction.h is in libgnuift0-dev 0.1.14-12.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
/* -*- mode: c++ -*- 
*/
/* 

    GIFT, a flexible content based image retrieval system.
    Copyright (C) 1998, 1999, 2000, 2001, 2002, CUI University of Geneva

     Copyright (C) 2003, 2004 Bayreuth University
      2005 Bamberg University
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*/
/**  -*- mode: c++ -*- */
/**
 *
 * CWEIGHTINGFUNCTION
 *
*
*
* modification history:
*
* HM 090399 created some documentation
*
* @author Wolfgang Müller
*
* compiler defines used:
*
*
*/
#ifndef _CWEIGHTINGFUNCTION
#define _CWEIGHTINGFUNCTION
#include "libGIFTQuInvertedFile/include/uses-declarations.h"
#include <cmath>
#include "libMRML/include/TID.h"
#include "libGIFTAcInvertedFile/include/CDocumentFrequencyElement.h"
#include "libGIFTAcInvertedFile/include/CAcInvertedFile.h"

class CQueryNormalizer;

/** a universally usable class for weighting. 
    
    The rationale is, that we want to implement very flexible 
    feature weighting, so flexible that it does not necessarily 
    have anything to do with the initial concept of feature
    weighting.

    The scenario: We have query/feedback from the user. That is:
    We have a list of images with either positive or negative
    relevance for the user. Each of these images contains a list
    of features. 

    Now we want to combine the different features. What we
    usually need to know is: how many images where in
    the positive feedback, and how many images where
    in the negative feedback.

*/
class CWeightingFunction{
protected:
  /** This value depends on all the elements of the query, which
      have a positive user-assigned relevance.

      i.e. not necessarily only on the elements which contain 
      this feature, so it has to be explicitly set using
      the function setRelevanceSum from the outside.
      
      If relevance=+-1 then this is the number of positive images in the query
  */
  double mPositiveRelevanceSum;
  /** This value depends on all the elements of the query, which
      have a negative user-assigned relevance.

      i.e. not necessarily only on the elements which contain 
      this feature, so it has to be explicitly set using
      the function setRelevanceSum from the outside.
      
      If relevance=+-1 then this is the number of negative images in the query
  */
  double mNegativeRelevanceSum;

  /* A pseudo term frequency calculated from the input
     at present by calculating the mean.

     mPositiveTermFrequency/mPositiveRelevanceSum is one term in a 
     a pseudo term frequency used for calculating query weights */
  double mPositiveTermFrequency;
  /* A pseudo term frequency calculated from the input
     at present by calculating the mean.

     mNegativeTermFrequency/mNegativeRelevanceSum is the other term in a 
     a pseudo term frequency used for calculating query weights */
  double mNegativeTermFrequency;

  /**  
       At present the feature description is a simple integer which expresses 
       if the feature is a histogram feature or not and if it is a texture feature
       or not. We probably will use more elaborate descriptions in the future.
   */
  int mFeatureDescription;

  /**  */
  TID mID;

  /** The accessor for the file on which the query is performed */
  const CAcInvertedFile* mAccessor;

  /** FIXME THERE IS A GOOD DESCRIPTION MISSING FOR THE NEXT
      TWO VARIABLES */
  mutable CQueryNormalizer* mQueryNormalizer;

  /** A normalizer for apply on self 
   */ 
  mutable CQueryNormalizer* mThisNormalizer;

  /**
     The query usually will separate into a part
     which is equal for all the query and a part which is to be 
     calculated for each document. The part which stays constant
  */
  double mQueryFactor;
  /**  */
  double mDocumentFactor;

public:

  /**
   *
   *  The query factor contains all informatio which
   *  depends only on the query. (for efficiency)
   *
   */
  double getQueryFactor()const;

  /**
   *
   * Calculate the QueryFactor.
   *
   */
  virtual void preCalculate();

  /**
   *
   * Constructor: 
   * @param inAccessor: the accessor containing this \
   *                     (for getting information about single documents)
   * @param inQueryNormalizer: FIXME
   * @param inThisNormalizer: FIXME
   */
  CWeightingFunction(const CAcInvertedFile* inAccessor=0,
		     CQueryNormalizer* inQueryNormalizer=0,
		     CQueryNormalizer* inThisNormalizer=0);

  /**
   *
   * Set the accessor (should not be needed) 
   *
   */
  void setAccessor(const CAcInvertedFile*);

  /**
   *
   *  Set the query normalizer (should not be needed);  
   *
   */
  void setNormalizers(CQueryNormalizer* inQueryNormalizer,
		      CQueryNormalizer* inThisNormalizer);

  /**
   *
   * Set the ID of this feature
   *
   */
  void setID(TID);

  /**
   *
   * get the ID of this feature 
   *
   */
  TID getID()const;

  /**
   *
   * Setting the relevance sum, 
   * that is the sum of the absolute values of all 
   * relevance levels of all documents of the query
   *
   * for rocchio we need this sum to be once calculated
   * for positive, once for negative feedback images
   * 
   */
  void setRelevanceSum(double inPositiveRelevanceSum,
		       double inNegativeRelevanceSum);

  /**
   *
   * Add a feature. A feature will be a document frequency element
   * out of the feature file.
   *
   */
  virtual void addQueryFeature(double inRelevanceLevel,
			       const CDocumentFrequencyElement& 
			       inQueryFeature);

  /**
   *
   * Giving a pseudo term frequency for normalization
   *
   */
  virtual double getTermFrequency()const;

  /**
   *
   * Apply this on a document frequency
   *
   */
  virtual double subApply(const double inDocumentFrequency,
			  const double inNormalizingFactor)const;

  /**
   *
   * Preparing the right parameters for subApply: Apply this on another feature
   *
   */
  virtual double apply(const CDocumentFrequencyElement& inResultFeature)const;

  /**
   *
   * Preparing the right parameters for subApply: Apply this on itself 
   *
   */
 
  double applyOnThis()const;

  /**For the "prototype pattern": 
     Kinda virtual copy constructor: 
     Gamma/Helm/Johnson/Vlissides p. 107*/
  virtual CWeightingFunction* constructNew(TID inID)const;

  /**For the "prototype pattern": 
     Kinda virtual copy constructor: 
     Gamma/Helm/Johnson/Vlissides p. 107

     This is a new version of constructNew which
     manages to live without the setID function
  */
  virtual CWeightingFunction* clone()const;

  /** This virtual destructor is here inorder to call the (inherited)
      default constructors
  */

  virtual ~CWeightingFunction();
  
  friend class CSortByDFTimesLogICF_WF;
};

/**
 *
 * 
 *
 */
bool operator<(const CWeightingFunction&,
	       const CWeightingFunction&);

/** CWeightingFunction: Sort by FeatureID  */
class CSortByFeatureID_WF:
  public binary_function
<CWeightingFunction,CWeightingFunction,bool>{
  /**  */
  inline bool operator()(const CWeightingFunction& l,
			 const CWeightingFunction& t){
    return l.getID()<t.getID();
  }
};

/**
 *
 * CWeightingFunction: Sort by DocumentFrequency/CollectionFrequency 
 *
 */ 
 
class CSortByDFTimesLogICF_WF:
  public binary_function
<CWeightingFunction,CWeightingFunction,bool>{
  /**  */
  inline bool operator()(const CWeightingFunction& l,
			 const CWeightingFunction& t){
    return 
      l.getTermFrequency()
      *
      fabs(log(l.mAccessor->FeatureToCollectionFrequency(l.getID())))
      <
      t.getTermFrequency()
      *
      fabs(log(t.mAccessor->FeatureToCollectionFrequency(t.getID())));
  };
};

/**
*
* CWeightingFunction: Sort by DocumentFrequency/CollectionFrequency 
* 
*/
class CSortByQueryFactor_WF:
  public binary_function
<CWeightingFunction,CWeightingFunction,bool>{
public:
  /**  */
  inline bool operator()(const CWeightingFunction& l,
			 const CWeightingFunction& t){
    return 
      l.getQueryFactor()
      <
      t.getQueryFactor();
  };
};
/**
   CWeightingFunction: Sort by the absolute value
   of the query factor. This is useful for pruning
   when the feedback is negative.
*/

class CSortByAbsQueryFactor_WF:
  public binary_function
<CWeightingFunction,CWeightingFunction,bool>{
public:
  /**  */
  inline bool operator()(const CWeightingFunction& l,
			 const CWeightingFunction& t){
    return 
      fabs(l.getQueryFactor())
      <
      fabs(t.getQueryFactor());
  };
};

/**
*
* 
*
*/
template<class CSortOp>
class CSortPointers_WF:
  binary_function<CWeightingFunction*,CWeightingFunction*,bool>{
protected:
  /**  */
  CSortOp mSorter;
public:
  /**  */
  inline CSortPointers_WF(){};
  /**  */
  inline bool operator()(const CWeightingFunction* l,
			 const CWeightingFunction* t){
    return mSorter(*l,*t);
  };
};

#include "libGIFTQuInvertedFile/include/CQueryNormalizer.h"

#endif