00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef moses_LexicalReorderingTableCompact_h
00023 #define moses_LexicalReorderingTableCompact_h
00024
00025 #include "moses/FF/LexicalReordering/LexicalReorderingTable.h"
00026 #include "moses/StaticData.h"
00027 #include "moses/TranslationModel/PhraseDictionary.h"
00028 #include "moses/GenerationDictionary.h"
00029 #include "moses/TargetPhrase.h"
00030 #include "moses/TargetPhraseCollection.h"
00031
00032 #include "BlockHashIndex.h"
00033 #include "CanonicalHuffman.h"
00034 #include "StringVector.h"
00035
00036 namespace Moses
00037 {
00038
00039 class LexicalReorderingTableCompact:
00040 public LexicalReorderingTable
00041 {
00042 private:
00043 static bool s_inMemoryByDefault;
00044 bool m_inMemory;
00045
00046 size_t m_numScoreComponent;
00047 bool m_multipleScoreTrees;
00048
00049 BlockHashIndex m_hash;
00050
00051 typedef CanonicalHuffman<float> ScoreTree;
00052 std::vector<ScoreTree*> m_scoreTrees;
00053
00054 StringVector<unsigned char, unsigned long, MmapAllocator> m_scoresMapped;
00055 StringVector<unsigned char, unsigned long, std::allocator> m_scoresMemory;
00056
00057 std::string MakeKey(const Phrase& f, const Phrase& e, const Phrase& c) const;
00058 std::string MakeKey(const std::string& f, const std::string& e, const std::string& c) const;
00059
00060 public:
00061 LexicalReorderingTableCompact(const std::string& filePath,
00062 const std::vector<FactorType>& f_factors,
00063 const std::vector<FactorType>& e_factors,
00064 const std::vector<FactorType>& c_factors);
00065
00066 LexicalReorderingTableCompact(const std::vector<FactorType>& f_factors,
00067 const std::vector<FactorType>& e_factors,
00068 const std::vector<FactorType>& c_factors);
00069
00070 virtual
00071 ~LexicalReorderingTableCompact();
00072
00073 virtual
00074 std::vector<float>
00075 GetScore(const Phrase& f, const Phrase& e, const Phrase& c);
00076
00077 static
00078 LexicalReorderingTable*
00079 CheckAndLoad(const std::string& filePath,
00080 const std::vector<FactorType>& f_factors,
00081 const std::vector<FactorType>& e_factors,
00082 const std::vector<FactorType>& c_factors);
00083
00084 void
00085 Load(std::string filePath);
00086
00087 static void
00088 SetStaticDefaultParameters(Parameter const& param);
00089
00090 };
00091
00092 }
00093
00094 #endif