From 4eef94b1217a82eb979242dd3e06d8a4b6255e6e Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Thu, 31 May 2012 17:24:06 +0100 Subject: move c++ code out of /script/ to / --- phrase-extract/tables-core.h | 66 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 phrase-extract/tables-core.h (limited to 'phrase-extract/tables-core.h') diff --git a/phrase-extract/tables-core.h b/phrase-extract/tables-core.h new file mode 100644 index 000000000..1899b4d77 --- /dev/null +++ b/phrase-extract/tables-core.h @@ -0,0 +1,66 @@ +// $Id$ + +#ifndef _TABLES_H +#define _TABLES_H + +#include +#include +#include +#include +#include +#include +#include +#include + +extern std::vector tokenize( const char*); + +typedef std::string WORD; +typedef unsigned int WORD_ID; + +class Vocabulary +{ +public: + std::map lookup; + std::vector< WORD > vocab; + WORD_ID storeIfNew( const WORD& ); + WORD_ID getWordID( const WORD& ); + inline WORD &getWord( WORD_ID id ) { + return vocab[ id ]; + } +}; + +typedef std::vector< WORD_ID > PHRASE; +typedef unsigned int PHRASE_ID; + +class PhraseTable +{ +public: + std::map< PHRASE, PHRASE_ID > lookup; + std::vector< PHRASE > phraseTable; + PHRASE_ID storeIfNew( const PHRASE& ); + PHRASE_ID getPhraseID( const PHRASE& ); + void clear(); + inline PHRASE &getPhrase( const PHRASE_ID id ) { + return phraseTable[ id ]; + } +}; + +typedef std::vector< std::pair< PHRASE_ID, double > > PHRASEPROBVEC; + +class TTable +{ +public: + std::map< PHRASE_ID, std::vector< std::pair< PHRASE_ID, double > > > ttable; + std::map< PHRASE_ID, std::vector< std::pair< PHRASE_ID, std::vector< double > > > > ttableMulti; +}; + +class DTable +{ +public: + std::map< int, double > dtable; + void init(); + void load( const std::string& ); + double get( int ); +}; + +#endif -- cgit v1.2.3