SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
UAIFile.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2014 Abinash Panda
8  */
9 
10 #ifndef __UAIFILE_H__
11 #define __UAIFILE_H__
12 
13 #include <shogun/io/File.h>
14 
15 #include <shogun/io/LineReader.h>
16 #include <shogun/io/Parser.h>
18 #include <shogun/base/Parameter.h>
19 
20 namespace shogun
21 {
22 
27 class CUAIFile : public CFile
28 {
29 public:
31  CUAIFile();
32 
38  CUAIFile(FILE* f, const char* name=NULL);
39 
40 #ifdef HAVE_FDOPEN
41 
47  CUAIFile(int fd, const char* mode, const char* name=NULL);
48 #endif
49 
56  CUAIFile(const char* fname, char rw='r', const char* name=NULL);
57 
59  virtual ~CUAIFile();
60 
65  virtual void parse();
66 
72  virtual void set_net_type(const char* net_type);
73 
78  virtual void set_num_vars(int32_t num_vars);
79 
84  virtual void set_num_factors(int32_t num_vars);
85 
90  virtual void set_vars_card(SGVector<int32_t> vars_card);
91 
97  virtual void set_factors_scope(int32_t num_factors,
98  const SGVector<int32_t>* factors_scope);
99 
105  virtual void set_factors_table(int32_t num_factors,
106  const SGVector<float64_t>* factors_table);
107 
116  virtual void get_preamble(SGVector<char>& net_type,
117  int32_t& num_vars,
118  SGVector<int32_t>& vars_card,
119  int32_t& num_factors,
120  SGVector<int32_t>*& factors_scope);
121 
126  virtual void get_factors_table(SGVector<float64_t>*& factors_table);
127 
128 #ifndef SWIG // SWIG should skip this
129 
136  virtual void get_vector(int8_t*& vector, int32_t& len);
137  virtual void get_vector(uint8_t*& vector, int32_t& len);
138  virtual void get_vector(char*& vector, int32_t& len);
139  virtual void get_vector(int32_t*& vector, int32_t& len);
140  virtual void get_vector(uint32_t*& vector, int32_t& len);
141  virtual void get_vector(float64_t*& vector, int32_t& len);
142  virtual void get_vector(float32_t*& vector, int32_t& len);
143  virtual void get_vector(floatmax_t*& vector, int32_t& len);
144  virtual void get_vector(int16_t*& vector, int32_t& len);
145  virtual void get_vector(uint16_t*& vector, int32_t& len);
146  virtual void get_vector(int64_t*& vector, int32_t& len);
147  virtual void get_vector(uint64_t*& vector, int32_t& len);
149 
151  /*virtual void get_vector(void*& vector, int32_t& len, DataType& dtype);*/
152 
160  virtual void set_vector(const int8_t* vector, int32_t len);
161  virtual void set_vector(const uint8_t* vector, int32_t len);
162  virtual void set_vector(const char* vector, int32_t len);
163  virtual void set_vector(const int32_t* vector, int32_t len);
164  virtual void set_vector(const uint32_t* vector, int32_t len);
165  virtual void set_vector(const float32_t* vector, int32_t len);
166  virtual void set_vector(const float64_t* vector, int32_t len);
167  virtual void set_vector(const floatmax_t* vector, int32_t len);
168  virtual void set_vector(const int16_t* vector, int32_t len);
169  virtual void set_vector(const uint16_t* vector, int32_t len);
170  virtual void set_vector(const int64_t* vector, int32_t len);
171  virtual void set_vector(const uint64_t* vector, int32_t len);
173 
174 #endif // #ifndef SWIG // SWIG should skip this
175 
176  virtual const char* get_name() const { return "UAIFile"; }
177 
178 private:
180  void init();
181 
183  void init_with_defaults();
184 
185 protected:
188 
191 
194 
197 
200 
202  int32_t m_num_vars;
203 
205  int32_t m_num_factors;
206 
209 
212 
215 
218 };
219 
220 }
221 
222 #endif
virtual void set_factors_table(int32_t num_factors, const SGVector< float64_t > *factors_table)
Definition: UAIFile.cpp:275
SGVector< float64_t > * m_factors_table
Definition: UAIFile.h:217
SGVector< int32_t > m_vars_card
Definition: UAIFile.h:211
virtual void set_vector(const int8_t *vector, int32_t len)
virtual ~CUAIFile()
Definition: UAIFile.cpp:45
virtual void get_preamble(SGVector< char > &net_type, int32_t &num_vars, SGVector< int32_t > &vars_card, int32_t &num_factors, SGVector< int32_t > *&factors_scope)
Definition: UAIFile.cpp:292
CLineReader * m_line_reader
Definition: UAIFile.h:187
virtual const char * get_name() const
Definition: UAIFile.h:176
SGVector< char > m_net_type
Definition: UAIFile.h:208
Class for buffered reading from a ascii file.
Definition: LineReader.h:24
char m_delimiter
Definition: UAIFile.h:199
virtual void get_factors_table(SGVector< float64_t > *&factors_table)
Definition: UAIFile.cpp:308
virtual void get_vector(int8_t *&vector, int32_t &len)
CDelimiterTokenizer * m_tokenizer
Definition: UAIFile.h:196
SGVector< int32_t > * m_factors_scope
Definition: UAIFile.h:214
Class for reading from a string.
Definition: Parser.h:23
double float64_t
Definition: common.h:50
long double floatmax_t
Definition: common.h:51
A File access base class.
Definition: File.h:34
int32_t m_num_vars
Definition: UAIFile.h:202
virtual void set_num_vars(int32_t num_vars)
Definition: UAIFile.cpp:235
float float32_t
Definition: common.h:49
CDelimiterTokenizer * m_line_tokenizer
Definition: UAIFile.h:193
virtual void set_vars_card(SGVector< int32_t > vars_card)
Definition: UAIFile.cpp:241
virtual void set_factors_scope(int32_t num_factors, const SGVector< int32_t > *factors_scope)
Definition: UAIFile.cpp:257
CParser * m_parser
Definition: UAIFile.h:190
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class CDelimiterTokenizer is used to tokenize a SGVector into tokens using custom chars as ...
virtual void set_num_factors(int32_t num_vars)
Definition: UAIFile.cpp:251
virtual void parse()
Definition: UAIFile.cpp:173
int32_t m_num_factors
Definition: UAIFile.h:205
Class UAIFILE used to read data from UAI files. See http://graphmod.ics.uci.edu/uai08/FileFormat for ...
Definition: UAIFile.h:27
virtual void set_net_type(const char *net_type)
Definition: UAIFile.cpp:223

SHOGUN Machine Learning Toolbox - Documentation