/*
    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.
*/

#ifndef RFFSELECTOR_H
#define RFFSELECTOR_H
#include "Selector.h"
#include "../weights/MIWeight.h"
#include <set>
namespace smartcomparator
{
	namespace selectors
	{

		class RFFSelector : public Selector
		{
		public:
			/**
			  * Constructor
			  * \param superMatrix Base matrix to compute similarity for
			  * \param TFTreshold Treshold for global column TF to consider column significant
			  * \param weightTreshold Treshold to consider 2 words close
			  */
			RFFSelector(Matrices::SuperMatrixPtr superMatrix,size_t TFTreshold, double weightTreshold);
			/**
			  * Selector choosing important cells
			  * \param rowIndex Index of row being computed
			  * \param filteredIndices Indices of columns to be considered in choosing process
			  * \param out Output set for indices relevant for computed row
			  */
			void SelectBestFeatures(size_t rowIndex,
									const std::set<size_t> &filteredIndices, std::set<size_t> &out);
			virtual ~RFFSelector();
			/**
			  * Function checking if value was removed from computations.
			  * Checking only value, doesn't check if column is removed.
			  */
			bool CheckIfValueIsRemoved(size_t rowIndex,size_t colIndex);
		private:
			/**
			  * Function preparing set of column indexes, which won't be considered in computations.
			  */
			void PrepareColumnIndices();
			/**
			  * Function preparing set of column indexes for each row, which won't be considered in computations.
			  */
			void PrepareRowIndices();
			size_t TFTreshold;
			double weightTreshold;
			std::set<size_t> columnsToRemove;
			std::map<size_t,std::set<size_t> > indicesToRemove;
		};

		typedef boost::shared_ptr<RFFSelector> RFFSelectorPtr;
	}
}

#endif // RFFSELECTOR_H
