Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ClusterRep.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2002 University of Massachusetts.  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   Author: dmf 11/2002
00013 */
00014 
00015 #ifndef _CLUSTERREP_HPP
00016 #define _CLUSTERREP_HPP
00017 #include "common_headers.hpp"
00018 #include "FloatFreqVector.hpp"
00019 #include "Index.hpp"
00020 namespace lemur 
00021 {
00022   namespace cluster
00023   {
00024     
00026     class ClusterRep {
00027     public:
00029       ClusterRep(const lemur::api::Index &ind) : index(ind) {
00030         rep = new lemur::utility::FloatFreqVector();
00031       }
00033       ClusterRep(lemur::api::DOCID_T did, const lemur::api::Index &ind);
00035       ClusterRep(lemur::api::TermInfoList *tList, 
00036                  const lemur::api::Index &ind);
00038       ClusterRep(vector<lemur::api::DOCID_T> &dids, 
00039                  const lemur::api::Index &ind);
00041       ClusterRep(lemur::utility::FloatFreqVector *v, 
00042                  const lemur::api::Index &ind);
00044       ClusterRep(const ClusterRep *old);
00046       virtual ~ClusterRep();  
00048       virtual void normalize();
00050       double sum2() const {return rep->sum2();}
00051       // This should not be exposed...
00053       lemur::utility::FloatFreqVector *getRep() const {return rep;}
00055       void weigh(const double *vals){rep->weigh(vals);} 
00057       void weigh(double val){rep->weigh(val);} 
00059       void addVal(int id, double val) {rep->addVal(id, val);}  
00061       void addTerms(const vector<lemur::api::TERMID_T> &tids) {
00062         for (int i = 0; i < tids.size(); i++) {
00063           addVal(tids[i], 1);
00064         }
00065       }
00067       void addVec(const ClusterRep *v2){rep->addVec(v2->rep);}
00069       void subtract(const ClusterRep *v2){rep->subtract(v2->rep);}
00071       double dotProd(const ClusterRep *v2) const {
00072         return rep->dotProd(v2->rep);
00073       }
00074     private:
00075       lemur::utility::FloatFreqVector *rep;
00076       const lemur::api::Index &index;
00077     };
00078   }
00079 }
00080 
00081 #endif /* _CLUSTERREP_HPP */

Generated on Tue Jun 15 11:02:53 2010 for Lemur by doxygen 1.3.4