00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "PhraseDictionaryOnDisk.h"
00022 #include "InputFileStream.h"
00023 #include "StaticData.h"
00024 #include "TargetPhraseCollection.h"
00025 #include "CYKPlusParser/DotChartOnDisk.h"
00026 #include "CYKPlusParser/ChartRuleLookupManagerOnDisk.h"
00027
00028 using namespace std;
00029
00030
00031 namespace Moses
00032 {
00033 PhraseDictionaryOnDisk::~PhraseDictionaryOnDisk()
00034 {
00035 CleanUp();
00036 }
00037
00038 bool PhraseDictionaryOnDisk::Load(const std::vector<FactorType> &input
00039 , const std::vector<FactorType> &output
00040 , const std::string &filePath
00041 , const std::vector<float> &weight
00042 , size_t tableLimit
00043 , const LMList& languageModels
00044 , const WordPenaltyProducer* wpProducer)
00045 {
00046 m_languageModels = &(languageModels);
00047 m_wpProducer = wpProducer;
00048 m_filePath = filePath;
00049 m_tableLimit = tableLimit;
00050 m_inputFactorsVec = input;
00051 m_outputFactorsVec = output;
00052
00053 m_weight = weight;
00054
00055 LoadTargetLookup();
00056
00057 if (!m_dbWrapper.BeginLoad(filePath))
00058 return false;
00059
00060 CHECK(m_dbWrapper.GetMisc("Version") == 3);
00061 CHECK(m_dbWrapper.GetMisc("NumSourceFactors") == input.size());
00062 CHECK(m_dbWrapper.GetMisc("NumTargetFactors") == output.size());
00063 CHECK(m_dbWrapper.GetMisc("NumScores") == weight.size());
00064
00065 return true;
00066 }
00067
00069 const TargetPhraseCollection *PhraseDictionaryOnDisk::GetTargetPhraseCollection(const Phrase& ) const
00070 {
00071 CHECK(false);
00072 return NULL;
00073 }
00074
00075 void PhraseDictionaryOnDisk::InitializeForInput(const InputType& )
00076 {
00077
00078 }
00079
00080 void PhraseDictionaryOnDisk::CleanUp()
00081 {
00082
00083 }
00084
00085 void PhraseDictionaryOnDisk::LoadTargetLookup()
00086 {
00087
00088 }
00089
00090 ChartRuleLookupManager *PhraseDictionaryOnDisk::CreateRuleLookupManager(
00091 const InputType &sentence,
00092 const ChartCellCollection &cellCollection)
00093 {
00094 return new ChartRuleLookupManagerOnDisk(sentence, cellCollection, *this,
00095 m_dbWrapper, m_languageModels,
00096 m_wpProducer, m_inputFactorsVec,
00097 m_outputFactorsVec, m_weight,
00098 m_filePath);
00099 }
00100
00101 }
00102