|
FreeLing
3.0
|
00001 00002 // 00003 // Omlet - Open Machine Learning Enhanced Toolkit 00004 // 00005 // Copyright (C) 2006 TALP Research Center 00006 // Universitat Politecnica de Catalunya 00007 // 00008 // This file is part of the Omlet library 00009 // 00010 // The Omlet library is free software; you can redistribute it 00011 // and/or modify it under the terms of the GNU General Public 00012 // License as published by the Free Software Foundation; either 00013 // version 3 of the License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 51 Franklin St, 5th Floor, Boston, MA 02110-1301 USA 00023 // 00024 // contact: Lluis Padro (padro@lsi.upc.es) 00025 // TALP Research Center 00026 // despatx Omega.S112 - Campus Nord UPC 00027 // 08034 Barcelona. SPAIN 00028 // 00030 00031 // 00032 // Author: Xavier Carreras 00033 // 00034 00035 #ifndef _DATASET 00036 #define _DATASET 00037 00038 #include <list> 00039 #include <vector> 00040 #include "freeling/omlet/example.h" 00041 00042 00047 00048 class dataset : public std::list<std::list<example>::iterator> 00049 { 00050 private: 00052 static std::list<example> all_examples; 00053 00054 std::vector<int> size_pos; 00055 std::vector<int> size_neg; 00056 int dimension; 00057 int nlabels; 00058 void add_member(std::list<example>::iterator); 00059 00060 public: 00061 dataset(int nlabels); 00062 00064 void add_example(const example &); 00065 00067 // int get_size() const; 00068 int get_negative_size(int l) const; 00069 int get_positive_size(int l) const; 00070 int get_nlabels() const; 00071 int get_dimension() const; 00072 00073 void split(int feature, dataset &ds0, dataset &ds1) const; 00074 00075 class iterator : public std::list<std::list<example>::iterator>::iterator { 00076 public: 00077 iterator () {}; 00078 iterator (std::list<std::list<example>::iterator>::iterator x) : std::list<std::list<example>::iterator>::iterator(x) {} 00079 example& operator*() { 00080 return std::list<std::list<example>::iterator>::iterator::operator*().operator*(); 00081 }; 00082 example* operator->() { 00083 return std::list<std::list<example>::iterator>::iterator::operator*().operator->(); 00084 }; 00085 }; 00086 00087 class const_iterator : public std::list<std::list<example>::iterator>::const_iterator { 00088 public: 00089 const_iterator () {}; 00090 const_iterator (std::list<std::list<example>::iterator>::const_iterator x) : std::list<std::list<example>::iterator>::const_iterator(x) {} 00091 example& operator*() { 00092 return std::list<std::list<example>::iterator>::const_iterator::operator*().operator*(); 00093 }; 00094 example* operator->() { 00095 return std::list<std::list<example>::iterator>::const_iterator::operator*().operator->(); 00096 }; 00097 }; 00098 00099 iterator begin() { return std::list<std::list<example>::iterator>::begin(); }; 00100 iterator end() { return std::list<std::list<example>::iterator>::end(); }; 00101 const_iterator begin() const { return std::list<std::list<example>::iterator>::begin(); }; 00102 const_iterator end() const { return std::list<std::list<example>::iterator>::end(); }; 00103 00104 }; 00105 00106 #endif 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125
1.7.6.1