SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StreamingStringFeatures.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_STRINGFEATURES__H__
11 #define _STREAMING_STRINGFEATURES__H__
12 
13 #include <shogun/lib/config.h>
14 
15 #include <shogun/lib/common.h>
17 #include <shogun/base/Parameter.h>
18 #include <shogun/lib/DataType.h>
20 
21 #include <shogun/lib/SGString.h>
24 
25 namespace shogun
26 {
30 template <class T> class CStreamingStringFeatures : public CStreamingFeatures
31 {
32 public:
33 
42 
52  bool is_labelled,
53  int32_t size);
54 
60  virtual ~CStreamingStringFeatures();
61 
71  virtual void set_vector_reader();
72 
82  virtual void set_vector_and_label_reader();
83 
90  void use_alphabet(EAlphabet alpha);
91 
98  void use_alphabet(CAlphabet* alpha);
99 
107  void set_remap(CAlphabet* ascii_alphabet, CAlphabet* binary_alphabet);
108 
116  void set_remap(EAlphabet ascii_alphabet=DNA, EAlphabet binary_alphabet=RAWDNA);
117 
123 
131 
137  virtual void start_parser();
138 
144  virtual void end_parser();
145 
154  virtual bool get_next_example();
155 
162 
170  virtual float64_t get_label();
171 
178  virtual void release_example();
179 
185  virtual int32_t get_vector_length();
186 
192  virtual EFeatureType get_feature_type() const;
193 
199  virtual EFeatureClass get_feature_class() const;
200 
206  virtual CFeatures* duplicate() const;
207 
213  virtual const char* get_name() const { return "StreamingStringFeatures"; }
214 
220  virtual int32_t get_num_vectors() const;
221 
227  virtual int32_t get_num_features();
228 
229 private:
230 
235  void init();
236 
244  void init(CStreamingFile *file, bool is_labelled, int32_t size);
245 
246 protected:
247 
249  CInputParser<T> parser;
250 
253 
256 
259 
262 
265 
268 
270  int32_t current_length;
271 
274 
277 
280 
282  int32_t num_symbols;
283 };
284 
285 }
286 #endif // _STREAMING_STRINGFEATURES__H__

SHOGUN Machine Learning Toolbox - Documentation