StringKernel.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 1999-2009 Soeren Sonnenburg
00008  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #ifndef _STRINGKERNEL_H___
00012 #define _STRINGKERNEL_H___
00013 
00014 #include "kernel/Kernel.h"
00015 #include "features/StringFeatures.h"
00016 
00022 template <class ST> class CStringKernel : public CKernel
00023 {
00024     public:
00029         CStringKernel(int32_t cachesize) : CKernel(cachesize) {}
00030 
00036         CStringKernel(CFeatures *l, CFeatures *r) : CKernel(10)
00037         {
00038             init(l, r);
00039         }
00040 
00051         virtual bool init(CFeatures* l, CFeatures* r)
00052         {
00053             CKernel::init(l,r);
00054 
00055             ASSERT(l->get_feature_class()==C_STRING);
00056             ASSERT(r->get_feature_class()==C_STRING);
00057             ASSERT(l->get_feature_type()==this->get_feature_type());
00058             ASSERT(r->get_feature_type()==this->get_feature_type());
00059 
00060             return true;
00061         }
00062 
00067         inline virtual EFeatureClass get_feature_class() { return C_STRING; }
00068 
00073         virtual EFeatureType get_feature_type();
00074 };
00075 
00076 template<> inline EFeatureType CStringKernel<float64_t>::get_feature_type() { return F_DREAL; }
00077 
00078 template<> inline EFeatureType CStringKernel<uint64_t>::get_feature_type() { return F_ULONG; }
00079 
00080 template<> inline EFeatureType CStringKernel<int32_t>::get_feature_type() { return F_INT; }
00081 
00082 template<> inline EFeatureType CStringKernel<uint16_t>::get_feature_type() { return F_WORD; }
00083 
00084 template<> inline EFeatureType CStringKernel<int16_t>::get_feature_type() { return F_SHORT; }
00085 
00086 template<> inline EFeatureType CStringKernel<uint8_t>::get_feature_type() { return F_BYTE; }
00087 
00088 template<> inline EFeatureType CStringKernel<char>::get_feature_type() { return F_CHAR; }
00089 
00090 #endif /* _STRINGKERNEL_H__ */
00091 

SHOGUN Machine Learning Toolbox - Documentation