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

phimbl.h

Go to the documentation of this file.
00001 /* phimbl.h    $Revision: 1.2 $ $Date: 2005/12/10 20:33:54 $
00002    Copyright (C) 2003 University of Bonn.
00003    http://www.ikp.uni-bonn.de/boss
00004 
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU General Public License
00007    as published by the Free Software Foundation; either version 2
00008    of the License, or (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA  02111-1307, USA.
00019 */
00020 
00025 #ifndef PHIMBL_H
00026 #define PHIMBL_H
00027 
00028 using namespace std;
00029 
00030 #include <iostream>
00031 #include <string>
00032 #include <vector>
00033 #include <map>
00034 #include <fstream>
00035 #include <sstream>
00036 #include "boss_utility/boss_types.h"
00037 
00038 namespace BOSS
00039 {
00040 class Phimbl
00041 {
00042 protected:
00043   struct t_Node
00044   {
00045     t_Node* parent;
00046     int Class;
00047     //int max;
00048     map <int,int> count;
00049     struct t_Child
00050     {
00051       int Feature;
00052       t_Node* node;
00053     };
00054     vector <t_Child*> child;
00055     t_Node(){parent = NULL;}
00056   };
00057 
00058  public:
00059   struct t_Data
00060   {
00061     t_Node* currentNode;
00062     t_Node* root;
00063     vector <int> permutation;
00064     vector <string> classes;
00065     vector <string> features;
00066     t_Data(){currentNode = root = NULL;}
00067   };
00068 
00069  protected:
00070   struct t_classes
00071   {
00072     string class_string;
00073     int count;
00074     vector <string> features;
00075   };
00076 
00077   struct t_features
00078   {
00079     string feature_string;
00080     int count;
00081   };
00082 
00083   vector <t_classes> classes;
00084   vector <vector <t_features> > features;
00085   vector <t_features> allfeatures;
00086   int feature_count;
00087   int line_count;
00088   string seperator;
00089   t_Node* tree;
00090   t_Data Data;
00091   
00092   int find_str(string & str, vector <t_classes> & data);
00093   int find_str(string & str, vector <t_features> & data);
00094 
00095   void ReduceTree(t_Node * node);
00096   void DeleteNode(t_Node * node);
00097   void SaveTree(t_Node * node, fstream & out);
00098   bool Load(string filename);
00099   void Calculate_Permutation();
00100   void Bulid_Tree(string filename);
00101   void ClassCount(t_Node * node);
00102   bool Save(string outfile);
00103   void Print_Permutation();
00104   void AddChild(t_Node* parent, string & str, int pos, t_Data & Data);
00105 
00106 public:
00107   Phimbl();
00108   ~Phimbl();
00109 
00110   vector <int> permutation;
00111   bool Learn(const string & filename);
00112   bool Write(const string & filename);
00113   bool Classify(const BOSS::t_SVector & str, string & res, const t_Data & Data) const;
00114   bool operator () (string & filename);
00115   bool LoadTree(const char* filename, t_Data & Data);
00116   void DeleteData(t_Data & Data);
00117 };
00118 }
00119 
00120 #endif

Generated on Tue Dec 20 23:14:38 2005 for BOSS by doxygen 1.3.6