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

/// @author Bartosz Broda, bartosz.broda@gmail.com
#ifndef SUPERMATRIX_TOOLS_KBESTCOUNTER
#define SUPERMATRIX_TOOLS_KBESTCOUNTER

#include "matrices_all.h"
#include "comparator_all.h"


namespace kbestd{

class KBestCounterError : public std::runtime_error
{
public:
	KBestCounterError(const std::string &what);
	~KBestCounterError() throw() {};
	virtual std::string info() const;

};

class KBestCounter
{
public:
	typedef std::vector< std::pair<std::string, double> > kbestvec;
	KBestCounter();

	/**
	  * may throw std::runtime_error
	  */
	kbestvec generate_kbest(const std::string &matrix_path,
					   const std::string &msr_str,
					   const std::string &word,
					   size_t k = 20
					   );

	void release_mem();

private:
	void load_matrix(const std::string &str);

	Matrices::SuperMatrixPtr matrix_;
	std::string matrix_path_;
	smartcomparator::compare::CompareFunctionPtr msr_;
	std::string msr_str_;

};

} // ns kbestd

#endif //SUPERMATRIX_TOOLS_KBESTCOUNTER
