/*
    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 LEXICALUNITS_UNITLIST
#define LEXICALUNITS_UNITLIST

#include "lex_headers.h"
#include "LexicalUnit.h"

namespace LexicalUnits
{
	class UnitsList
	{
		public:
			UnitsList();
			/**
			 * Adds lexical unit lu to list.
			 * Note that order of insertion of units might be important, because
			 * in case of ambiguous sentences, where on one position distinguishing 
			 * between two or more lexical units is impossible, GetUnitOnCurrentPosition 
			 * will return first unit (in order of calling AddUnit).
			 * Thus suggested method of adding units is by their 'size' 
			 * (no. of constituents) --- generally longer n-grams are less common in corpra.
			 * 
			 */
			void AddUnit(LexicalUnitPtr lu);
			/**
			 * Check which LU is on 'current' position in sentence.
			 *
			 * \return found lexical unit or NULL. If more than one lexical unit might be at given position,
			 *         then returns first one (i.e. first one inserted into the list via AddUnit method call).
			 *         If current position has more then one disamb lexem, then we will try to match all of them.
			 */ 
			LexicalUnitPtr GetUnitOnCurrentPosition(Corpus::CSentence *sentence);
		private:

			std::vector<LexicalUnits::LexicalUnitPtr> m_pvLexicalUnits;
			/**
			 * Lexical units index: base_id -> positions in m_pvLexicalUnits
			 */ 
			std::map<int, std::vector<size_t> > m_LexIndex;
	};

	typedef boost::shared_ptr<UnitsList> UnitsListPtr;
}//namespace LexicalUnits

#endif // LEXICALUNITS_UNITLIST

