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

FlatFileClusterDB.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 // Peter Amstutz
00013 // init: 12/17/2002
00014 #ifndef _FLATFILECLUSTERDB_HPP
00015 #define _FLATFILECLUSTERDB_HPP
00016 
00017 #include "ClusterDB.hpp"
00018 #include "IndexedReal.hpp"
00019 #include <string>
00020 namespace lemur 
00021 {
00022   namespace cluster
00023   {
00025     class FlatFileClusterDB : public lemur::api::ClusterDB {
00026 
00027     public:
00029       FlatFileClusterDB(const lemur::api::Index *ind, 
00030                         const string &name,                
00031                         double threshold = 0.25,
00032                         enum ClusterParam::simTypes simType = ClusterParam::COS,
00033                         enum ClusterParam::clusterTypes 
00034                         clusterType = ClusterParam::CENTROID,
00035                         enum ClusterParam::docModes docMode = ClusterParam::DMAX);
00036 
00038       virtual ~FlatFileClusterDB();
00039 
00041       virtual vector<Cluster*> getDocCluster(lemur::api::DOCID_T docId) const;
00042 
00044       virtual int countClusters() const {return clusterCount - 1;}
00045 
00047       virtual int maxID() const{return clusterIdCounter - 1;}
00048 
00050       virtual Cluster *getCluster(int clusterId) const;
00051 
00053       virtual vector<int> getDocClusterId(lemur::api::DOCID_T docId) const;
00054 
00056       virtual int addToCluster(lemur::api::DOCID_T docId, int clusterId, 
00057                                double score);
00058 
00060       virtual int addToCluster(lemur::api::DOCID_T docId, Cluster *cluster, 
00061                                double score);
00062 
00064       virtual int removeFromCluster(lemur::api::DOCID_T docId, int clusterID);
00065 
00067       virtual int deleteCluster(int clusterID);
00068 
00070       virtual int deleteCluster(Cluster * cluster);
00071 
00073       virtual vector<int> splitCluster(int cid, int num = 2);
00074 
00076       virtual int mergeClusters(int cid1, int cid2);
00077 
00078     protected:
00080       virtual Cluster * newCluster();
00081 
00082     private:
00083       int clusterCount;
00084       int clusterIdCounter;
00085       string clusterDB;
00087       int *doc2cluster;
00088       void readClusterDB();
00089       void writeClusterDB();
00090       void init(const string &name);
00091     };
00092   }
00093 }
00094 
00095 #endif

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