/*
    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_UNIGRAMDICTIONARY_H
#define LEXICALUNITS_UNIGRAMDICTIONARY_H
#include "lex_headers.h"
#include "LexicalUnit.h"

namespace LexicalUnits
{
	/**
	 * Unigram dictionary for lexical units.
	 * 
	 * \todo Serialize and deserialize of unigram dictionary - serializing lexical unit.
	 * \author Bartosz Broda
	 */
	class UnigramDictionary
	{
	public:
		/**
		 * Retrives instance of unigram dictionary.
		 */ 
		static UnigramDictionary* GetInstance();

		/**
		 * Adds new lu to dictionary without setting its frequency.
		 * \param lu Lexical unit which should be added to dictionary.
		 */
		void AddNewLexicalUnit(LexicalUnitPtr lu);
		
		/**
		 * Adds lu to dictionary (if not present already) and increases its frequency.
		 * \param lu Lexical unit which should be added to dictionary.
		 * \returns Frequency of given lexical unit
		 */ 
		size_t AddLexicalUnit(LexicalUnitPtr lu);

		size_t GetCount(LexicalUnitPtr lu);

		/**
		 * Removes givel lexical unit from dictionary.
		 * \returns Frequency of removed lexical unit.
		 */ 
		size_t RemoveLexicalUnit(LexicalUnitPtr lu);

		/**
		 * Clears whole dictionary.
		 */
		void Clear();

		void Save(std::string filename);

	private:
		/// private constructor for singelton
		UnigramDictionary();

		~UnigramDictionary();

		static UnigramDictionary* m_pInstance;

		std::map<size_t, LexicalUnitPtr> m_mapIdToLexicalUnit;
		
		std::map<size_t, size_t> m_mapIdToCount;
	};
}

#endif //LEXICALUNITS_UNIGRAMDICTIONARY_H

