mosesdecoder/moses/TranslationModel/fuzzy-match/Vocabulary.h
Jeroen Vermeulen a9c8f44896 Modernize "C" includes in moses.
This is one of those little chores in managing a long-lived C++
project: standard C headers like stdio.h and math.h now have their own
place in the C++ standard as resp. cstdio, cmath, and so on.  In this
branch the #include names are updated for the moses/ subdirectory; more
branches to follow.

C++11 adds cstdint, but to support compilation with the previous
standard, that change is left for later.
2015-03-28 20:09:03 +07:00

47 lines
786 B
C++

// $Id: tables-core.h 1470 2007-10-02 21:43:54Z redpony $
#pragma once
#include <iostream>
#include <fstream>
#include <cassert>
#include <cstdlib>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#ifdef WITH_THREADS
#include <boost/thread/shared_mutex.hpp>
#endif
namespace tmmt
{
typedef std::string WORD;
typedef unsigned int WORD_ID;
class Vocabulary
{
public:
std::map<WORD, WORD_ID> lookup;
std::vector< WORD > vocab;
WORD_ID StoreIfNew( const WORD& );
WORD_ID GetWordID( const WORD& );
std::vector<WORD_ID> Tokenize( const char[] );
inline WORD &GetWord( WORD_ID id ) const {
WORD &i = (WORD&) vocab[ id ];
return i;
}
protected:
#ifdef WITH_THREADS
//reader-writer lock
mutable boost::shared_mutex m_accessLock;
#endif
};
}