debugged FF NieceTerminal

This commit is contained in:
Hieu Hoang 2014-05-21 13:43:32 +01:00
parent b60ac0321f
commit 401c4940cf
3 changed files with 44 additions and 6 deletions

View File

@ -541,6 +541,11 @@
<type>1</type>
<locationURI>PARENT-3-PROJECT_LOC/moses/PDTAimp.h</locationURI>
</link>
<link>
<name>PP</name>
<type>2</type>
<locationURI>virtual:/virtual</locationURI>
</link>
<link>
<name>Parameter.cpp</name>
<type>1</type>
@ -1601,6 +1606,26 @@
<type>1</type>
<locationURI>PARENT-3-PROJECT_LOC/moses/LM/backward.arpa</locationURI>
</link>
<link>
<name>PP/Factory.cpp</name>
<type>1</type>
<locationURI>PARENT-3-PROJECT_LOC/moses/PP/Factory.cpp</locationURI>
</link>
<link>
<name>PP/Factory.h</name>
<type>1</type>
<locationURI>PARENT-3-PROJECT_LOC/moses/PP/Factory.h</locationURI>
</link>
<link>
<name>PP/PhraseProperty.h</name>
<type>1</type>
<locationURI>PARENT-3-PROJECT_LOC/moses/PP/PhraseProperty.h</locationURI>
</link>
<link>
<name>PP/TreeStructurePhraseProperty.h</name>
<type>1</type>
<locationURI>PARENT-3-PROJECT_LOC/moses/PP/TreeStructurePhraseProperty.h</locationURI>
</link>
<link>
<name>TranslationModel/BilingualDynSuffixArray.cpp</name>
<type>1</type>

View File

@ -4,6 +4,7 @@
#include "moses/ScoreComponentCollection.h"
#include "moses/TargetPhrase.h"
#include "moses/ChartCellLabel.h"
#include "moses/InputType.h"
using namespace std;
@ -30,7 +31,7 @@ void NieceTerminal::Evaluate(const InputType &input
std::set<Word> terms;
for (size_t i = 0; i < ruleSource->GetSize(); ++i) {
const Word &word = ruleSource->GetWord(i);
if (word.IsNonTerminal()) {
if (!word.IsNonTerminal()) {
terms.insert(word);
}
}
@ -38,12 +39,16 @@ void NieceTerminal::Evaluate(const InputType &input
size_t ntInd = 0;
for (size_t i = 0; i < ruleSource->GetSize(); ++i) {
const Word &word = ruleSource->GetWord(i);
if (!word.IsNonTerminal()) {
if (word.IsNonTerminal()) {
const ChartCellLabel &cell = *stackVec->at(ntInd);
const WordsRange &ntRange = cell.GetCoverage();
bool containTerm = ContainTerm(ntRange, terms);
bool containTerm = ContainTerm(input, ntRange, terms);
if (containTerm) {
//cerr << "ruleSource=" << *ruleSource << " ";
//cerr << "ntRange=" << ntRange << endl;
// non-term contains 1 of the terms in the rule.
scoreBreakdown.PlusEquals(this, 1);
return;
}
@ -61,13 +66,19 @@ void NieceTerminal::EvaluateChart(const ChartHypothesis &hypo,
ScoreComponentCollection* accumulator) const
{}
bool NieceTerminal::ContainTerm(const WordsRange &ntRange, const std::set<Word> &terms) const
bool NieceTerminal::ContainTerm(const InputType &input,
const WordsRange &ntRange,
const std::set<Word> &terms) const
{
std::set<Word>::const_iterator iter;
for (size_t pos = ntRange.GetStartPos(); pos <= ntRange.GetEndPos(); ++pos) {
const Word &word = input.GetWord(pos);
iter = terms.find(word);
// iter = terms.find(ntRange);
if (iter != terms.end()) {
return true;
}
}
return false;
}

View File

@ -37,7 +37,9 @@ public:
ScoreComponentCollection* accumulator) const;
protected:
bool ContainTerm(const WordsRange &ntRange, const std::set<Word> &terms) const;
bool ContainTerm(const InputType &input,
const WordsRange &ntRange,
const std::set<Word> &terms) const;
};
}