SHOGUN  v3.2.0
StreamingVwFile.h
浏览该文件的文档.
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 
16 
17 namespace shogun
18 {
20 typedef int32_t (CVwParser::*parse_func)(CIOBuffer*, VwExample*&);
21 
27 {
28 public:
34 
41  CStreamingVwFile(const char* fname, char rw='r');
42 
46  virtual ~CStreamingVwFile();
47 
55 
66  virtual void get_vector(VwExample* &ex, int32_t &len);
67 
77  virtual void get_vector_and_label(VwExample* &ex, int32_t &len, float64_t &label);
78 
84  void set_env(CVwEnvironment* env_to_use)
85  {
86  parser->set_env(env_to_use);
87  }
88 
95  {
96  SG_REF(env);
97  return env;
98  }
99 
105  void set_write_to_cache(bool write_cache)
106  {
107  write_to_cache = write_cache;
108  parser->set_write_cache(write_cache);
109  }
110 
117 
118  virtual bool is_seekable() { return false; }
119 
121  virtual const char* get_name() const
122  {
123  return "StreamingVwFile";
124  }
125 
126 public:
129 
130 private:
134  virtual void init();
135 
136 protected:
139 
142 
145 
148 };
149 }
150 #endif //__STREAMING_VWFILE_H__
An I/O buffer class.
Definition: IOBuffer.h:44
virtual void get_vector_and_label(VwExample *&ex, int32_t &len, float64_t &label)
CVwEnvironment * get_env()
Class CVwEnvironment is the environment used by VW.
Definition: VwEnvironment.h:39
CVwParser * parser
Parser for vw format.
CVwParser is the object which provides the functions to parse examples from buffered input...
Definition: VwParser.h:46
E_VW_PARSER_TYPE
The type of input to parse.
Definition: VwParser.h:28
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:114
A Streaming File access class.
Definition: StreamingFile.h:39
double float64_t
Definition: common.h:48
void set_env(CVwEnvironment *env_to_use)
CVwEnvironment * env
Environment used for vw - used by parser.
#define SG_REF(x)
Definition: SGRefObject.h:34
int32_t(CVwParser::* parse_func)(CIOBuffer *, VwExample *&)
Parse function typedef. Takes an IOBuffer and VwExample as arguments.
Example class for VW.
Definition: vw_example.h:56
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:16
void set_env(CVwEnvironment *env_to_use)
Definition: VwParser.h:82
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