00001 // 00002 // PhraseDictionaryALSuffixArray.cpp 00003 // moses 00004 // 00005 // Created by Hieu Hoang on 06/11/2011. 00006 // Copyright 2011 __MyCompanyName__. All rights reserved. 00007 // 00008 00009 #include <iostream> 00010 #include "PhraseDictionaryALSuffixArray.h" 00011 #include "moses/InputType.h" 00012 #include "moses/InputFileStream.h" 00013 #include "moses/TypeDef.h" 00014 #include "moses/StaticData.h" 00015 #include "moses/UserMessage.h" 00016 #include "Loader.h" 00017 #include "LoaderFactory.h" 00018 00019 using namespace std; 00020 00021 namespace Moses 00022 { 00023 PhraseDictionaryALSuffixArray::PhraseDictionaryALSuffixArray(const std::string &line) 00024 : PhraseDictionaryMemory("PhraseDictionaryALSuffixArray", line) 00025 { 00026 const StaticData &staticData = StaticData::Instance(); 00027 if (staticData.ThreadCount() > 1) { 00028 throw runtime_error("Suffix array implementation is not threadsafe"); 00029 } 00030 CHECK(m_args.size() == 0); 00031 } 00032 00033 void PhraseDictionaryALSuffixArray::Load() 00034 { 00035 SetFeaturesToApply(); 00036 } 00037 00038 void PhraseDictionaryALSuffixArray::InitializeForInput(InputType const& source) 00039 { 00040 // populate with rules for this sentence 00041 long translationId = source.GetTranslationId(); 00042 00043 string grammarFile = GetFilePath() + "/grammar." + SPrint(translationId) + ".gz"; 00044 00045 std::auto_ptr<RuleTableLoader> loader = 00046 RuleTableLoaderFactory::Create(grammarFile); 00047 bool ret = loader->Load(m_input, m_output, grammarFile, m_tableLimit, 00048 *this); 00049 00050 CHECK(ret); 00051 } 00052 00053 void PhraseDictionaryALSuffixArray::CleanUpAfterSentenceProcessing(const InputType &source) 00054 { 00055 m_collection.Clear(); 00056 } 00057 00058 }
1.5.9