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

#include "../comparator_stdheaders.h"
#include "MILinsComparision.h"
#include "RWFLinScaled.h"
#include "../weights/FunctionScaledWeight.h"
#include "../weights/RWFLinWeight.h"
#include "../simfunctions/CosineFunction.h"
#include "../filters/NoiseFilter.h"
#include "../selectors/FrequencySelector.h"


namespace smartcomparator
{
	namespace compare
	{

		RWFLinScaledComparison::RWFLinScaledComparison(Matrices::SuperMatrixPtr pMatrix, weights::RankBuilderPtr pRankBuilder,
					double noisefilter , size_t col_mintf ,
					double mi_treshold, size_t row_min_nz, size_t row_min_tf, size_t  row_min_TF, size_t divfactor)
			: CompareFunction(pMatrix)
		{
			//filtering
			size_t cNoise = (size_t) (pMatrix->NumberOfColumns()*noisefilter);
			m_pFilter = filters::FilterFeaturePtr(
					new filters::NoiseKTFFilter(pMatrix->GetColumnFeatures(), cNoise, col_mintf) );
			// selector
			m_pSelector = selectors::SelectorPtr(
					new selectors::FrequencySelector(pMatrix, row_min_nz, row_min_tf, row_min_TF)
					);
			// weighting
			weights::WeightFeaturePtr pWeight_inner = weights::WeightFeaturePtr (
				new weights::RWFLinWeight(pMatrix, pRankBuilder, mi_treshold) );

			m_pWeight = weights::WeightFeaturePtr(
					new weights::FunctionScaledWeight(pMatrix, pWeight_inner, divfactor));
			// simfun
			simfunctions::CosineFunction *fun = new  simfunctions::CosineFunction(pMatrix);
			m_pSimfun = simfunctions::SimilarityFunctionPtr( fun );


		}
	}//namespace comapre
}//namespace smartcomparator

