/*
    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 READ_UTILS_H
#define READ_UTILS_H
#include <libcorpus2/io/reader.h>

namespace Corpus2
{
	std::string orthwriter(Corpus2::Sentence::Ptr sentence,Corpus2::Tagset tagset);

	template <typename T>
	Sentence::Ptr  clone_sentence(Corpus2::Sentence::Ptr sentence,
										  int head, const T& all,
										  const std::string &new_orth,
										  const std::string &new_base)
	{
		Sentence::Ptr new_sentence = boost::make_shared<Sentence>();
		std::vector<Token*> &tokens = sentence->tokens();
		for(int i = 0; i < (int)tokens.size(); i++)
		{
			if(i == head)
			{
				Corpus2::Token * t = tokens[i]->clone();
				t->set_orth_utf8(new_orth);
				BOOST_FOREACH (Lexeme& lex, t->lexemes())
					if(lex.is_disamb())
						lex.set_lemma_utf8(new_base);
				new_sentence->append(t);
			} else if(find(all.begin(),all.end(),i)== all.end())
				new_sentence->append(tokens[i]->clone());
			// else -> do nothing
		}
		return new_sentence;
	}

	int get_head(Corpus2::Sentence::Ptr sentence,std::vector<int> all,Corpus2::Tagset tagset);
}

#endif // READ_UTILS_H
