mosesdecoder/moses/LM/MaxEntSRI.h
Lane Schwartz f40e1ac8f8 Added support for hierarchical maximum entropy LM through SRILM.
Currently, the code compiles, but has not been run or tested.

    Steps to compile with maxent LM are below:

    - Download SRILM 1.6.0

    - Download the maxent patch from
      http://www.phon.ioc.ee/~tanela/srilm-me/srilm-1.6.0-me.patch

    - Download the required libLBFGS library from
      http://www.chokkan.org/software/liblbfgs

    - Edit SRILM's sbin/machine-type script
      to return MACHINE_TYPE=i686-m64 for case x86_64

    - Compile libLBFGS and install it in the /tools/SRILM/SRILM-1.7.0 directory.
      Make sure that the liblbfgs.* library files are in /tools/SRILM/SRILM-1.7.0/lib//

    - In the /tools/SRILM/SRILM-1.7.0 dir, apply the maxent patch to SRILM:
      patch -p1 < srilm-1.6.0-me.patch

    - Point the appropriate SRILM makefile
      to see libLBFGS's include and lib dirs, following the instructions at:
      http://www.phon.ioc.ee/dokuwiki/doku.php?id=people:tanel:srilm-me.en

    - Compile SRILM

    - Compile Moses using --with-srilm and --with-maxent-srilm:
      ./bjam --with-srilm=/tools/SRILM/SRILM-1.7.0 --with-maxent-srilm=true

    NOTE: The above steps were for my original integration.
          Current versions of SRILM (such as 1.7.1) include the maxent patch.
          As such, it should be sufficient to compile a current version of SRILM
          with support form maxent enabled,
          and then compile Moses using --with-srilm and --with-maxent-srilm:
          ./bjam --with-srilm=/tools/SRILM/SRILM-1.7.0 --with-maxent-srilm=true
2013-12-20 15:04:09 -05:00

65 lines
1.9 KiB
C++

// $Id$
/***********************************************************************
Moses - factored phrase-based language decoder
Copyright (C) 2006 University of Edinburgh
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
***********************************************************************/
#ifndef moses_LanguageModelMaxEntSRI_h
#define moses_LanguageModelMaxEntSRI_h
#include <string>
#include <vector>
#include "moses/Factor.h"
#include "moses/TypeDef.h"
#include "SingleFactor.h"
class Factor;
class Phrase;
class Vocab;
class MEModel;
namespace Moses
{
/** Implementation of maximum entropy LM using SRILM's code.
*/
class LanguageModelMaxEntSRI : public LanguageModelSingleFactor
{
protected:
std::vector<unsigned int> m_lmIdLookup;
::Vocab *m_srilmVocab;
MEModel *m_srilmModel;
unsigned int m_unknownId;
LMResult GetValue(unsigned int wordId, unsigned int *context) const;
void CreateFactors();
unsigned int GetLmID( const std::string &str ) const;
unsigned int GetLmID( const Factor *factor ) const;
public:
LanguageModelMaxEntSRI(const std::string &line);
~LanguageModelMaxEntSRI();
void Load();
virtual LMResult GetValue(const std::vector<const Word*> &contextFactor, State* finalState = 0) const;
};
}
#endif