/*
    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 COMPARATOR_SELECTORS_FREQUENCY_SELECTOR
#define COMPARATOR_SELECTORS_FREQUENCY_SELECTOR
#include "../comparator_stdheaders.h"
#include "Selector.h"

namespace smartcomparator
{
	namespace selectors
	{
		/**
		  * Selector that checks global properties of a row. It can be used for filtering rows based
		  * on global frequencies. Global frequencies are: term frequency (sum of row values before weighting),
		  * global term frequecny (frequency of given token word type in a corpus) and number of non zero cells
		  * in a row.
		  *
		  * For each of frequency user can set a minimal threshold. If the actual row value is smaller then any of
		  * the thresholds set then filtered indices will be cleared. This means that current row shouldn't be used
		  * for comparision.
		  *
		  * \note Filtering is being done on the basis of matrix row features, not the actual values of  matrix cells.
		  */
		class SMART_COMPARATOR_API FrequencySelector : public Selector
		{
		public:
			/**
			  * \param min_nz Minimal value for number of non zero cells in a row.
			  * \param min_tf Minimal value for sum of row frequencies.
			  * \param min_TF Minimal value for global occurances of a given token word type being described
			  * by a row in a corpus
			  */
			FrequencySelector(Matrices::SuperMatrixPtr pMatrix, size_t min_nz = 5, size_t min_tf = 5, size_t min_TF = 5);
			virtual ~FrequencySelector(void);

			/**
			  * If some of criterions are not met then will clear out set.
			  */
			virtual void SelectBestFeatures(size_t rowIndex, const std::set<size_t> &filteredIndices,
											std::set<size_t> &out);
		private:
			size_t m_stMinNz;
			size_t m_stMinTermFrequency;
			size_t m_stMinGlobalTermFrequency;
		};
	}//namespace smartcomparator
}//namespace selectors

#endif //COMPARATOR_SELECTORS_FREQUENCY_SELECTOR
