Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

FloatFreqVector.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2001 Carnegie Mellon University.  All Rights Reserved.
00003  *
00004  * Use of the Lemur Toolkit for Language Modeling and Information Retrieval
00005  * is subject to the terms of the software license set forth in the LICENSE
00006  * file included with this software, and also available at
00007  * http://www.lemurproject.org/license.html
00008  *
00009  *==========================================================================
00010 */
00011 
00012 
00013 #ifndef _FLOATFREQVECTOR_HPP
00014 #define _FLOATFREQVECTOR_HPP
00015 
00016 #include "FreqVector.hpp"
00017 
00019 class FloatFreqCounter {
00020 public:
00021   TERMID_T key;
00022   // used for termid->f mappings, no need to compute a hash
00023   unsigned int Hash() const { return (unsigned int)key; }
00024   unsigned int hash() const { return Hash(); }
00025   bool operator==(const FloatFreqCounter count) { return count.key == this->key;} 
00026 };
00027 
00028 class FloatFreqVector : public FreqVector, public CSet<FloatFreqCounter, double> {
00029 public:
00030   FloatFreqVector() : CSet<FloatFreqCounter, double>(1000) {s2 = 0;}
00032   FloatFreqVector(const Index &index, DOCID_T docID);
00033   FloatFreqVector(const Index &index, TermInfoList *tList);
00034   FloatFreqVector(const Index &index, vector<DOCID_T> &dids);
00035   FloatFreqVector(FloatFreqVector *old);
00036 
00037   virtual ~FloatFreqVector() {};
00038   virtual bool find(TERMID_T ind, double &freq) const;
00039   virtual void startIteration() const {  i=0; }
00040   virtual bool hasMore() const {  return (i < size()); }
00041   virtual void nextFreq(TERMID_T &id, double &freq) const;
00043   virtual int size() const {    return (ISet<FloatFreqCounter>::size()); }
00044 
00045   virtual void nextFreq (TERMID_T &id, int &freq)  const;
00046   virtual bool find(TERMID_T ind, int &freq) const ;
00047 
00048   void addVal(TERMID_T id, int cnt);
00049   void addVal(TERMID_T id, double val);
00050   double sum() const; 
00051   double sum2() const;
00052   void weigh(const double *vals);
00053   void weigh(double vals); 
00054   void addVec(const FloatFreqVector *v2);
00055   void subtract(const FloatFreqVector *v2); 
00056   double dotProd(const FloatFreqVector *v2);
00057 
00058 protected:
00059   mutable int i;
00060   mutable double s2;
00061   
00062 };
00063 
00064 #endif /* _FLOATFREQVECTOR_HPP */

Generated on Wed Nov 3 12:58:55 2004 for Lemur Toolkit by doxygen1.2.18