mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
move checking of legacy phrase-table to StaticData
This commit is contained in:
parent
6e32bd3e19
commit
f2d218f8ee
@ -5,7 +5,6 @@
|
||||
|
||||
#include "FactorCollection.h"
|
||||
#include "Util.h"
|
||||
#include "moses/TranslationModel/PhraseDictionaryTreeAdaptor.h"
|
||||
#include "TranslationOptionCollectionConfusionNet.h"
|
||||
#include "StaticData.h"
|
||||
#include "Sentence.h"
|
||||
|
@ -76,6 +76,7 @@ public:
|
||||
return m_defaultLabelSet;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& out,const ConfusionNet& cn);
|
||||
|
@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "InputType.h"
|
||||
#include "ChartTranslationOptions.h"
|
||||
#include "StaticData.h"
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
|
@ -41,7 +41,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#include "InputFileStream.h"
|
||||
#include "ScoreComponentCollection.h"
|
||||
#include "DecodeGraph.h"
|
||||
#include "moses/TranslationModel/PhraseDictionary.h"
|
||||
#include "TranslationModel/PhraseDictionary.h"
|
||||
#include "TranslationModel/PhraseDictionaryTreeAdaptor.h"
|
||||
|
||||
#ifdef WITH_THREADS
|
||||
#include <boost/thread.hpp>
|
||||
@ -915,6 +916,7 @@ void StaticData::LoadFeatureFunctions()
|
||||
pt->Load();
|
||||
}
|
||||
|
||||
CheckLEGACYPT();
|
||||
}
|
||||
|
||||
bool StaticData::CheckWeights() const
|
||||
@ -1065,5 +1067,20 @@ void StaticData::OverrideFeatures()
|
||||
|
||||
}
|
||||
|
||||
// check whether we should be using the old code to support binary phrase-table.
|
||||
// eventually, we'll stop support the binary phrase-table and delete this legacy code
|
||||
void StaticData::CheckLEGACYPT()
|
||||
{
|
||||
for (size_t i = 0; i < m_phraseDictionary.size(); ++i) {
|
||||
const PhraseDictionary *phraseDictionary = m_phraseDictionary[i];
|
||||
if (dynamic_cast<const PhraseDictionaryTreeAdaptor*>(phraseDictionary) != NULL) {
|
||||
m_useLegacyPT = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_useLegacyPT = false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -208,6 +208,7 @@ protected:
|
||||
std::map< std::string, std::set< size_t > > m_weightSettingIgnoreDP; // decoding path
|
||||
|
||||
FactorType m_placeHolderFactor;
|
||||
bool m_useLegacyPT;
|
||||
|
||||
StaticData();
|
||||
|
||||
@ -223,6 +224,7 @@ protected:
|
||||
bool m_continuePartialTranslation;
|
||||
std::string m_binPath;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
bool IsAlwaysCreateDirectTranslationOption() const {
|
||||
@ -751,6 +753,11 @@ public:
|
||||
FactorType GetPlaceholderFactor() const {
|
||||
return m_placeHolderFactor;
|
||||
}
|
||||
|
||||
void CheckLEGACYPT();
|
||||
bool GetUseLegacyPT() const
|
||||
{ return m_useLegacyPT; }
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -126,10 +126,6 @@ TranslationOptionCollectionConfusionNet::TranslationOptionCollectionConfusionNet
|
||||
} // for (iterPath = prevPaths.begin(); iterPath != prevPaths.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)
|
||||
@ -166,7 +162,7 @@ void TranslationOptionCollectionConfusionNet::ProcessUnknownWord(size_t sourcePo
|
||||
|
||||
void TranslationOptionCollectionConfusionNet::CreateTranslationOptions()
|
||||
{
|
||||
if (!m_useLegacy) {
|
||||
if (!StaticData::Instance().GetUseLegacyPT()) {
|
||||
GetTargetPhraseCollectionBatch();
|
||||
}
|
||||
TranslationOptionCollection::CreateTranslationOptions();
|
||||
@ -188,7 +184,7 @@ void TranslationOptionCollectionConfusionNet::CreateTranslationOptionsForRange(
|
||||
, bool adhereTableLimit
|
||||
, size_t graphInd)
|
||||
{
|
||||
if (m_useLegacy) {
|
||||
if (StaticData::Instance().GetUseLegacyPT()) {
|
||||
CreateTranslationOptionsForRangeLEGACY(decodeGraph, startPos, endPos, adhereTableLimit, graphInd);
|
||||
} else {
|
||||
CreateTranslationOptionsForRangeNew(decodeGraph, startPos, endPos, adhereTableLimit, graphInd);
|
||||
@ -300,19 +296,6 @@ void TranslationOptionCollectionConfusionNet::CreateTranslationOptionsForRangeLE
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,6 @@ public:
|
||||
typedef std::vector< std::vector<InputPathList> > InputPathMatrix;
|
||||
|
||||
protected:
|
||||
bool m_useLegacy;
|
||||
|
||||
InputPathMatrix m_inputPathMatrix; /*< contains translation options */
|
||||
|
||||
InputPathList &GetInputPathList(size_t startPos, size_t endPos);
|
||||
@ -30,7 +28,6 @@ protected:
|
||||
, bool adhereTableLimit
|
||||
, size_t graphInd);
|
||||
|
||||
void CheckLEGACY();
|
||||
void CreateTranslationOptionsForRangeLEGACY(const DecodeGraph &decodeStepList
|
||||
, size_t startPosition
|
||||
, size_t endPosition
|
||||
|
@ -126,10 +126,6 @@ TranslationOptionCollectionLattice::TranslationOptionCollectionLattice(
|
||||
} // for (iterPath = prevPaths.begin(); iterPath != prevPaths.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 &TranslationOptionCollectionLattice::GetInputPathList(size_t startPos, size_t endPos)
|
||||
@ -166,7 +162,7 @@ void TranslationOptionCollectionLattice::ProcessUnknownWord(size_t sourcePos)
|
||||
|
||||
void TranslationOptionCollectionLattice::CreateTranslationOptions()
|
||||
{
|
||||
if (!m_useLegacy) {
|
||||
if (!StaticData::Instance().GetUseLegacyPT()) {
|
||||
GetTargetPhraseCollectionBatch();
|
||||
}
|
||||
TranslationOptionCollection::CreateTranslationOptions();
|
||||
@ -188,7 +184,7 @@ void TranslationOptionCollectionLattice::CreateTranslationOptionsForRange(
|
||||
, bool adhereTableLimit
|
||||
, size_t graphInd)
|
||||
{
|
||||
if (m_useLegacy) {
|
||||
if (StaticData::Instance().GetUseLegacyPT()) {
|
||||
CreateTranslationOptionsForRangeLEGACY(decodeGraph, startPos, endPos, adhereTableLimit, graphInd);
|
||||
} else {
|
||||
CreateTranslationOptionsForRangeNew(decodeGraph, startPos, endPos, adhereTableLimit, graphInd);
|
||||
@ -300,20 +296,7 @@ void TranslationOptionCollectionLattice::CreateTranslationOptionsForRangeLEGACY(
|
||||
}
|
||||
}
|
||||
|
||||
void TranslationOptionCollectionLattice::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;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
|
@ -18,7 +18,6 @@ public:
|
||||
typedef std::vector< std::vector<InputPathList> > InputPathMatrix;
|
||||
|
||||
protected:
|
||||
bool m_useLegacy;
|
||||
|
||||
InputPathMatrix m_inputPathMatrix; /*< contains translation options */
|
||||
|
||||
@ -29,7 +28,6 @@ protected:
|
||||
, bool adhereTableLimit
|
||||
, size_t graphInd);
|
||||
|
||||
void CheckLEGACY();
|
||||
void CreateTranslationOptionsForRangeLEGACY(const DecodeGraph &decodeStepList
|
||||
, size_t startPosition
|
||||
, size_t endPosition
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "Util.h"
|
||||
#include "FloydWarshall.h"
|
||||
#include "TranslationOptionCollectionLattice.h"
|
||||
#include "TranslationOptionCollectionConfusionNet.h"
|
||||
#include "moses/FF/InputFeature.h"
|
||||
#include "util/check.hh"
|
||||
|
||||
@ -214,6 +215,7 @@ WordLattice::CreateTranslationOptionCollection() const
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& operator<<(std::ostream &out, const WordLattice &obj)
|
||||
{
|
||||
out << "next_nodes=";
|
||||
|
@ -46,7 +46,6 @@ public:
|
||||
{ return next_nodes[pos]; }
|
||||
|
||||
TranslationOptionCollection *CreateTranslationOptionCollection() const;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user