diff --git a/moses/.cdtbuild b/moses/.cdtbuild
index bd5d27046..8a77858e4 100755
--- a/moses/.cdtbuild
+++ b/moses/.cdtbuild
@@ -23,7 +23,7 @@
-
+
@@ -78,7 +78,7 @@
-
+
diff --git a/moses/src/ConfusionNet.cpp b/moses/src/ConfusionNet.cpp
index f5fc1e88d..1195a61a6 100644
--- a/moses/src/ConfusionNet.cpp
+++ b/moses/src/ConfusionNet.cpp
@@ -9,7 +9,8 @@
#include "Util.h"
#include "PhraseDictionaryTreeAdaptor.h"
#include "TranslationOptionCollectionConfusionNet.h"
-
+#include "StaticData.h"
+
struct CNStats {
unsigned created,destr,read,colls,words;
@@ -195,7 +196,8 @@ CreateTargetPhraseCollection(PhraseDictionaryBase const& d,
TranslationOptionCollection*
ConfusionNet::CreateTranslationOptionCollection() const
{
- return new TranslationOptionCollectionConfusionNet(*this);
+ size_t maxNoTransOptPerCoverage = StaticData::Instance()->GetMaxNoTransOptPerCoverage();
+ return new TranslationOptionCollectionConfusionNet(*this, maxNoTransOptPerCoverage);
}
#endif
diff --git a/moses/src/Parameter.cpp b/moses/src/Parameter.cpp
index 399eb4554..40c288ba1 100755
--- a/moses/src/Parameter.cpp
+++ b/moses/src/Parameter.cpp
@@ -67,6 +67,7 @@ Parameter::Parameter()
AddParam("report-all-factors");
AddParam("drop-unknown");
AddParam("inputtype");
+ AddParam("max-trans-opt-per-coverage");
}
// check if parameter settings make sense
diff --git a/moses/src/Sentence.cpp b/moses/src/Sentence.cpp
index 066e8c101..8c18c03eb 100755
--- a/moses/src/Sentence.cpp
+++ b/moses/src/Sentence.cpp
@@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include
#include "PhraseDictionary.h"
#include "TranslationOptionCollectionText.h"
+#include "StaticData.h"
int Sentence::Read(std::istream& in,const std::vector& factorOrder,
FactorCollection &factorCollection)
@@ -48,7 +49,8 @@ CreateTargetPhraseCollection(PhraseDictionaryBase const& d,
TranslationOptionCollection*
Sentence::CreateTranslationOptionCollection() const
{
- return new TranslationOptionCollectionText(*this);
+ size_t maxNoTransOptPerCoverage = StaticData::Instance()->GetMaxNoTransOptPerCoverage();
+ return new TranslationOptionCollectionText(*this, maxNoTransOptPerCoverage);
}
void Sentence::Print(std::ostream& out) const
{
diff --git a/moses/src/StaticData.cpp b/moses/src/StaticData.cpp
index bd19c11d8..50011bb6a 100755
--- a/moses/src/StaticData.cpp
+++ b/moses/src/StaticData.cpp
@@ -287,6 +287,9 @@ bool StaticData::LoadParameters(int argc, char* argv[])
TransformScore(Scan(m_parameter.GetParam("beam-threshold")[0]))
: TransformScore(DEFAULT_BEAM_THRESHOLD);
+ m_maxNoTransOptPerCoverage = (m_parameter.GetParam("max-trans-opt-per-coverage").size() > 0)
+ ? Scan(m_parameter.GetParam("max-trans-opt-per-coverage")[0]) : DEFAULT_MAX_TRANS_OPT_SIZE;
+
// Unknown Word Processing -- wade
//TODO replace this w/general word dropping -- EVH
if (m_parameter.GetParam("drop-unknown").size() == 1)
diff --git a/moses/src/StaticData.h b/moses/src/StaticData.h
index 84ae94b84..bde1178b8 100755
--- a/moses/src/StaticData.h
+++ b/moses/src/StaticData.h
@@ -67,8 +67,11 @@ protected:
// do it differently from old pharaoh
// -ve = no limit on distortion
// 0 = no disortion (monotone in old pharaoh)
- size_t m_maxHypoStackSize; //hypothesis-stack size that triggers pruning
- size_t m_nBestSize;
+ size_t
+ m_maxHypoStackSize //hypothesis-stack size that triggers pruning
+ , m_nBestSize
+ , m_maxNoTransOptPerCoverage;
+
std::string m_nBestFilePath, m_cachePath;
std::vector m_mySQLParam;
InputOutput *m_inputOutput;
@@ -139,6 +142,10 @@ public:
{
return m_dropUnknown;
}
+ inline size_t GetMaxNoTransOptPerCoverage() const
+ {
+ return m_maxNoTransOptPerCoverage;
+ }
/*
boost::shared_ptr GetUnknownWordHandler()
{
diff --git a/moses/src/TranslationOptionCollection.cpp b/moses/src/TranslationOptionCollection.cpp
index 6f21f7626..bd0152c81 100644
--- a/moses/src/TranslationOptionCollection.cpp
+++ b/moses/src/TranslationOptionCollection.cpp
@@ -9,10 +9,11 @@
using namespace std;
-TranslationOptionCollection::TranslationOptionCollection(InputType const& src)
+TranslationOptionCollection::TranslationOptionCollection(InputType const& src, size_t maxNoTransOptPerCoverage)
: m_source(src)
,m_futureScore(src.GetSize())
,m_unknownWordPos(src.GetSize())
+ ,m_maxNoTransOptPerCoverage(maxNoTransOptPerCoverage)
{
// create 2-d vector
size_t size = src.GetSize();
diff --git a/moses/src/TranslationOptionCollection.h b/moses/src/TranslationOptionCollection.h
index 6803bc5a1..235521ec9 100755
--- a/moses/src/TranslationOptionCollection.h
+++ b/moses/src/TranslationOptionCollection.h
@@ -48,13 +48,14 @@ protected:
InputType const &m_source;
SquareMatrix m_futureScore;
WordsBitmap m_unknownWordPos;
- std::list m_allPhraseDictionary;
+ std::list m_allPhraseDictionary;
std::list m_allGenerationDictionary;
- std::set m_unknownTargetPhrase;
- // make sure phrase doesn't go out of memory while we're using it
+ std::set m_unknownTargetPhrase;
+ // make sure phrase doesn't go out of memory while we're using it
+ const size_t m_maxNoTransOptPerCoverage;
const LMList *m_allLM;
- TranslationOptionCollection(InputType const& src);
+ TranslationOptionCollection(InputType const& src, size_t maxNoTransOptPerCoverage);
void CalcFutureScore(size_t verboseLevel);
diff --git a/moses/src/TranslationOptionCollectionConfusionNet.cpp b/moses/src/TranslationOptionCollectionConfusionNet.cpp
index 29eae8c0e..86d9634b5 100644
--- a/moses/src/TranslationOptionCollectionConfusionNet.cpp
+++ b/moses/src/TranslationOptionCollectionConfusionNet.cpp
@@ -8,8 +8,8 @@
#include "LMList.h"
TranslationOptionCollectionConfusionNet::
-TranslationOptionCollectionConfusionNet(const ConfusionNet &input)
- : TranslationOptionCollection(input) {}
+TranslationOptionCollectionConfusionNet(const ConfusionNet &input, size_t maxNoTransOptPerCoverage)
+ : TranslationOptionCollection(input, maxNoTransOptPerCoverage) {}
void TranslationOptionCollectionConfusionNet::
ProcessUnknownWord( size_t sourcePos
diff --git a/moses/src/TranslationOptionCollectionConfusionNet.h b/moses/src/TranslationOptionCollectionConfusionNet.h
index 8dcf27b13..20fe84cb0 100644
--- a/moses/src/TranslationOptionCollectionConfusionNet.h
+++ b/moses/src/TranslationOptionCollectionConfusionNet.h
@@ -7,7 +7,7 @@ class ConfusionNet;
class TranslationOptionCollectionConfusionNet : public TranslationOptionCollection {
public:
- TranslationOptionCollectionConfusionNet(const ConfusionNet &source);
+ TranslationOptionCollectionConfusionNet(const ConfusionNet &source, size_t maxNoTransOptPerCoverage);
void ProcessUnknownWord( size_t sourcePos
, int dropUnknown
diff --git a/moses/src/TranslationOptionCollectionText.cpp b/moses/src/TranslationOptionCollectionText.cpp
index 361983599..56b10af23 100644
--- a/moses/src/TranslationOptionCollectionText.cpp
+++ b/moses/src/TranslationOptionCollectionText.cpp
@@ -10,8 +10,8 @@
using namespace std;
-TranslationOptionCollectionText::TranslationOptionCollectionText(Sentence const &inputSentence)
- : TranslationOptionCollection(inputSentence) {}
+TranslationOptionCollectionText::TranslationOptionCollectionText(Sentence const &inputSentence, size_t maxNoTransOptPerCoverage)
+ : TranslationOptionCollection(inputSentence, maxNoTransOptPerCoverage) {}
void TranslationOptionCollectionText::ProcessUnknownWord(size_t sourcePos
, int dropUnknown
diff --git a/moses/src/TranslationOptionCollectionText.h b/moses/src/TranslationOptionCollectionText.h
index 48a2b4880..cb8de50e7 100644
--- a/moses/src/TranslationOptionCollectionText.h
+++ b/moses/src/TranslationOptionCollectionText.h
@@ -15,7 +15,7 @@ protected:
, float weightWordPenalty);
public:
- TranslationOptionCollectionText(Sentence const& inputSentence);
+ TranslationOptionCollectionText(Sentence const& inputSentence, size_t maxNoTransOptPerCoverage);
};
diff --git a/moses/src/TypeDef.h b/moses/src/TypeDef.h
index 658c8caf7..2d2e5305d 100755
--- a/moses/src/TypeDef.h
+++ b/moses/src/TypeDef.h
@@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#define MAX_NGRAM_SIZE 20
const size_t DEFAULT_MAX_HYPOSTACK_SIZE = 200;
+const size_t DEFAULT_MAX_TRANS_OPT_SIZE = 50;
const size_t ARRAY_SIZE_INCR = 20; //amount by which a hypostack gets resized when necessary
const float LOWEST_SCORE = -100.0f;
const float DEFAULT_BEAM_THRESHOLD = 0.00001f;