Compile ORLM. The existing code should to be refactored.

This commit is contained in:
Kenneth Heafield 2012-02-08 13:29:16 -05:00
parent b8c1c53e2b
commit 3c7271220d
5 changed files with 15 additions and 21 deletions

View File

@ -12,9 +12,7 @@
#include "PhraseDictionaryDynSuffixArray.h"
#include "TranslationSystem.h"
#include "LMList.h"
#ifdef LM_ORLM
# include "LanguageModelORLM.h"
#endif
#include "LM/ORLM.h"
using namespace Moses;
using namespace std;
@ -67,20 +65,12 @@ public:
string source_, target_, alignment_;
bool bounded_, add2ORLM_;
void updateORLM() {
#ifdef LM_ORLM
// TODO(level101): this belongs in the language model, not in moseserver.cpp
vector<string> vl;
map<vector<string>, int> ngSet;
LMList lms = StaticData::Instance().GetLMList(); // get LM
LMList::const_iterator lmIter = lms.begin();
const LanguageModel* lm = *lmIter;
/* currently assumes a single LM that is a ORLM */
#ifdef WITH_THREADS
boost::shared_ptr<LanguageModelORLM> orlm;
orlm = boost::dynamic_pointer_cast<LanguageModelORLM>(lm->GetLMImplementation());
#else
LanguageModelORLM* orlm;
orlm = (LanguageModelORLM*)lm->GetLMImplementation();
#endif
LanguageModelORLM* orlm = static_cast<LanguageModelORLM*>(static_cast<LMRefCount*>(*lmIter)->MosesServerCppShouldNotHaveLMCode());
if(orlm == 0) {
cerr << "WARNING: Unable to add target sentence to ORLM\n";
return;
@ -113,7 +103,6 @@ public:
orlm->UpdateORLM(it->first, it->second);
}
}
#endif
}
void breakOutParams(const params_t& params) {
params_t::const_iterator si = params.find("source");

View File

@ -0,0 +1 @@
lib dynsa : [ glob *.cpp ] ../../../util//kenutil : : : <include>. ;

View File

@ -37,13 +37,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#ifdef LM_RAND
# include "LM/Rand.h"
#endif
#ifdef LM_ORLM
# include "LM/ORLM.h"
#endif
#include "LM/ORLM.h"
#ifdef LM_REMOTE
# include "LM/Remote.h"
#endif
#include "LM/Ken.h"
#ifdef LM_DMAP
# include "LM/DMapLM.h"
#endif
@ -77,9 +79,7 @@ LanguageModel* CreateLanguageModel(LMImplementation lmImplementation
#endif
break;
case ORLM:
#ifdef LM_ORLM
lm = new LanguageModelORLM();
#endif
break;
case Remote:
#ifdef LM_REMOTE

View File

@ -168,6 +168,8 @@ class LMRefCount : public LanguageModel {
return m_impl->GetScoreProducerDescription(param);
}
LanguageModelImplementation *MosesServerCppShouldNotHaveLMCode() { return m_impl.get(); }
private:
LMRefCount(ScoreIndexManager &scoreIndexManager, const LMRefCount &copy_from) : m_impl(copy_from.m_impl) {
Init(scoreIndexManager);

View File

@ -44,9 +44,11 @@ if $(with-randlm) {
dependencies += rand ;
}
obj Factory.o : Factory.cpp ..//headers $(dependencies) ;
obj ORLM.o : ORLM.cpp ..//headers ../DynSAInclude//dynsa : : : <include>../DynSAInclude ;
lib LM : Base.cpp Factory.o Implementation.cpp Joint.cpp Ken.cpp MultiFactor.cpp Remote.cpp SingleFactor.cpp
obj Factory.o : Factory.cpp ..//headers $(dependencies) : <include>../DynSAInclude ;
lib LM : Base.cpp Factory.o Implementation.cpp Joint.cpp Ken.cpp MultiFactor.cpp Remote.cpp SingleFactor.cpp ORLM.o
../../../lm//kenlm ..//headers $(dependencies) ;
#Huge kludge to force building if different --with options are passed.