add functionalty to support adding direct translation (ie, passthrouh) even when there are other translation options available for the span.

git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1510 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
redpony 2007-11-10 23:19:41 +00:00
parent 80d66757c6
commit 9521e78fbf
7 changed files with 17 additions and 7 deletions

View File

@ -73,6 +73,7 @@ StaticData::StaticData()
,m_onlyDistinctNBest(false)
,m_computeLMBackoffStats(false)
,m_factorDelimiter("|") // default delimiter between factors
,m_isAlwaysCreateDirectTranslationOption(true)
{
m_maxFactorIdx[0] = 0; // source side
m_maxFactorIdx[1] = 0; // target side

View File

@ -120,6 +120,7 @@ protected:
float m_mbrScale; //! Scaling factor for computing marginal probability of candidate translation
mutable const InputType* m_input; //! holds reference to current sentence
bool m_isAlwaysCreateDirectTranslationOption;
//! constructor. only the 1 static variable can be created
StaticData();
@ -143,6 +144,9 @@ protected:
public:
bool IsAlwaysCreateDirectTranslationOption() const {
return m_isAlwaysCreateDirectTranslationOption;
}
//! destructor
~StaticData();
//! return static instance for use like global variable

View File

@ -61,10 +61,12 @@ TranslationOption::TranslationOption(const WordsRange &wordsRange
, m_futureScore(0)
{
const UnknownWordPenaltyProducer *up = StaticData::Instance().GetUnknownWordPenaltyProducer();
const ScoreProducer *scoreProducer = (const ScoreProducer *)up; // not sure why none of the c++ cast works
vector<float> score(1);
score[0] = FloorScore(-numeric_limits<float>::infinity());
m_scoreBreakdown.Assign(scoreProducer, score);
if (up) {
const ScoreProducer *scoreProducer = (const ScoreProducer *)up; // not sure why none of the c++ cast works
vector<float> score(1);
score[0] = FloorScore(-numeric_limits<float>::infinity());
m_scoreBreakdown.Assign(scoreProducer, score);
}
if (inputType.GetType() == SentenceInput)
{

View File

@ -160,11 +160,12 @@ void TranslationOptionCollection::ProcessUnknownWord(const std::vector <DecodeGr
}
}
bool alwaysCreateDirectTranslationOption = StaticData::Instance().IsAlwaysCreateDirectTranslationOption();
// create unknown words for 1 word coverage where we don't have any trans options
for (size_t pos = 0 ; pos < size ; ++pos)
{
TranslationOptionList &fullList = GetTranslationOptionList(pos, pos);
if (fullList.size() == 0)
if (fullList.size() == 0 || alwaysCreateDirectTranslationOption)
ProcessUnknownWord(pos);
}
}

View File

@ -27,7 +27,7 @@ void TranslationOptionCollectionConfusionNet::ProcessUnknownWord(
size_t j=0;
for(ConfusionNet::Column::const_iterator i=coll.begin();i!=coll.end();++i) {
ProcessOneUnknownWord(i->first ,sourcePos, source.GetColumnIncrement(sourcePos, j++));
}
}
}

View File

@ -24,7 +24,7 @@ my @tests = qw (
xml-markup
);
############################################################
#@tests=qw(xml-markup);
#@tests=qw(lattice-distortion);
use MosesRegressionTesting;
use File::Temp qw ( tempfile );
use POSIX qw ( strftime );

View File

@ -24,6 +24,8 @@ TRANSLATION_2_NBEST_1=1 2 3 ||| d: 0 lm: -6.08823 I: 0 tm: -6.90776 -6.90776 w:
TRANSLATION_2_NBEST_2=2 3 1 ||| d: -2 lm: -9.26988 I: 0 tm: -6.90776 -6.90776 w: -3
TRANSLATION_2_NBEST_3=1 3 2 ||| d: -3 lm: -10.7767 I: 0 tm: -6.90776 -6.90776 w: -3
TRANSLATION_2_NBEST_4=3 1 2 ||| d: -3 lm: -10.9714 I: 0 tm: -6.90776 -6.90776 w: -3
TRANSLATION_2_NBEST_5=NOT_FOUND 3 ||| d: 0 lm: -105.485 I: 0 tm: -2.30259 -2.30259 w: -2
TRANSLATION_2_NBEST_6=3 NOT_FOUND ||| d: -3 lm: -105.49 I: 0 tm: -2.30259 -2.30259 w: -2
TRANSLATION_3_NBEST_1=1 2 3 ||| d: 0 lm: -6.08823 I: 0 tm: -6.90776 -6.90776 w: -3
TRANSLATION_3_NBEST_2=1 3 2 ||| d: -1 lm: -10.7767 I: 0 tm: -6.90776 -6.90776 w: -3
TRANSLATION_3_NBEST_3=1 12 ||| d: 0 lm: -9.28642 I: 0 tm: -4.60517 -4.60517 w: -2