Merge branch 'master' of github.com:moses-smt/mosesdecoder

This commit is contained in:
Barry Haddow 2013-07-25 15:56:44 +01:00
commit 29aa9ea153
7 changed files with 45 additions and 37 deletions

View File

@ -4,11 +4,12 @@
using namespace std; using namespace std;
namespace Moses { namespace Moses
{
ControlRecombination::ControlRecombination(const std::string &line) ControlRecombination::ControlRecombination(const std::string &line)
:StatefulFeatureFunction("ControlRecombination", 0, line) :StatefulFeatureFunction("ControlRecombination", 0, line)
,m_type(Output) ,m_type(Output)
{ {
} }
@ -44,12 +45,12 @@ const FFState* ControlRecombination::EmptyHypothesisState(const InputType &input
} }
ControlRecombinationState::ControlRecombinationState() ControlRecombinationState::ControlRecombinationState()
:m_hypo(NULL) :m_hypo(NULL)
{ {
} }
ControlRecombinationState::ControlRecombinationState(const Hypothesis *hypo) ControlRecombinationState::ControlRecombinationState(const Hypothesis *hypo)
:m_hypo(hypo) :m_hypo(hypo)
{ {
} }

View File

@ -4,7 +4,8 @@
#include "StatefulFeatureFunction.h" #include "StatefulFeatureFunction.h"
#include "moses/FF/FFState.h" #include "moses/FF/FFState.h"
namespace Moses { namespace Moses
{
class ControlRecombinationState; class ControlRecombinationState;
@ -12,17 +13,16 @@ class ControlRecombinationState;
class ControlRecombination : public StatefulFeatureFunction class ControlRecombination : public StatefulFeatureFunction
{ {
public: public:
enum Type enum Type {
{ None,
None, Output,
Output, Segmentation
Segmentation };
};
ControlRecombination(const std::string &line); ControlRecombination(const std::string &line);
bool IsUseable(const FactorMask &mask) const { bool IsUseable(const FactorMask &mask) const {
return true; return true;
} }
virtual FFState* Evaluate( virtual FFState* Evaluate(

View File

@ -42,7 +42,8 @@ LanguageModelRandLM::LanguageModelRandLM(const std::string &line)
{ {
} }
LanguageModelRandLM::~LanguageModelRandLM() { LanguageModelRandLM::~LanguageModelRandLM()
{
delete m_lm; delete m_lm;
} }
@ -100,7 +101,8 @@ randlm::WordID LanguageModelRandLM::GetLmID( const std::string &str ) const
return m_lm->getWordID(str); return m_lm->getWordID(str);
} }
randlm::WordID LanguageModelRandLM::GetLmID( const Factor *factor ) const { randlm::WordID LanguageModelRandLM::GetLmID( const Factor *factor ) const
{
size_t factorId = factor->GetId(); size_t factorId = factor->GetId();
return ( factorId >= m_randlm_ids_vec.size()) ? m_oov_id : m_randlm_ids_vec[factorId]; return ( factorId >= m_randlm_ids_vec.size()) ? m_oov_id : m_randlm_ids_vec[factorId];
} }
@ -127,10 +129,12 @@ LMResult LanguageModelRandLM::GetValue(const vector<const Word*> &contextFactor,
return ret; return ret;
} }
void LanguageModelRandLM::InitializeForInput(InputType const& source) { void LanguageModelRandLM::InitializeForInput(InputType const& source)
{
m_lm->initThreadSpecificData(); // Creates thread specific data iff // compiled with multithreading. m_lm->initThreadSpecificData(); // Creates thread specific data iff // compiled with multithreading.
} }
void LanguageModelRandLM::CleanUpAfterSentenceProcessing(const InputType& source) { void LanguageModelRandLM::CleanUpAfterSentenceProcessing(const InputType& source)
{
m_lm->clearCaches(); // clear caches m_lm->clearCaches(); // clear caches
} }

View File

@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
namespace randlm namespace randlm
{ {
class RandLM; class RandLM;
} }
namespace Moses namespace Moses

View File

@ -174,12 +174,12 @@ Parameter::Parameter()
AddParam("lmodel-file", "DEPRECATED. DO NOT USE. location and properties of the language models"); AddParam("lmodel-file", "DEPRECATED. DO NOT USE. location and properties of the language models");
AddParam("lmodel-dub", "DEPRECATED. DO NOT USE. dictionary upper bounds of language models"); AddParam("lmodel-dub", "DEPRECATED. DO NOT USE. dictionary upper bounds of language models");
#ifdef HAVE_SYNLM #ifdef HAVE_SYNLM
AddParam("slmodel-file", "DEPRECATED. DO NOT USE. location of the syntactic language model file(s)"); AddParam("slmodel-file", "DEPRECATED. DO NOT USE. location of the syntactic language model file(s)");
AddParam("slmodel-factor", "DEPRECATED. DO NOT USE. factor to use with syntactic language model"); AddParam("slmodel-factor", "DEPRECATED. DO NOT USE. factor to use with syntactic language model");
AddParam("slmodel-beam", "DEPRECATED. DO NOT USE. beam width to use with syntactic language model's parser"); AddParam("slmodel-beam", "DEPRECATED. DO NOT USE. beam width to use with syntactic language model's parser");
#endif #endif
AddParam("ttable-file", "DEPRECATED. DO NOT USE. location and properties of the translation tables"); AddParam("ttable-file", "DEPRECATED. DO NOT USE. location and properties of the translation tables");
AddParam("phrase-pair-feature", "DEPRECATED. DO NOT USE. Source and target factors for phrase pair feature"); AddParam("phrase-pair-feature", "DEPRECATED. DO NOT USE. Source and target factors for phrase pair feature");
AddParam("phrase-boundary-source-feature", "DEPRECATED. DO NOT USE. Source factors for phrase boundary feature"); AddParam("phrase-boundary-source-feature", "DEPRECATED. DO NOT USE. Source factors for phrase boundary feature");
AddParam("phrase-boundary-target-feature", "DEPRECATED. DO NOT USE. Target factors for phrase boundary feature"); AddParam("phrase-boundary-target-feature", "DEPRECATED. DO NOT USE. Target factors for phrase boundary feature");
@ -312,21 +312,21 @@ bool Parameter::LoadParam(int argc, char* argv[])
// don't mix old and new format // don't mix old and new format
if ((isParamSpecified("feature") || isParamSpecified("weight")) if ((isParamSpecified("feature") || isParamSpecified("weight"))
&& (isParamSpecified("weight-slm") || isParamSpecified("weight-bl") || isParamSpecified("weight-d") || && (isParamSpecified("weight-slm") || isParamSpecified("weight-bl") || isParamSpecified("weight-d") ||
isParamSpecified("weight-dlm") || isParamSpecified("weight-lrl") || isParamSpecified("weight-generation") || isParamSpecified("weight-dlm") || isParamSpecified("weight-lrl") || isParamSpecified("weight-generation") ||
isParamSpecified("weight-i") || isParamSpecified("weight-l") || isParamSpecified("weight-lex") || isParamSpecified("weight-i") || isParamSpecified("weight-l") || isParamSpecified("weight-lex") ||
isParamSpecified("weight-glm") || isParamSpecified("weight-wt") || isParamSpecified("weight-pp") || isParamSpecified("weight-glm") || isParamSpecified("weight-wt") || isParamSpecified("weight-pp") ||
isParamSpecified("weight-pb") || isParamSpecified("weight-t") || isParamSpecified("weight-w") || isParamSpecified("weight-pb") || isParamSpecified("weight-t") || isParamSpecified("weight-w") ||
isParamSpecified("weight-u") || isParamSpecified("weight-e") || isParamSpecified("weight-u") || isParamSpecified("weight-e") ||
isParamSpecified("dlm-mode") || isParamSpecified("generation-file") || isParamSpecified("global-lexical-file") || isParamSpecified("dlm-mode") || isParamSpecified("generation-file") || isParamSpecified("global-lexical-file") ||
isParamSpecified("glm-feature") || isParamSpecified("lmodel-file") || isParamSpecified("lmodel-dub") || isParamSpecified("glm-feature") || isParamSpecified("lmodel-file") || isParamSpecified("lmodel-dub") ||
isParamSpecified("slmodel-file") || isParamSpecified("slmodel-factor") || isParamSpecified("slmodel-file") || isParamSpecified("slmodel-factor") ||
isParamSpecified("slmodel-beam") || isParamSpecified("ttable-file") || isParamSpecified("phrase-pair-feature") || isParamSpecified("slmodel-beam") || isParamSpecified("ttable-file") || isParamSpecified("phrase-pair-feature") ||
isParamSpecified("phrase-boundary-source-feature") || isParamSpecified("phrase-boundary-target-feature") || isParamSpecified("phrase-length-feature") || isParamSpecified("phrase-boundary-source-feature") || isParamSpecified("phrase-boundary-target-feature") || isParamSpecified("phrase-length-feature") ||
isParamSpecified("target-word-insertion-feature") || isParamSpecified("source-word-deletion-feature") || isParamSpecified("word-translation-feature") isParamSpecified("target-word-insertion-feature") || isParamSpecified("source-word-deletion-feature") || isParamSpecified("word-translation-feature")
) )
) { ) {
UTIL_THROW(util::Exception, "Don't mix old and new ini file format"); UTIL_THROW(util::Exception, "Don't mix old and new ini file format");
} }
// convert old weights args to new format // convert old weights args to new format

View File

@ -21,7 +21,7 @@ sub run {
} }
my $sourceLocale = $opts{s} || ""; my $sourceLocale = $opts{s} || "";
my $targetLocale = $opts{t} || ""; my $targetLocale = $opts{t} || "";
my $numberSymbol = $opts{m} || '@NUM@'; my $numberSymbol = $opts{m} || '@num@';
while(<>) { while(<>) {
chomp; chomp;
print mark_numbers($_,$opts{c},$opts{l},$numberSymbol,$_),"\n"; print mark_numbers($_,$opts{c},$opts{l},$numberSymbol,$_),"\n";
@ -32,7 +32,7 @@ sub mark_numbers {
my $input = shift; my $input = shift;
my $corpusMode = shift; my $corpusMode = shift;
my $legacyMode = shift; my $legacyMode = shift;
my $numberSymbol = shift || '@NUM@'; my $numberSymbol = shift || '@num@';
my $numref = recognize($input); my $numref = recognize($input);
my $input_length = length($input); my $input_length = length($input);

View File

@ -28,6 +28,9 @@ sub Beautify($)
next if ($name eq "util"); next if ($name eq "util");
next if ($name eq "lm"); next if ($name eq "lm");
next if ($name eq "search"); next if ($name eq "search");
next if ($name eq "randlm");
next if ($name eq "srilm");
next if ($name eq "irstlm");
$name = $path ."/" .$name; $name = $path ."/" .$name;
if (-d $name) { if (-d $name) {