correct creation of input paths for lattices

This commit is contained in:
Hieu Hoang 2013-10-04 13:08:14 +01:00
parent f18e35c42a
commit a0b6c381e0
4 changed files with 41 additions and 24 deletions

View File

@ -108,8 +108,6 @@ void PhraseDictionaryOnDisk::GetTargetPhraseCollectionBatch(InputPath &inputPath
const Phrase &phrase = inputPath.GetPhrase();
const InputPath *prevInputPath = inputPath.GetPrevPath();
cerr << "inputPath=" << inputPath << endl;
const OnDiskPt::PhraseNode *prevPtNode = NULL;
if (prevInputPath) {

View File

@ -105,30 +105,41 @@ TranslationOptionCollectionLattice::TranslationOptionCollectionLattice(
}
}
void TranslationOptionCollectionLattice::ProcessUnknownWord()
{
}
/* forcibly create translation option for a particular source word.
* call the base class' ProcessOneUnknownWord() for each possible word in the confusion network
* at a particular source position
*/
void TranslationOptionCollectionLattice::ProcessUnknownWord(size_t sourcePos)
{
}
void TranslationOptionCollectionLattice::CreateTranslationOptions()
{
GetTargetPhraseCollectionBatch();
//TranslationOptionCollection::CreateTranslationOptions();
VERBOSE(2,"Translation Option Collection\n " << *this << endl);
const vector <DecodeGraph*> &decodeGraphs = StaticData::Instance().GetDecodeGraphs();
CHECK(decodeGraphs.size() == 1);
const DecodeGraph &decodeGraph = *decodeGraphs[0];
CHECK(decodeGraph.GetSize() == 1);
ProcessUnknownWord();
const DecodeStep &decodeStep = **decodeGraph.begin();
const PhraseDictionary &phraseDictionary = *decodeStep.GetPhraseDictionaryFeature();
EvaluateWithSource();
for (size_t i = 0; i < m_inputPathQueue.size(); ++i) {
const InputPath &path = *m_inputPathQueue[i];
const TargetPhraseCollection *tpColl = path.GetTargetPhrases(phraseDictionary);
const WordsRange &range = path.GetWordsRange();
if (tpColl) {
TargetPhraseCollection::const_iterator iter;
for (iter = tpColl->begin(); iter != tpColl->end(); ++iter) {
const TargetPhrase &tp = **iter;
TranslationOption *transOpt = new TranslationOption(range, tp);
transOpt->SetInputPath(path);
transOpt->Evaluate(m_source);
Add(transOpt);
}
}
else if (path.GetPhrase().GetSize() == 1) {
// unknown word processing
ProcessOneUnknownWord(path, path.GetWordsRange().GetEndPos(), 1, path.GetInputScore());
}
}
// Prune
Prune();
@ -143,6 +154,11 @@ void TranslationOptionCollectionLattice::CreateTranslationOptions()
}
void TranslationOptionCollectionLattice::ProcessUnknownWord(size_t sourcePos)
{
UTIL_THROW(util::Exception, "ProcessUnknownWord() not implemented for lattice");
}
void TranslationOptionCollectionLattice::CreateTranslationOptionsForRange(const DecodeGraph &decodeStepList
, size_t startPosition
, size_t endPosition

View File

@ -15,8 +15,11 @@ class WordLattice;
class TranslationOptionCollectionLattice : public TranslationOptionCollection
{
protected:
void ProcessUnknownWord();
void ProcessUnknownWord(size_t sourcePos);
/* forcibly create translation option for a 1 word.
* call the base class' ProcessOneUnknownWord() for each possible word in the confusion network
* at a particular source position
*/
void ProcessUnknownWord(size_t sourcePos); // do not implement
public:
TranslationOptionCollectionLattice(const WordLattice &source, size_t maxNoTransOptPerCoverage, float translationOptionThreshold);
@ -27,7 +30,7 @@ public:
, size_t startPosition
, size_t endPosition
, bool adhereTableLimit
, size_t graphInd);
, size_t graphInd); // do not implement
protected:

View File

@ -212,15 +212,15 @@ WordLattice::CreateTranslationOptionCollection() const
float translationOptionThreshold = StaticData::Instance().GetTranslationOptionThreshold();
TranslationOptionCollection *rv = NULL;
rv = new TranslationOptionCollectionConfusionNet(*this, maxNoTransOptPerCoverage, translationOptionThreshold);
/*
//rv = new TranslationOptionCollectionConfusionNet(*this, maxNoTransOptPerCoverage, translationOptionThreshold);
if (StaticData::Instance().GetUseLegacyPT()) {
rv = new TranslationOptionCollectionConfusionNet(*this, maxNoTransOptPerCoverage, translationOptionThreshold);
}
else {
rv = new TranslationOptionCollectionLattice(*this, maxNoTransOptPerCoverage, translationOptionThreshold);
}
*/
CHECK(rv);
return rv;
}