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-2009 Christian Gehl 00008 * Copyright (C) 1999-2009 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 00017 namespace shogun 00018 { 00020 template <class ST> class CStringDistance : public CDistance 00021 { 00022 public: 00024 CStringDistance() : CDistance() {} 00025 00032 /* when training data is supplied as both l and r do_init 00033 * should be true 00034 */ 00035 virtual bool init(CFeatures* l, CFeatures* r) 00036 { 00037 CDistance::init(l,r); 00038 00039 ASSERT(l->get_feature_class()==C_STRING); 00040 ASSERT(r->get_feature_class()==C_STRING); 00041 ASSERT(l->get_feature_type()==this->get_feature_type()); 00042 ASSERT(r->get_feature_type()==this->get_feature_type()); 00043 return true; 00044 } 00045 00050 inline virtual EFeatureClass get_feature_class() { return C_STRING; } 00051 00056 virtual EFeatureType get_feature_type(); 00057 }; 00058 00063 template<> inline EFeatureType CStringDistance<float64_t>::get_feature_type() { return F_DREAL; } 00064 00069 template<> inline EFeatureType CStringDistance<uint64_t>::get_feature_type() { return F_ULONG; } 00070 00075 template<> inline EFeatureType CStringDistance<int32_t>::get_feature_type() { return F_INT; } 00076 00081 template<> inline EFeatureType CStringDistance<uint16_t>::get_feature_type() { return F_WORD; } 00082 00087 template<> inline EFeatureType CStringDistance<int16_t>::get_feature_type() { return F_SHORT; } 00088 00093 template<> inline EFeatureType CStringDistance<uint8_t>::get_feature_type() { return F_BYTE; } 00094 00099 template<> inline EFeatureType CStringDistance<char>::get_feature_type() { return F_CHAR; } 00100 00101 } // namespace shogun 00102 #endif 00103