/* $Id: Testers.h 15565 2013-01-07 14:27:05Z sloot $ $URL: https://ilk.uvt.nl/svn/trunk/sources/Timbl6/include/timbl/Testers.h $ Copyright (c) 1998 - 2013 ILK - Tilburg University CLiPS - University of Antwerp This file is part of timbl timbl is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. timbl is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . For questions and suggestions, see: http://ilk.uvt.nl/software.html or send mail to: timbl@uvt.nl */ #ifndef TIMBL_TESTERS_H #define TIMBL_TESTERS_H namespace Timbl{ class metricTestFunction { public: virtual ~metricTestFunction(){}; virtual double test( FeatureValue *, FeatureValue *, Feature * ) const = 0; }; class overlapTestFunction: public metricTestFunction { public: double test( FeatureValue *FV, FeatureValue *G, Feature *Feat ) const; }; class valueDiffTestFunction: public metricTestFunction { public: valueDiffTestFunction( int t ): metricTestFunction(), threshold( t ){}; double test( FeatureValue *, FeatureValue *, Feature * ) const; protected: int threshold; }; class TesterClass { public: TesterClass( const std::vector&, const std::vector & ); virtual ~TesterClass(){}; void init( const Instance&, size_t, size_t ); virtual size_t test( std::vector&, size_t, double ) = 0; virtual double getDistance( size_t ) const = 0; protected: size_t _size; size_t effSize; size_t offSet; const std::vector *FV; const std::vector &features; std::vector permFeatures; const std::vector &permutation; std::vector distances; }; class DistanceTester: public TesterClass { public: DistanceTester( const std::vector&, const std::vector&, int ); ~DistanceTester(); double getDistance( size_t ) const; size_t test( std::vector&, size_t, double ); private: metricTestFunction **metricTest; }; class SimilarityTester: public TesterClass { public: SimilarityTester( const std::vector& pf, const std::vector& p ): TesterClass( pf, p ){}; ~SimilarityTester() {}; double getDistance( size_t ) const; virtual size_t test( std::vector&, size_t, double ) = 0; }; class CosineTester: public SimilarityTester { public: CosineTester( const std::vector& pf, const std::vector& p ): SimilarityTester( pf, p ){}; size_t test( std::vector&, size_t, double ); }; class DotProductTester: public SimilarityTester { public: DotProductTester( const std::vector& pf, const std::vector& p ): SimilarityTester( pf, p ){}; size_t test( std::vector&, size_t, double ); }; TesterClass* getTester( MetricType, const std::vector&, const std::vector&, int ); } #endif // TIMBL_TESTERS_H