call legacy code for confusion network input with binary pt

This commit is contained in:
Hieu Hoang 2013-07-11 12:37:20 +01:00
parent e3982f9ea8
commit 01641bfeee
2 changed files with 22 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#include "DecodeStepTranslation.h"
#include "FactorCollection.h"
#include "FF/InputFeature.h"
#include "TranslationModel/PhraseDictionaryTreeAdaptor.h"
using namespace std;
@ -97,6 +98,10 @@ TranslationOptionCollectionConfusionNet::TranslationOptionCollectionConfusionNet
} // for (iterPath = prevNodes.begin(); iterPath != prevNodes.end(); ++iterPath) {
}
}
// check whether we should be using the old code to supportbinary phrase-table.
// eventually, we'll stop support the binary phrase-table and delete this legacy code
CheckLegacy();
}
InputPathList &TranslationOptionCollectionConfusionNet::GetInputPathList(size_t startPos, size_t endPos)
@ -203,6 +208,20 @@ void TranslationOptionCollectionConfusionNet::CreateTranslationOptionsForRange(
}
}
void TranslationOptionCollectionConfusionNet::CheckLegacy()
{
const std::vector<PhraseDictionary*> &pts = StaticData::Instance().GetPhraseDictionaries();
for (size_t i = 0; i < pts.size(); ++i) {
const PhraseDictionary *phraseDictionary = pts[i];
if (dynamic_cast<const PhraseDictionaryTreeAdaptor*>(phraseDictionary) != NULL) {
m_useLegacy = true;
return;
}
}
m_useLegacy = false;
}
}

View File

@ -19,9 +19,12 @@ public:
typedef std::vector< std::vector<InputPathList> > TargetPhraseMatrix;
protected:
bool m_useLegacy;
TargetPhraseMatrix m_targetPhrasesfromPt; /*< contains translation options */
InputPathList &GetInputPathList(size_t startPos, size_t endPos);
void CheckLegacy();
public:
TranslationOptionCollectionConfusionNet(const ConfusionNet &source, size_t maxNoTransOptPerCoverage, float translationOptionThreshold);