SHOGUN  4.0.0
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 
46  CUAIFile(int fd, const char* mode, const char* name=NULL);
47 
54  CUAIFile(const char* fname, char rw='r', const char* name=NULL);
55 
57  virtual ~CUAIFile();
58 
63  virtual void parse();
64 
70  virtual void set_net_type(const char* net_type);
71 
76  virtual void set_num_vars(int32_t num_vars);
77 
82  virtual void set_num_factors(int32_t num_vars);
83 
88  virtual void set_vars_card(SGVector<int32_t> vars_card);
89 
95  virtual void set_factors_scope(int32_t num_factors,
96  const SGVector<int32_t>* factors_scope);
97 
103  virtual void set_factors_table(int32_t num_factors,
104  const SGVector<float64_t>* factors_table);
105 
114  virtual void get_preamble(SGVector<char>& net_type,
115  int32_t& num_vars,
116  SGVector<int32_t>& vars_card,
117  int32_t& num_factors,
118  SGVector<int32_t>*& factors_scope);
119 
124  virtual void get_factors_table(SGVector<float64_t>*& factors_table);
125 
126 #ifndef SWIG // SWIG should skip this
127 
134  virtual void get_vector(int8_t*& vector, int32_t& len);
135  virtual void get_vector(uint8_t*& vector, int32_t& len);
136  virtual void get_vector(char*& vector, int32_t& len);
137  virtual void get_vector(int32_t*& vector, int32_t& len);
138  virtual void get_vector(uint32_t*& vector, int32_t& len);
139  virtual void get_vector(float64_t*& vector, int32_t& len);
140  virtual void get_vector(float32_t*& vector, int32_t& len);
141  virtual void get_vector(floatmax_t*& vector, int32_t& len);
142  virtual void get_vector(int16_t*& vector, int32_t& len);
143  virtual void get_vector(uint16_t*& vector, int32_t& len);
144  virtual void get_vector(int64_t*& vector, int32_t& len);
145  virtual void get_vector(uint64_t*& vector, int32_t& len);
147 
149  /*virtual void get_vector(void*& vector, int32_t& len, DataType& dtype);*/
150 
158  virtual void set_vector(const int8_t* vector, int32_t len);
159  virtual void set_vector(const uint8_t* vector, int32_t len);
160  virtual void set_vector(const char* vector, int32_t len);
161  virtual void set_vector(const int32_t* vector, int32_t len);
162  virtual void set_vector(const uint32_t* vector, int32_t len);
163  virtual void set_vector(const float32_t* vector, int32_t len);
164  virtual void set_vector(const float64_t* vector, int32_t len);
165  virtual void set_vector(const floatmax_t* vector, int32_t len);
166  virtual void set_vector(const int16_t* vector, int32_t len);
167  virtual void set_vector(const uint16_t* vector, int32_t len);
168  virtual void set_vector(const int64_t* vector, int32_t len);
169  virtual void set_vector(const uint64_t* vector, int32_t len);
171 
172 #endif // #ifndef SWIG // SWIG should skip this
173 
174  virtual const char* get_name() const { return "UAIFile"; }
175 
176 private:
178  void init();
179 
181  void init_with_defaults();
182 
183 protected:
186 
189 
192 
195 
198 
200  int32_t m_num_vars;
201 
203  int32_t m_num_factors;
204 
207 
210 
213 
216 };
217 
218 }
219 
220 #endif
virtual void set_factors_table(int32_t num_factors, const SGVector< float64_t > *factors_table)
Definition: UAIFile.cpp:273
SGVector< float64_t > * m_factors_table
Definition: UAIFile.h:215
SGVector< int32_t > m_vars_card
Definition: UAIFile.h:209
virtual void set_vector(const int8_t *vector, int32_t len)
virtual ~CUAIFile()
Definition: UAIFile.cpp:43
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:290
CLineReader * m_line_reader
Definition: UAIFile.h:185
virtual const char * get_name() const
Definition: UAIFile.h:174
SGVector< char > m_net_type
Definition: UAIFile.h:206
Class for buffered reading from a ascii file.
Definition: LineReader.h:24
char m_delimiter
Definition: UAIFile.h:197
virtual void get_factors_table(SGVector< float64_t > *&factors_table)
Definition: UAIFile.cpp:306
virtual void get_vector(int8_t *&vector, int32_t &len)
CDelimiterTokenizer * m_tokenizer
Definition: UAIFile.h:194
SGVector< int32_t > * m_factors_scope
Definition: UAIFile.h:212
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:200
virtual void set_num_vars(int32_t num_vars)
Definition: UAIFile.cpp:233
float float32_t
Definition: common.h:49
CDelimiterTokenizer * m_line_tokenizer
Definition: UAIFile.h:191
virtual void set_vars_card(SGVector< int32_t > vars_card)
Definition: UAIFile.cpp:239
virtual void set_factors_scope(int32_t num_factors, const SGVector< int32_t > *factors_scope)
Definition: UAIFile.cpp:255
CParser * m_parser
Definition: UAIFile.h:188
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:249
virtual void parse()
Definition: UAIFile.cpp:171
int32_t m_num_factors
Definition: UAIFile.h:203
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:221

SHOGUN Machine Learning Toolbox - Documentation