39 CFile(fname, rw, name)
87 void CUAIFile::init_with_defaults()
107 #define GET_VECTOR(read_func, sg_type) \
108 void CUAIFile::get_vector(sg_type*& vector, int32_t& len) \
110 if (!m_line_reader->has_next()) \
113 SGVector<char> line; \
114 int32_t num_elements = 0; \
116 line = m_line_reader->read_line(); \
117 m_tokenizer->set_text(line); \
118 while (m_tokenizer->has_next()) \
120 int32_t temp_start; \
121 m_tokenizer->next_token_idx(temp_start); \
125 vector = SG_MALLOC(sg_type, num_elements); \
126 m_parser->set_text(line); \
127 for (int32_t i=0; i<num_elements; i++) \
128 vector[i] = m_parser->read_func(); \
129 len = num_elements; \
146 #define SET_VECTOR(format, sg_type) \
147 void CUAIFile::set_vector(const sg_type* vector, int32_t len) \
152 for (i=0; i<len-1; i++) \
153 fprintf(file, "%" format "%c", vector[i], m_delimiter); \
154 fprintf(file, "%" format "\n", vector[i]); \
202 for (int32_t j=0; j<num_elems; j++)
216 if (data_size != data.
vlen)
217 SG_SERROR(
"Data size mismatch. Expected %d size data; \
218 got %d size data\n", data_size, data.
vlen);
225 REQUIRE ((strncmp(net_type,
"BAYES", 5) == 0 || strncmp(net_type,
"MARKOV", 6) == 0),
226 "Network type should be either MARKOV or BAYES");
229 for (uint32_t i=0; i<strlen(net_type); i++)
232 fprintf(
file,
"%s\n", net_type);
238 fprintf(
file,
"%d\n", num_vars);
244 "Variables mismatch. Expected %d variables, got %d variables",
254 fprintf(
file,
"%d\n", num_factors);
269 for (int32_t j=0; j<scope.
vlen; j++)
270 fprintf(
file,
"%d ", scope[j]);
295 int32_t& num_factors,
virtual void set_factors_table(int32_t num_factors, const SGVector< float64_t > *factors_table)
void set_text(SGVector< char > text)
SGVector< float64_t > * m_factors_table
SGVector< int32_t > m_vars_card
virtual void set_vector(const int8_t *vector, int32_t len)
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)
#define SET_VECTOR(format, sg_type)
CLineReader * m_line_reader
#define GET_VECTOR(read_func, sg_type)
SGVector< char > m_net_type
Class for buffered reading from a ascii file.
virtual void get_factors_table(SGVector< float64_t > *&factors_table)
virtual void get_vector(int8_t *&vector, int32_t &len)
virtual int32_t read_int()
CDelimiterTokenizer * m_tokenizer
virtual SGVector< char > read_string()
virtual SGVector< char > read_line()
SGVector< int32_t > * m_factors_scope
Class for reading from a string.
Class SGObject is the base class of all shogun objects.
A File access base class.
virtual void set_num_vars(int32_t num_vars)
void set_tokenizer(CTokenizer *tokenizer)
CDelimiterTokenizer * m_line_tokenizer
virtual void set_vars_card(SGVector< int32_t > vars_card)
virtual void set_factors_scope(int32_t num_factors, const SGVector< int32_t > *factors_scope)
all of classes and functions are contained in the shogun namespace
The class CDelimiterTokenizer is used to tokenize a SGVector into tokens using custom chars as ...
SGVector< bool > delimiters
virtual void set_num_factors(int32_t num_vars)
virtual void set_net_type(const char *net_type)