SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StreamingVwFile.cpp
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 
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 }

SHOGUN Machine Learning Toolbox - Documentation