StringDistance.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) 2006 Christian Gehl
00008  * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #ifndef _STRINGDISTANCE_H___
00012 #define _STRINGDISTANCE_H___
00013 
00014 #include "distance/Distance.h"
00015 #include "features/StringFeatures.h"
00016 
00018 template <class ST> class CStringDistance : public CDistance
00019 {
00020     public:
00022         CStringDistance() : CDistance() {}
00023 
00030         /* when training data is supplied as both l and r do_init
00031          * should be true
00032         */
00033         virtual bool init(CFeatures* l, CFeatures* r)
00034         {
00035             CDistance::init(l,r);
00036 
00037             ASSERT(l->get_feature_class()==C_STRING);
00038             ASSERT(r->get_feature_class()==C_STRING);
00039             ASSERT(l->get_feature_type()==this->get_feature_type());
00040             ASSERT(r->get_feature_type()==this->get_feature_type());
00041             return true;
00042         }
00043 
00048         inline virtual EFeatureClass get_feature_class() { return C_STRING; }
00049 
00054         virtual EFeatureType get_feature_type();
00055 };
00056 
00061 template<> inline EFeatureType CStringDistance<float64_t>::get_feature_type() { return F_DREAL; }
00062 
00067 template<> inline EFeatureType CStringDistance<uint64_t>::get_feature_type() { return F_ULONG; }
00068 
00073 template<> inline EFeatureType CStringDistance<int32_t>::get_feature_type() { return F_INT; }
00074 
00079 template<> inline EFeatureType CStringDistance<uint16_t>::get_feature_type() { return F_WORD; }
00080 
00085 template<> inline EFeatureType CStringDistance<int16_t>::get_feature_type() { return F_SHORT; }
00086 
00091 template<> inline EFeatureType CStringDistance<uint8_t>::get_feature_type() { return F_BYTE; }
00092 
00097 template<> inline EFeatureType CStringDistance<char>::get_feature_type() { return F_CHAR; }
00098 
00099 #endif
00100 

SHOGUN Machine Learning Toolbox - Documentation