ManhattanWordDistance.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) 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 _MANHATTANWORDDISTANCE_H___
00013 #define _MANHATTANWORDDISTANCE_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 CManhattanWordDistance: public CStringDistance<uint16_t>
00022 {
00023     public:
00025         CManhattanWordDistance();
00026 
00032         CManhattanWordDistance(CStringFeatures<uint16_t>* l, CStringFeatures<uint16_t>* r);
00033         virtual ~CManhattanWordDistance();
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_MANHATTANWORD; }
00065 
00070         virtual const char* get_name() { return "ManhattanWord"; }
00071 
00077         void get_dictionary(int32_t& dsize, float64_t*& dweights)
00078         {
00079             dsize=dictionary_size;
00080             dweights = dictionary_weights;
00081         }
00082 
00083     protected:
00087         float64_t compute(int32_t idx_a, int32_t idx_b);
00088 
00089     protected:
00091         int32_t dictionary_size;
00093         float64_t* dictionary_weights;
00094 };
00095 #endif /* _MANHATTANWORDDISTANCE_H___ */

SHOGUN Machine Learning Toolbox - Documentation