SHOGUN  5.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
StreamingVwFile.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) 2011 Shashwat Lal Das
8  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
9  */
10 #ifndef __STREAMING_VWFILE_H__
11 #define __STREAMING_VWFILE_H__
12 
13 #include <shogun/lib/config.h>
14 
18 
19 namespace shogun
20 {
22 typedef int32_t (CVwParser::*parse_func)(CIOBuffer*, VwExample*&);
23 
29 {
30 public:
36 
43  CStreamingVwFile(const char* fname, char rw='r');
44 
48  virtual ~CStreamingVwFile();
49 
57 
68  virtual void get_vector(VwExample* &ex, int32_t &len);
69 
79  virtual void get_vector_and_label(VwExample* &ex, int32_t &len, float64_t &label);
80 
86  void set_env(CVwEnvironment* env_to_use)
87  {
88  parser->set_env(env_to_use);
89  }
90 
97  {
98  return env;
99  }
100 
106  void set_write_to_cache(bool write_cache)
107  {
108  write_to_cache = write_cache;
109  parser->set_write_cache(write_cache);
110  }
111 
118 
119  virtual bool is_seekable() { return false; }
120 
122  virtual const char* get_name() const
123  {
124  return "StreamingVwFile";
125  }
126 
127 public:
130 
131 private:
135  virtual void init();
136 
137 protected:
140 
143 
146 
149 };
150 }
151 #endif //__STREAMING_VWFILE_H__
An I/O buffer class.
Definition: IOBuffer.h:41
virtual void get_vector_and_label(VwExample *&ex, int32_t &len, float64_t &label)
CVwEnvironment * get_env()
int32_t(CVwParser::* parse_func)(CIOBuffer *, VwExample *&)
Parse function typedef. Takes an IOBuffer and VwExample as arguments.
Class CVwEnvironment is the environment used by VW.
Definition: VwEnvironment.h:41
CVwParser * parser
Parser for vw format.
CVwParser is the object which provides the functions to parse examples from buffered input...
Definition: VwParser.h:48
E_VW_PARSER_TYPE
The type of input to parse.
Definition: VwParser.h:30
void set_parser_type(E_VW_PARSER_TYPE type=T_VW)
bool write_to_cache
Write data to a binary cache file.
E_VW_PARSER_TYPE parser_type
Parser type.
void set_write_cache(bool wr_cache)
Definition: VwParser.h:119
A Streaming File access class.
Definition: StreamingFile.h:34
double float64_t
Definition: common.h:50
void set_env(CVwEnvironment *env_to_use)
CVwEnvironment * env
Environment used for vw - used by parser.
Example class for VW.
Definition: vw_example.h:58
void set_write_to_cache(bool write_cache)
Class StreamingVwFile to read vector-by-vector from Vowpal Wabbit data files. It reads the example an...
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
void set_env(CVwEnvironment *env_to_use)
Definition: VwParser.h:83
parse_func parse_example
The function which will be called for parsing.
virtual void get_vector(VwExample *&ex, int32_t &len)
virtual const char * get_name() const

SHOGUN Machine Learning Toolbox - Documentation