mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 19:27:11 +03:00
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:
parent
80d66757c6
commit
9521e78fbf
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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++));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user