make LanguageModelImplementation have new format constructor

This commit is contained in:
Hieu Hoang 2013-02-20 22:44:11 +00:00
parent 165ed39296
commit 1a1634a391
12 changed files with 26 additions and 24 deletions

View File

@ -40,6 +40,7 @@ using namespace std;
namespace Moses namespace Moses
{ {
LanguageModelIRST::LanguageModelIRST(const std::string &line) LanguageModelIRST::LanguageModelIRST(const std::string &line)
:LanguageModelSingleFactor("IRSTLM", line)
{ {
cerr << "line=" << line << endl; cerr << "line=" << line << endl;
FactorType factorType; FactorType factorType;
@ -68,11 +69,6 @@ LanguageModelIRST::LanguageModelIRST(const std::string &line)
Load(filePath, factorType, nGramOrder); Load(filePath, factorType, nGramOrder);
} }
LanguageModelIRST::LanguageModelIRST(int dub)
:m_lmtb(0),m_lmtb_dub(dub)
{
}
LanguageModelIRST::~LanguageModelIRST() LanguageModelIRST::~LanguageModelIRST()
{ {

View File

@ -64,7 +64,6 @@ protected:
public: public:
LanguageModelIRST(const std::string &line); LanguageModelIRST(const std::string &line);
LanguageModelIRST(int dub);
~LanguageModelIRST(); ~LanguageModelIRST();
bool Load(const std::string &filePath bool Load(const std::string &filePath
, FactorType factorType , FactorType factorType

View File

@ -63,7 +63,10 @@ protected:
Word m_sentenceStartArray, m_sentenceEndArray; //! Contains factors which represents the beging and end words for this LM. Word m_sentenceStartArray, m_sentenceEndArray; //! Contains factors which represents the beging and end words for this LM.
//! Usually <s> and </s> //! Usually <s> and </s>
LanguageModelImplementation(const std::string& description, const std::string &line)
{}
public: public:
virtual ~LanguageModelImplementation() {} virtual ~LanguageModelImplementation() {}
//! Single or multi-factor //! Single or multi-factor

View File

@ -49,7 +49,9 @@ protected:
size_t m_implFactor; size_t m_implFactor;
public: public:
LanguageModelJoint(LanguageModelSingleFactor *lmImpl) { LanguageModelJoint(const std::string &line, LanguageModelSingleFactor *lmImpl)
:LanguageModelMultiFactor("JointLM", line)
{
m_lmImpl = lmImpl; m_lmImpl = lmImpl;
} }

View File

@ -41,7 +41,9 @@ class LanguageModelMultiFactor : public LanguageModelImplementation
protected: protected:
FactorMask m_factorTypes; FactorMask m_factorTypes;
LanguageModelMultiFactor(){} LanguageModelMultiFactor(const std::string& description, const std::string &line)
:LanguageModelImplementation(description, line)
{}
public: public:
virtual bool Load(const std::string &filePath virtual bool Load(const std::string &filePath

View File

@ -20,8 +20,10 @@ class Phrase;
class LanguageModelORLM : public LanguageModelSingleFactor { class LanguageModelORLM : public LanguageModelSingleFactor {
public: public:
typedef count_t T; // type for ORLM filter typedef count_t T; // type for ORLM filter
LanguageModelORLM() LanguageModelORLM(const std::string &line)
: m_lm(0) {} :LanguageModelSingleFactor("ORLM", line)
,m_lm(0)
{}
bool Load(const std::string &filePath, FactorType factorType, size_t nGramOrder); bool Load(const std::string &filePath, FactorType factorType, size_t nGramOrder);
virtual LMResult GetValue(const std::vector<const Word*> &contextFactor, State* finalState = NULL) const; virtual LMResult GetValue(const std::vector<const Word*> &contextFactor, State* finalState = NULL) const;
~LanguageModelORLM() { ~LanguageModelORLM() {

View File

@ -69,6 +69,10 @@ private:
WidMatrix *widMatrix; WidMatrix *widMatrix;
public: public:
LanguageModelParallelBackoff(const std::string &line)
:LanguageModelMultiFactor("ParallelBackoffLM", line)
{}
~LanguageModelParallelBackoff(); ~LanguageModelParallelBackoff();
bool Load(const std::string &filePath, const std::vector<FactorType> &factorTypes, size_t nGramOrder); bool Load(const std::string &filePath, const std::vector<FactorType> &factorTypes, size_t nGramOrder);
@ -347,9 +351,6 @@ const FFState *LanguageModelParallelBackoff::GetBeginSentenceState() const
} }
LanguageModelMultiFactor *NewParallelBackoff() {
return new LanguageModelParallelBackoff();
}
} }

View File

@ -24,10 +24,5 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
namespace Moses namespace Moses
{ {
class LanguageModelMultiFactor;
/** @todo what is this?
*/
LanguageModelMultiFactor *NewParallelBackoff();
} }

View File

@ -38,9 +38,10 @@ using namespace std;
namespace Moses namespace Moses
{ {
LanguageModelSRI::LanguageModelSRI() LanguageModelSRI::LanguageModelSRI(const std::string &line)
: m_srilmVocab(0) :LanguageModelSingleFactor("SRILM", line)
, m_srilmModel(0) ,m_srilmVocab(0)
,m_srilmModel(0)
{ {
} }

View File

@ -52,7 +52,7 @@ protected:
unsigned int GetLmID( const Factor *factor ) const; unsigned int GetLmID( const Factor *factor ) const;
public: public:
LanguageModelSRI(); LanguageModelSRI(const std::string &line);
~LanguageModelSRI(); ~LanguageModelSRI();
bool Load(const std::string &filePath bool Load(const std::string &filePath
, FactorType factorType , FactorType factorType

View File

@ -49,7 +49,8 @@ struct PointerState : public FFState {
} }
}; };
LanguageModelSingleFactor::LanguageModelSingleFactor() LanguageModelSingleFactor::LanguageModelSingleFactor(const std::string& description, const std::string &line)
:LanguageModelImplementation(description, line)
{ {
m_nullContextState = new PointerState(NULL); m_nullContextState = new PointerState(NULL);
m_beginSentenceState = new PointerState(NULL); m_beginSentenceState = new PointerState(NULL);

View File

@ -43,7 +43,7 @@ protected:
FFState *m_nullContextState; FFState *m_nullContextState;
FFState *m_beginSentenceState; FFState *m_beginSentenceState;
LanguageModelSingleFactor(); LanguageModelSingleFactor(const std::string& description, const std::string &line);
public: public:
virtual ~LanguageModelSingleFactor(); virtual ~LanguageModelSingleFactor();