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) 2007 Christian Gehl 00008 * Written (W) 1999-2008 Soeren Sonnenburg 00009 * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society 00010 */ 00011 00012 #ifndef _CANBERRAWORDDISTANCE_H___ 00013 #define _CANBERRAWORDDISTANCE_H___ 00014 00015 #include "lib/common.h" 00016 #include "features/Features.h" 00017 #include "features/StringFeatures.h" 00018 #include "distance/StringDistance.h" 00019 00021 class CCanberraWordDistance: public CStringDistance<WORD> 00022 { 00023 public: 00025 CCanberraWordDistance(); 00026 00032 CCanberraWordDistance(CStringFeatures<WORD>* l, CStringFeatures<WORD>* r); 00033 virtual ~CCanberraWordDistance(); 00034 00041 virtual bool init(CFeatures* l, CFeatures* r); 00042 00044 virtual void cleanup(); 00045 00051 bool load_init(FILE* src); 00052 00058 bool save_init(FILE* dest); 00059 00064 virtual EDistanceType get_distance_type() { return D_CANBERRAWORD; } 00065 00070 virtual const CHAR* get_name() { return "CanberraWord"; } 00071 00077 void get_dictionary(INT& dsize, DREAL*& dweights) 00078 { 00079 dsize=dictionary_size; 00080 dweights = dictionary_weights; 00081 } 00082 00083 protected: 00087 DREAL compute(INT idx_a, INT idx_b); 00088 00089 protected: 00091 INT dictionary_size; 00093 DREAL* dictionary_weights; 00094 }; 00095 #endif /* _CANBERRAWORDDISTANCE_H___ */