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

KeyfileClusterDB.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 // David Fisher
00013 // init: 05/11/2004
00014 #ifndef _KEYFILECLUSTERDB_HPP
00015 #define _KEYFILECLUSTERDB_HPP
00016 
00017 #include "ClusterDB.hpp"
00018 #include "IndexedReal.hpp"
00019 #include "Keyfile.hpp"
00020 #include <string>
00023 class KeyfileClusterDB : public ClusterDB {
00024 
00025 public:
00027   KeyfileClusterDB(const Index *ind, 
00028                     const string &name,                    
00029                     double threshold = 0.25,
00030                     enum ClusterParam::simTypes simType = ClusterParam::COS,
00031                     enum ClusterParam::clusterTypes 
00032                       clusterType = ClusterParam::CENTROID,
00033                     enum ClusterParam::docModes docMode = ClusterParam::DMAX);
00034 
00036   virtual ~KeyfileClusterDB();
00037 
00039   virtual vector<Cluster*> getDocCluster(DOCID_T docId) const ;
00040 
00042   virtual int countClusters() const {
00043   //clustersKey.get("NUMCLUSTERS");
00044     int clusterCount = 0, actual;
00045     clustersKey.get("NUMCLUSTERS", &clusterCount, actual, sizeof(int));
00046     return  clusterCount;
00047   }
00048 
00050   virtual int maxID() const {// get
00051   //clustersKey.get("MAXID");
00052     int clusterIDCounter = 0, actual;
00053     clustersKey.get("MAXID", &clusterIDCounter, actual, sizeof(int));
00054     return  clusterIDCounter;
00055   }
00056   
00057 
00059   virtual Cluster *getCluster(int clusterId) const ;
00060 
00062   virtual vector<int> getDocClusterId(DOCID_T docId) const ;
00063 
00065   virtual int addToCluster(DOCID_T docId, int clusterId, double score);
00066 
00068   virtual int addToCluster(DOCID_T docId, Cluster *cluster, double score);
00069 
00071   virtual int removeFromCluster(DOCID_T docId, int clusterID);
00072 
00074   virtual int deleteCluster(int clusterID);
00075 
00077   virtual int deleteCluster(Cluster * cluster);
00078 
00080   virtual vector<int> splitCluster(int cid, int num = 2);
00081 
00083   virtual int mergeClusters(int cid1, int cid2);
00084 
00085 protected:
00087   virtual Cluster * newCluster();
00088 
00089 private:
00091   mutable Keyfile doc2cluster;
00092   mutable Keyfile clustersKey;
00093   void init(const string &name);
00094   void addC2D(int cid, const vector<DOCID_T> &dids);
00095 };
00096 #endif

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