2007-03-15 01:22:36 +03:00
|
|
|
// $Id$
|
|
|
|
|
2006-08-08 22:54:28 +04:00
|
|
|
#ifndef _TABLES_H
|
|
|
|
#define _TABLES_H
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string>
|
|
|
|
#include <queue>
|
|
|
|
#include <map>
|
2006-08-08 23:04:59 +04:00
|
|
|
#include <cmath>
|
2006-08-08 22:54:28 +04:00
|
|
|
|
2007-03-14 02:03:53 +03:00
|
|
|
using namespace std;
|
|
|
|
|
2010-04-12 19:22:50 +04:00
|
|
|
extern vector<string> tokenize( const char*);
|
2006-08-08 22:54:28 +04:00
|
|
|
|
|
|
|
typedef string WORD;
|
|
|
|
typedef unsigned int WORD_ID;
|
|
|
|
|
|
|
|
class Vocabulary {
|
|
|
|
public:
|
|
|
|
map<WORD, WORD_ID> lookup;
|
|
|
|
vector< WORD > vocab;
|
2007-10-03 01:43:54 +04:00
|
|
|
WORD_ID storeIfNew( const WORD& );
|
|
|
|
WORD_ID getWordID( const WORD& );
|
2006-08-08 22:54:28 +04:00
|
|
|
inline WORD &getWord( WORD_ID id ) { return vocab[ id ]; }
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef vector< WORD_ID > PHRASE;
|
|
|
|
typedef unsigned int PHRASE_ID;
|
|
|
|
|
|
|
|
class PhraseTable {
|
|
|
|
public:
|
|
|
|
map< PHRASE, PHRASE_ID > lookup;
|
|
|
|
vector< PHRASE > phraseTable;
|
2007-10-03 01:43:54 +04:00
|
|
|
PHRASE_ID storeIfNew( const PHRASE& );
|
|
|
|
PHRASE_ID getPhraseID( const PHRASE& );
|
2006-08-08 22:54:28 +04:00
|
|
|
void clear();
|
|
|
|
inline PHRASE &getPhrase( const PHRASE_ID id ) { return phraseTable[ id ]; }
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef vector< pair< PHRASE_ID, double > > PHRASEPROBVEC;
|
|
|
|
|
|
|
|
class TTable {
|
|
|
|
public:
|
|
|
|
map< PHRASE_ID, vector< pair< PHRASE_ID, double > > > ttable;
|
|
|
|
map< PHRASE_ID, vector< pair< PHRASE_ID, vector< double > > > > ttableMulti;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DTable {
|
|
|
|
public:
|
|
|
|
map< int, double > dtable;
|
|
|
|
void init();
|
2007-10-03 01:43:54 +04:00
|
|
|
void load( const string& );
|
2006-08-08 22:54:28 +04:00
|
|
|
double get( int );
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|