/*
    Copyright (C) 2012 Bartosz Broda, Jacek Bochenek, Łukasz Biłeńkij, 
    Damian Jaworski, Wojciech Mazur, Dominik Piasecki, Maciej Piasecki, 
    Radosław Ramocki
    
    This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option)
any later version.

    This program 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 LICENSE and COPYING files for more details.
*/

#pragma once
#include "../comparator_stdheaders.h"
#include "WeightFeature.h"
#include "../selectors/rffselector.h"
#include "../compare/CompareFunction.h"

namespace smartcomparator
{

	namespace weights
	{
		/**
		Relative Frequency Focus. See Geffet & Dagan "Feature Vector Quality and Distributional Similarity"
		*/
		class SMART_COMPARATOR_API RFFWeight : public WeightFeature
		{
		public:
			/**
			  * Constructor
			  * \param m Base supermatrix to compute similarity from
			  * \param SimMatrix Similarity matrix pre-computed earlier
			  * \param top_k Number of best weights to compute
			  * \param simThreshold Treshold for similarity to compute 2 words close to each other
			  * \param selectorPtr Selector for weighting function
			  */
			RFFWeight(Matrices::SuperMatrixPtr m, Matrices::CRSMatrixPtr SimMatrix, size_t top_k,double simThreshold,selectors::RFFSelectorPtr selectorPtr);
			/**
			  * Constructor
			  * \param m Base supermatrix to compute similarity from
			  * \param SimMatrixPath Path to a similarity matrix pre-computed earlier
			  * \param top_k Number of best weights to compute
			  * \param simThreshold Treshold for similarity to compute 2 words close to each other
			  * \param selectorPtr Selector for weighting function
			  */
			RFFWeight(Matrices::SuperMatrixPtr m, std::string SimMatrixPath, size_t top_k,double simThreshold,selectors::RFFSelectorPtr selectorPtr);
			virtual ~RFFWeight(void);

			/**
			  * Weighting function,
			  * \param rowindex Index of row being weighted
			  * \param Copy of row being weighted
			  * \param filteredIndices Column indexes relevant for computed row, assumes that filteredIndices where filter with rfffilter
			  */
			virtual void Weight(size_t rowindex, Matrices::CompressedVector *v, std::set<size_t> &filteredIndices) ;

		private:


			Matrices::CRSMatrixPtr m_pSimMatrix;

			size_t m_stTopK;
			double m_dsimThreshold;
			selectors::RFFSelectorPtr rffSelector;
		};
	}
}
