/** @file notifier.cpp
 *
 *	Definition (implementation) of notification module interface.
 *
 *	See notifier.h for more info.
 *
 *	(C) Ceslav Przywara 2008, MFF UK Prague
 *
 */

// Constants.
#include "config.h"
// Self header.
#include "notifier.h"
// Need of unsigned2str()
#include "utils.h"

namespace ace {

// We use eol constant abudantly.
using constants::eol;

#ifdef _BOOST_ON
// Static object needs its storage.
boost::progress_timer ProgressNotifier::_timer;
#endif

void Notifier::fatal_error(const std::string& message) const {
	_output << "FATAL ERROR: " << message << std::endl;
}

void Notifier::info(const std::string& message) const {
	_output << message << std::endl;
}

void Notifier::warning(const std::string& message) const {
	_output << "WARNING: " << message << std::endl;
}

void ProgressNotifier::elapsed(const std::string& message) const {
#ifdef _BOOST_ON
	_output << message << eol << _timer.elapsed() << " secs elapsed." << std::endl;
#else
	_output << message << std::endl;
#endif
}

void print_usage(void) {
	std::string option_margin = " ", description_margin = "   ";
	std::cout << "Usage: pace [options]" << eol
		<< eol
		<< "Mandatory options:" << eol
		<< option_margin << "-i input-file-path" << eol
		<< description_margin << "Path to file with list of input datafile names." << eol
		<< option_margin << "-n size" << eol
		<< description_margin << "Size of extracted N-grams. Minimum value is 2, maximum value is " << constants::max_grammity << "." << eol
		<< option_margin << "-o output-file-path" << eol
		<< description_margin << "Path to output datafile." << eol
		<< eol
		<< "Auxiliary options:" << eol
		<< option_margin << "-c context-output-file" << eol
		<< description_margin << "Output datafile for contexts storage." << eol
		<< option_margin << "-cf context-morphologic-filter-file-path" << eol
		<< description_margin << "Path to file with morphologic rules to filtrate stored context words." << eol
		<< option_margin << "-cs context-radius-size-in-sentences" << eol
		<< description_margin << "Size of context radius in sentences, may be from 0 to " << constants::sentences_radius_max_size << "." << eol
//		<< option_margin << "-ct context-words-tag-mask" << eol
//		<< description_margin << "Mask determines morphologic tag positions significant for n-grams context." << eol
		<< description_margin << "'" << constants::significant_position_mark << "' determines significant position, '" << constants::insignificant_position_mark << "' determines insignificant position." << eol
		<< option_margin << "-cw context-radius-size-in-words" << eol
		<< description_margin << "Size of context radius in words, may be from 1 to " << constants::words_radius_max_size << "." << eol
		<< option_margin << "-d path-to-datafiles-directory" << eol
		<< description_margin << "String that shall be prepended to all paths founded in input file." << eol
		<< option_margin << "-f n-grams-morphologic-filter-file-path" << eol
		<< description_margin << "Path to file with morphologic rules to filtrate parsed N-grams." << eol
		<< description_margin << "Must be specified in order to -fs parameter has any effect!" << eol
		<< option_margin << "-fs n-grams-morphologic-filter-stats-file-path" << eol
		<< description_margin << "Path to file for saving statistics of applied morphologic rules." << eol
		<< option_margin << "-m morphologic-tag-mask" << eol
		<< description_margin << "Mask determines morphologic tag positions significant for n-grams equality." << eol
		<< description_margin << "Must be specified in order to -cf, -ct, -f parameters have any effect!" << eol
		<< description_margin << "'" << constants::significant_position_mark << "' determines significant position, '" << constants::insignificant_position_mark << "' determines insignificant position." << eol
		<< option_margin << "-p unsigned-number" << eol
		<< description_margin << "Output statistics precision (default is " << constants::default_precision << ")." << eol
		<< option_margin << "-s stats-output-file" << eol
		<< description_margin << "Path to file, where statistics should be stored." << eol
		<< option_margin << "-ta" << eol
		<< description_margin << "Reaching all of given thresholds is required." << eol
		<< option_margin << "-tc floating-point-number" << eol
		<< description_margin << "Pearson's chi square test threshold." << eol
		<< option_margin << "-te floating-point-number" << eol
		<< description_margin << "Only N-grams with at least given estimated frequency will be evaluted." << eol
		<< option_margin << "-tf unsigned-number" << eol
		<< description_margin << "Only N-grams with at least given frequency will be evaluted." << eol
		<< option_margin << "-tl floating-point-number" << eol
		<< description_margin << "Log likelihood ratio threshold." << eol
		<< option_margin << "-tm floating-point-number" << eol
		<< description_margin << "Mutual information threshold." << eol
		<< option_margin << "-to" << eol
		<< description_margin << "Reaching anyone of given thresholds is required." << eol
		<< option_margin << "-tp floating-point-number" << eol
		<< description_margin << "Pearson's coeficient threshold." << eol
		<< option_margin << "-tt floating-point-number" << eol
		<< description_margin << "Student's t-test threshold." << eol
		<< option_margin << "-tz floating-point-number" << eol
		<< description_margin << "Z score threshold." << eol
#ifdef _SURFACE_MODE
		<< option_margin << "-w unsigned-number" << eol
		<< description_margin << "Collocation window size." << eol
#endif

		<< std::endl;
}

namespace notifier {

/* Tie to std error output.
 */
Notifier error(std::cerr);
/* Tie to std output.
 */
ProgressNotifier progress(std::cout);

} // namespace notifier

} // namespace ace
