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 <shogun/distance/Distance.h> 00015 #include <shogun/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 virtual EFeatureClass get_feature_class() { return C_STRING; } 00051 00056 virtual EFeatureType get_feature_type(); 00057 00063 virtual const char* get_name() const { 00064 return "StringDistance"; } 00065 00070 virtual void cleanup()=0; 00071 00078 virtual EDistanceType get_distance_type()=0; 00079 }; 00080 00085 template<> inline EFeatureType CStringDistance<float64_t>::get_feature_type() { return F_DREAL; } 00086 00091 template<> inline EFeatureType CStringDistance<uint64_t>::get_feature_type() { return F_ULONG; } 00092 00097 template<> inline EFeatureType CStringDistance<int32_t>::get_feature_type() { return F_INT; } 00098 00103 template<> inline EFeatureType CStringDistance<uint16_t>::get_feature_type() { return F_WORD; } 00104 00109 template<> inline EFeatureType CStringDistance<int16_t>::get_feature_type() { return F_SHORT; } 00110 00115 template<> inline EFeatureType CStringDistance<uint8_t>::get_feature_type() { return F_BYTE; } 00116 00121 template<> inline EFeatureType CStringDistance<char>::get_feature_type() { return F_CHAR; } 00122 00123 } // namespace shogun 00124 #endif 00125