/** @file word.h
 *
 *	Declaration and definition of structure designed to represent parsed words
 *	within the program.
 *
 *	Note: type definition for container used as words buffer (see buffer.h)
 *	underlying container is also included here.
 *
 *	(C) Ceslav Przywara 2008, MFF UK Prague
 *
 */

#ifndef _WORD_H
#define _WORD_H

#include <deque>

#include "config.h"

namespace ace {

/** Word class holds all information for single input word entity.
 */
class Word {
    /** Word lemma.
	 */
    string_index_t _lemma; // 4B
    /** Morphological tag.
	 */
    tag_index_t _tag; // 2B
#ifdef _DEPENDENCY_MODE
	/** Word order (index) in sentence.
	 */
	word_order_t _order; // 2B
    /** Word parent index in dependency tree.
	 */
	word_order_t _parent; // 2B
	/** Dependency type.
	 */
	dependency_index_t _dependency; // 1B

public:
	/** Constructor of Word instances expects data for all members.
	 *	@param order Word order in sentence.
	 *	@param parent Index of parent word in sentence (0 if word is root).
	 *	@param lemma Pointer to string with lemma form of given word.
	 *	@param tag Pointer to string containing significant part of morphological tag.
	 *	@param dependency Enumerator for dependency type of given word.
	 */
	Word(word_order_t order, word_order_t parent, string_index_t lemma, tag_index_t tag, dependency_index_t dependency) throw(): _lemma(lemma), _tag(tag), _order(order), _parent(parent), _dependency(dependency) {}
	/** @return Enumerator for dependency type of given word.
	 */
	inline dependency_index_t dependency(void) const throw() { return _dependency; }
	/** @return Word order (index) in sentence.
	 */
	inline word_order_t order(void) const throw() { return _order; }
	/** @return Index of parent word in grammar dependency tree.
	 */
	inline word_order_t parent(void) const throw() { return _parent; }
#else
public:
	/** Constructor of Word instances expects data for all members.
	 *	@param lemma Pointer to string with lemma form of given word.
	 *	@param tag Pointer to string containing significant part of morphological tag.
	 */
	Word(string_index_t lemma, tag_index_t tag) throw(): _lemma(lemma), _tag(tag) {}
#endif
	/** @return Pointer to string with lemma form of given word.
	 */
	inline string_index_t lemma(void) const throw() { return _lemma; }
	/** @return Pointer to string containing significant part of morphological tag.
	 */
	inline tag_index_t tag(void) const throw() { return _tag; }
};

/** (Forward) declaration of container used to buffering of words (see
 *	buffer.h). Few modules work with this buffer, but they're only interested
 *	in buffer underlying container. So it's more convenient to (pre)declare it
 *	here, because they include word.h anyway.
 */
typedef std::deque<Word> words_store_t;

} // namespace ace

#endif
