00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _FLOATFREQVECTOR_HPP
00014 #define _FLOATFREQVECTOR_HPP
00015
00016 #include "FreqVector.hpp"
00017 namespace lemur
00018 {
00019 namespace utility
00020 {
00022 class FloatFreqCounter {
00023 public:
00024 lemur::api::TERMID_T key;
00025
00026 unsigned int Hash() const { return (unsigned int)key; }
00027 unsigned int hash() const { return Hash(); }
00028 bool operator==(const FloatFreqCounter count) { return count.key == this->key;}
00029 };
00031 class FloatFreqVector : public FreqVector,
00032 public CSet<FloatFreqCounter, double> {
00033 public:
00034 FloatFreqVector() : CSet<FloatFreqCounter, double>(1000) {s2 = 0;}
00036 FloatFreqVector(const lemur::api::Index &index,
00037 lemur::api::DOCID_T docID);
00038 FloatFreqVector(const lemur::api::Index &index,
00039 lemur::api::TermInfoList *tList);
00040 FloatFreqVector(const lemur::api::Index &index,
00041 vector<lemur::api::DOCID_T> &dids);
00042 FloatFreqVector(FloatFreqVector *old);
00043
00044 virtual ~FloatFreqVector() {};
00045 virtual bool find(lemur::api::TERMID_T ind, double &freq) const;
00046 virtual void startIteration() const { i=0; }
00047 virtual bool hasMore() const { return (i < size()); }
00048 virtual void nextFreq(lemur::api::TERMID_T &id, double &freq) const;
00050 virtual int size() const { return (ISet<FloatFreqCounter>::size()); }
00051
00052 virtual void nextFreq (lemur::api::TERMID_T &id, int &freq) const;
00053 virtual bool find(lemur::api::TERMID_T ind, int &freq) const ;
00054
00055 void addVal(lemur::api::TERMID_T id, int cnt);
00056 void addVal(lemur::api::TERMID_T id, double val);
00057 double sum() const;
00058 double sum2() const;
00059 void weigh(const double *vals);
00060 void weigh(double vals);
00061 void addVec(const FloatFreqVector *v2);
00062 void subtract(const FloatFreqVector *v2);
00063 double dotProd(const FloatFreqVector *v2);
00064
00065 protected:
00066 mutable int i;
00067 mutable double s2;
00068
00069 };
00070 }
00071 }
00072
00073 #endif