From 6f9d59129f3d18184431115870f74fc50101dd24 Mon Sep 17 00:00:00 2001 From: Paul Baltescu Date: Fri, 26 Sep 2014 15:18:14 +0100 Subject: [PATCH] Rename LBLLM -> OxLM. --- contrib/other-builds/moses/.cproject | 6 +-- contrib/other-builds/moses/.project | 11 +++++ moses/Jamfile | 8 ---- moses/LM/oxlm/Mapper.cpp | 60 ---------------------------- moses/LM/oxlm/Mapper.h | 51 ----------------------- 5 files changed, 13 insertions(+), 123 deletions(-) delete mode 100644 moses/LM/oxlm/Mapper.cpp delete mode 100644 moses/LM/oxlm/Mapper.h diff --git a/contrib/other-builds/moses/.cproject b/contrib/other-builds/moses/.cproject index 1a4338564..97e6f40ea 100644 --- a/contrib/other-builds/moses/.cproject +++ b/contrib/other-builds/moses/.cproject @@ -74,7 +74,6 @@ -<<<<<<< HEAD @@ -143,7 +142,7 @@ -======= + @@ -158,7 +157,6 @@ ->>>>>>> fix Jamfile @@ -265,7 +263,7 @@ - + diff --git a/contrib/other-builds/moses/.project b/contrib/other-builds/moses/.project index 528db84f4..356ab713b 100644 --- a/contrib/other-builds/moses/.project +++ b/contrib/other-builds/moses/.project @@ -2249,6 +2249,7 @@ PARENT-1-ECLIPSE_HOME/github/mosesdecoder/moses/LM/bilingual-lm/BilingualLM.h +<<<<<<< HEAD LM/oxlm/LBLLM.cpp >>>>>>> add Bilingual LM class 1 @@ -2353,6 +2354,16 @@ Syntax/S2T/RuleTrieLoader.cpp 1 PARENT-3-PROJECT_LOC/moses/Syntax/S2T/RuleTrieLoader.cpp +======= + LM/oxlm/OxLM.cpp + 1 + PARENT-3-PROJECT_LOC/moses/LM/oxlm/OxLM.cpp + + + LM/oxlm/OxLM.h + 1 + PARENT-3-PROJECT_LOC/moses/LM/oxlm/OxLM.h +>>>>>>> Rename LBLLM -> OxLM. Syntax/S2T/RuleTrieLoader.h diff --git a/moses/Jamfile b/moses/Jamfile index 4e9732416..bb29b4d14 100644 --- a/moses/Jamfile +++ b/moses/Jamfile @@ -10,14 +10,6 @@ if $(with-dlib) { dlib = ; } -with-oxlm = [ option.get "with-oxlm" ] ; -if $(with-oxlm) { - oxlm2 = -std=c++0x LM_OXLM $(with-oxlm)/src $(with-oxlm)/third_party/eigen ; -} else { - oxlm2 = ; -} - -alias headers : ../util//kenutil : : : $(max-factors) $(dlib) $(oxlm2) ; alias ThreadPool : ThreadPool.cpp ; alias Util : Util.cpp Timer.cpp ; diff --git a/moses/LM/oxlm/Mapper.cpp b/moses/LM/oxlm/Mapper.cpp deleted file mode 100644 index be171fd07..000000000 --- a/moses/LM/oxlm/Mapper.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "Mapper.h" -#include "moses/FactorCollection.h" - -using namespace std; - -namespace Moses { - -OXLMMapper::OXLMMapper(const boost::shared_ptr& vocab) - : vocab(vocab) { - for (int i = 0; i < vocab->size(); ++i) { - const string &str = vocab->convert(i); - FactorCollection &fc = FactorCollection::Instance(); - const Moses::Factor *factor = fc.AddFactor(str, false); - moses2lbl[factor] = i; - } - - kUNKNOWN = vocab->convert(""); -} - -int OXLMMapper::convert(const Moses::Factor* factor) const { - Coll::const_iterator iter; - iter = moses2lbl.find(factor); - if (iter == moses2lbl.end()) { - return kUNKNOWN; - } else { - int ret = iter->second; - return ret; - } -} - -std::vector OXLMMapper::convert(const Phrase& phrase) const { - size_t size = phrase.GetSize(); - vector ret(size); - for (size_t i = 0; i < size; ++i) { - const Moses::Factor *factor = phrase.GetFactor(i, 0); - int id = convert(factor); - ret[i] = id; - } - - return ret; -} - -void OXLMMapper::convert( - const std::vector& contextFactor, - std::vector& ids, - int& word) const { - size_t size = contextFactor.size(); - ids.resize(size - 1); - for (size_t i = 0; i < size - 1; ++i) { - const Moses::Factor *factor = contextFactor[i]->GetFactor(0); - int id = convert(factor); - ids[i] = id; - } - std::reverse(ids.begin(), ids.end()); - - const Moses::Factor *factor = contextFactor.back()->GetFactor(0); - word = convert(factor); -} - -} // namespace Moses diff --git a/moses/LM/oxlm/Mapper.h b/moses/LM/oxlm/Mapper.h deleted file mode 100644 index cec865cc0..000000000 --- a/moses/LM/oxlm/Mapper.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include - -#include "lbl/vocabulary.h" - -#include "moses/Factor.h" -#include "moses/Phrase.h" - -namespace Moses { - -class OXLMMapper { - public: - OXLMMapper(const boost::shared_ptr& vocab); - - int convert(const Moses::Factor *factor) const; - - std::vector convert(const Phrase &phrase) const; - - void convert( - const std::vector &contextFactor, - std::vector &ids, - int &word) const; - - private: - void add(int lbl_id, int cdec_id); - - boost::shared_ptr vocab; - typedef std::map Coll; - Coll moses2lbl; - int kUNKNOWN; -}; - -/** - * Wraps the feature values computed from the LBL language model. - */ -struct LBLFeatures { - LBLFeatures() : LMScore(0), OOVScore(0) {} - LBLFeatures(double lm_score, double oov_score) - : LMScore(lm_score), OOVScore(oov_score) {} - LBLFeatures& operator+=(const LBLFeatures& other) { - LMScore += other.LMScore; - OOVScore += other.OOVScore; - return *this; - } - - double LMScore; - double OOVScore; -}; - -} // namespace Moses