Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class 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>
00021 namespace lemur
00022 {
00023   namespace cluster
00024   {
00026     class KeyfileClusterDB : public lemur::api::ClusterDB {
00027 
00028     public:
00030       KeyfileClusterDB(const lemur::api::Index *ind, 
00031                        const string &name,                 
00032                        double threshold = 0.25,
00033                        enum ClusterParam::simTypes simType = ClusterParam::COS,
00034                        enum ClusterParam::clusterTypes 
00035                        clusterType = ClusterParam::CENTROID,
00036                        enum ClusterParam::docModes docMode = ClusterParam::DMAX);
00037 
00039       virtual ~KeyfileClusterDB();
00040 
00042       virtual vector<Cluster*> getDocCluster(lemur::api::DOCID_T docId) const ;
00043 
00045       virtual int countClusters() const {
00046         //clustersKey.get("NUMCLUSTERS");
00047         int clusterCount = 0, actual;
00048         clustersKey.get("NUMCLUSTERS", &clusterCount, actual, sizeof(int));
00049         return  clusterCount;
00050       }
00051 
00053       virtual int maxID() const {// get
00054         //clustersKey.get("MAXID");
00055         int clusterIDCounter = 0, actual;
00056         clustersKey.get("MAXID", &clusterIDCounter, actual, sizeof(int));
00057         return  clusterIDCounter;
00058       }
00059   
00060 
00062       virtual Cluster *getCluster(int clusterId) const ;
00063 
00065       virtual vector<int> getDocClusterId(lemur::api::DOCID_T docId) const ;
00066 
00068       virtual int addToCluster(lemur::api::DOCID_T docId, int clusterId, 
00069                                double score);
00070 
00072       virtual int addToCluster(lemur::api::DOCID_T docId, Cluster *cluster, 
00073                                double score);
00074 
00076       virtual int removeFromCluster(lemur::api::DOCID_T docId, int clusterID);
00077 
00079       virtual int deleteCluster(int clusterID);
00080 
00082       virtual int deleteCluster(Cluster * cluster);
00083 
00085       virtual vector<int> splitCluster(int cid, int num = 2);
00086 
00088       virtual int mergeClusters(int cid1, int cid2);
00089 
00090     protected:
00092       virtual Cluster * newCluster();
00093 
00094     private:
00096       mutable lemur::file::Keyfile doc2cluster;
00097       mutable lemur::file::Keyfile clustersKey;
00098       void init(const string &name);
00099       void addC2D(int cid, const vector<lemur::api::DOCID_T> &dids);
00100     };
00101   }
00102 }
00103 
00104 #endif

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