SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
StreamingVwFile.cpp
浏览该文件的文档.
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 
12 
13 using namespace shogun;
14 
16  : CStreamingFile()
17 {
18  init();
19 }
20 
21 CStreamingVwFile::CStreamingVwFile(const char* fname, char rw)
22  : CStreamingFile(fname, rw)
23 {
24  init();
25 }
26 
28 {
29  SG_UNREF(env);
31 }
32 
34 {
35  switch (type)
36  {
37  case T_VW:
39  parser_type = T_VW;
40  return;
41  case T_SVMLIGHT:
44  return;
45  case T_DENSE:
48  return;
49  }
50 
51  SG_SERROR("Unrecognized parser type!\n")
52 }
53 
54 void CStreamingVwFile::get_vector(VwExample* &ex, int32_t &len)
55 {
56  len = (parser->*parse_example)(buf, ex);
57  if (len == 0)
58  len = -1; // indicates failure
59 }
60 
62 {
63  len = (parser->*parse_example)(buf, ex);
64  if (len == 0)
65  len = -1; // indicates failure
66 }
67 
68 void CStreamingVwFile::init()
69 {
70  parser = new CVwParser();
71  env = parser->get_env();
72 
74  write_to_cache = false;
75  SG_REF(env);
76 }
virtual void get_vector_and_label(VwExample *&ex, int32_t &len, float64_t &label)
int32_t read_features(CIOBuffer *buf, VwExample *&ex)
Definition: VwParser.cpp:48
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.
int32_t read_dense_features(CIOBuffer *buf, VwExample *&ae)
Definition: VwParser.cpp:206
CVwEnvironment * get_env()
Definition: VwParser.h:73
#define SG_REF(x)
Definition: SGObject.h:51
A Streaming File access class.
Definition: StreamingFile.h:34
CIOBuffer * buf
Buffer to hold stuff in memory.
int32_t read_svmlight_features(CIOBuffer *buf, VwExample *&ae)
Definition: VwParser.cpp:164
double float64_t
Definition: common.h:50
CVwEnvironment * env
Environment used for vw - used by parser.
Example class for VW.
Definition: vw_example.h:58
#define SG_UNREF(x)
Definition: SGObject.h:52
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
#define SG_SERROR(...)
Definition: SGIO.h:179
parse_func parse_example
The function which will be called for parsing.
virtual void get_vector(VwExample *&ex, int32_t &len)

SHOGUN 机器学习工具包 - 项目文档