SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StringPreprocessor.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) 1999-2009 Soeren Sonnenburg
8  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
11 #ifndef _CSTRINGPREPROC__H__
12 #define _CSTRINGPREPROC__H__
13 
14 #include <shogun/lib/config.h>
15 
18 #include <shogun/lib/common.h>
20 
21 namespace shogun
22 {
23 template <class ST> class CStringFeatures;
24 
32 template <class ST> class CStringPreprocessor : public CPreprocessor
33 {
34  public:
38 
45  virtual CFeatures* apply(CFeatures* features);
46 
50  virtual bool apply_to_string_features(CFeatures* f)=0;
51 
53  virtual ST* apply_to_string(ST* f, int32_t &len)=0;
54 
59 
61  virtual const char* get_name() const { return "UNKNOWN"; }
62 
64  virtual EPreprocessorType get_type() const { return P_UNKNOWN; }
65 
66 };
67 
69 {
70  return F_ULONG;
71 }
72 
74 {
75  return F_LONG;
76 }
77 
79 {
80  return F_UINT;
81 }
82 
84 {
85  return F_INT;
86 }
87 
89 {
90  return F_WORD;
91 }
92 
94 {
95  return F_WORD;
96 }
97 
99 {
100  return F_BYTE;
101 }
102 
104 {
105  return F_BYTE;
106 }
107 
109 {
110  return F_CHAR;
111 }
112 
114 {
115  return F_BOOL;
116 }
117 
119 {
120  return F_SHORTREAL;
121 }
122 
124 {
125  return F_DREAL;
126 }
127 
129 {
130  return F_LONGREAL;
131 }
132 
133 template <class ST>
135 {
136  REQUIRE(features->get_feature_class()==C_STRING, "Provided features (%d) "
137  "has to be of C_STRING (%d) class!\n",
138  features->get_feature_class(), C_STRING);
139 
140  apply_to_string_features(features);
141  return features;
142 }
143 
144 }
145 #endif

SHOGUN Machine Learning Toolbox - Documentation