/* $Id: TreeHash.h 15564 2013-01-07 14:25:32Z sloot $ $URL: https://ilk.uvt.nl/svn/sources/libticcutils/trunk/include/ticcutils/TreeHash.h $ Copyright (c) 1998 - 2013 ILK - Tilburg University CLiPS - University of Antwerp This file is part of ticcutils ticcutils is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. ticcutils 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 GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . For questions and suggestions, see: http://ilk.uvt.nl/software.html or send mail to: timbl@uvt.nl */ #ifndef TICC_TREE_H #define TICC_TREE_H #include #include "ticcutils/Trie.h" namespace Hash { using namespace Tries; // a StringTokenizer. Stores strings and assigns unique numbers class HashInfo { friend std::ostream& operator<< ( std::ostream&, const HashInfo& ); public: HashInfo( const std::string&, const unsigned int ); ~HashInfo(); const std::string& Name() const { return name; }; unsigned int Index() const { return ID; }; private: const std::string name; unsigned int ID; HashInfo( const HashInfo& ); HashInfo& operator=( const HashInfo& ); }; class StringHash { friend std::ostream& operator << ( std::ostream&, const StringHash& ); public: StringHash(); ~StringHash(); unsigned int NumOfEntries() const { return NumOfTokens; }; unsigned int Hash( const std::string& ); unsigned int Lookup( const std::string& ) const; const std::string& ReverseLookup( unsigned int ) const; private: unsigned int NumOfTokens; std::vector rev_index; Trie StringTree; StringHash( const StringHash& ); StringHash& operator=( const StringHash& ); }; // a Lexion. Stores strings and translations, assigns unique ID's as well class LexInfo { friend std::ostream& operator<<( std::ostream&, const LexInfo& ); public: LexInfo( const std::string&, const std::string& ); ~LexInfo(); const std::string& Name() const { return name; }; const std::string& Trans() const { return trans; }; private: const std::string name; const std::string trans; LexInfo( const LexInfo& ); LexInfo& operator=( const LexInfo& ); }; class Lexicon { friend std::ostream& operator<< ( std::ostream&, const Lexicon& ); public: Lexicon(); ~Lexicon(); LexInfo *Lookup( const std::string& ) const; LexInfo *Store( const std::string&, const std::string& ); private: Trie LexTree; Lexicon( const Lexicon& ); Lexicon& operator=( const Lexicon& ); }; } #endif