mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
move collection of generation-table from Staticdata to GenerationDictionary
This commit is contained in:
parent
c9d09a7168
commit
3f8972d67b
@ -534,7 +534,7 @@ void OutputFeatureWeightsForHypergraph(std::ostream &outputSearchGraphStream)
|
||||
for( size_t i=0; i<pds.size(); i++ ) {
|
||||
featureIndex = OutputFeatureWeightsForHypergraph(featureIndex, pds[i], outputSearchGraphStream);
|
||||
}
|
||||
const vector<const GenerationDictionary*>& gds = staticData.GetGenerationDictionaries();
|
||||
const vector<GenerationDictionary*>& gds = GenerationDictionary::GetColl();
|
||||
for( size_t i=0; i<gds.size(); i++ ) {
|
||||
featureIndex = OutputFeatureWeightsForHypergraph(featureIndex, gds[i], outputSearchGraphStream);
|
||||
}
|
||||
|
@ -34,10 +34,13 @@ using namespace std;
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
std::vector<GenerationDictionary*> GenerationDictionary::s_staticColl;
|
||||
|
||||
GenerationDictionary::GenerationDictionary(const std::string &line)
|
||||
: DecodeFeature(line)
|
||||
{
|
||||
s_staticColl.push_back(this);
|
||||
|
||||
ReadParameters();
|
||||
}
|
||||
|
||||
|
@ -46,12 +46,18 @@ class GenerationDictionary : public DecodeFeature
|
||||
{
|
||||
typedef std::map<const Word* , OutputWordCollection, WordComparer> Collection;
|
||||
protected:
|
||||
static std::vector<GenerationDictionary*> s_staticColl;
|
||||
|
||||
Collection m_collection;
|
||||
// 1st = source
|
||||
// 2nd = target
|
||||
std::string m_filePath;
|
||||
|
||||
public:
|
||||
static const std::vector<GenerationDictionary*>& GetColl() {
|
||||
return s_staticColl;
|
||||
}
|
||||
|
||||
GenerationDictionary(const std::string &line);
|
||||
virtual ~GenerationDictionary();
|
||||
|
||||
|
@ -691,7 +691,7 @@ void Manager::OutputFeatureWeightsForSLF(std::ostream &outputSearchGraphStream)
|
||||
for( size_t i=0; i<pds.size(); i++ ) {
|
||||
featureIndex = OutputFeatureWeightsForSLF(featureIndex, pds[i], outputSearchGraphStream);
|
||||
}
|
||||
const vector<const GenerationDictionary*>& gds = staticData.GetGenerationDictionaries();
|
||||
const vector<GenerationDictionary*>& gds = GenerationDictionary::GetColl();
|
||||
for( size_t i=0; i<gds.size(); i++ ) {
|
||||
featureIndex = OutputFeatureWeightsForSLF(featureIndex, gds[i], outputSearchGraphStream);
|
||||
}
|
||||
@ -730,7 +730,7 @@ void Manager::OutputFeatureValuesForSLF(const Hypothesis* hypo, bool zeros, std:
|
||||
for( size_t i=0; i<pds.size(); i++ ) {
|
||||
featureIndex = OutputFeatureValuesForSLF(featureIndex, zeros, hypo, pds[i], outputSearchGraphStream);
|
||||
}
|
||||
const vector<const GenerationDictionary*>& gds = staticData.GetGenerationDictionaries();
|
||||
const vector<GenerationDictionary*>& gds = GenerationDictionary::GetColl();
|
||||
for( size_t i=0; i<gds.size(); i++ ) {
|
||||
featureIndex = OutputFeatureValuesForSLF(featureIndex, zeros, hypo, gds[i], outputSearchGraphStream);
|
||||
}
|
||||
@ -764,7 +764,7 @@ void Manager::OutputFeatureValuesForHypergraph(const Hypothesis* hypo, std::ostr
|
||||
for( size_t i=0; i<pds.size(); i++ ) {
|
||||
featureIndex = OutputFeatureValuesForHypergraph(featureIndex, hypo, pds[i], outputSearchGraphStream);
|
||||
}
|
||||
const vector<const GenerationDictionary*>& gds = staticData.GetGenerationDictionaries();
|
||||
const vector<GenerationDictionary*>& gds = GenerationDictionary::GetColl();
|
||||
for( size_t i=0; i<gds.size(); i++ ) {
|
||||
featureIndex = OutputFeatureValuesForHypergraph(featureIndex, hypo, gds[i], outputSearchGraphStream);
|
||||
}
|
||||
|
@ -651,6 +651,7 @@ bool StaticData::LoadDecodeGraphs()
|
||||
const vector<string> &mappingVector = m_parameter->GetParam("mapping");
|
||||
const vector<size_t> &maxChartSpans = Scan<size_t>(m_parameter->GetParam("max-chart-span"));
|
||||
const vector<PhraseDictionary*>& pts = PhraseDictionary::GetColl();
|
||||
const vector<GenerationDictionary*>& gens = GenerationDictionary::GetColl();
|
||||
|
||||
const std::vector<FeatureFunction*> *featuresRemaining = &FeatureFunction::GetFeatureFunctions();
|
||||
DecodeStep *prev = 0;
|
||||
@ -698,14 +699,14 @@ bool StaticData::LoadDecodeGraphs()
|
||||
decodeStep = new DecodeStepTranslation(pts[index], prev, *featuresRemaining);
|
||||
break;
|
||||
case Generate:
|
||||
if(index>=m_generationDictionary.size()) {
|
||||
if(index>=gens.size()) {
|
||||
stringstream strme;
|
||||
strme << "No generation dictionary with index "
|
||||
<< index << " available!";
|
||||
UserMessage::Add(strme.str());
|
||||
CHECK(false);
|
||||
}
|
||||
decodeStep = new DecodeStepGeneration(m_generationDictionary[index], prev, *featuresRemaining);
|
||||
decodeStep = new DecodeStepGeneration(gens[index], prev, *featuresRemaining);
|
||||
break;
|
||||
case InsertNullFertilityWord:
|
||||
CHECK(!"Please implement NullFertilityInsertion.");
|
||||
@ -901,7 +902,7 @@ void StaticData::LoadFeatureFunctions()
|
||||
doLoad = false;
|
||||
} else if (const GenerationDictionary *ffCast
|
||||
= dynamic_cast<const GenerationDictionary*>(ff)) {
|
||||
m_generationDictionary.push_back(ffCast);
|
||||
// do nothing
|
||||
} else if (WordPenaltyProducer *ffCast
|
||||
= dynamic_cast<WordPenaltyProducer*>(ff)) {
|
||||
CHECK(m_wpProducer == NULL); // max 1 feature;
|
||||
|
@ -47,7 +47,6 @@ namespace Moses
|
||||
{
|
||||
|
||||
class InputType;
|
||||
class GenerationDictionary;
|
||||
class DecodeGraph;
|
||||
class DecodeStep;
|
||||
class WordPenaltyProducer;
|
||||
@ -66,7 +65,6 @@ class StaticData
|
||||
private:
|
||||
static StaticData s_instance;
|
||||
protected:
|
||||
std::vector<const GenerationDictionary*> m_generationDictionary;
|
||||
Parameter *m_parameter;
|
||||
std::vector<FactorType> m_inputFactorOrder, m_outputFactorOrder;
|
||||
mutable ScoreComponentCollection m_allWeights;
|
||||
@ -721,10 +719,6 @@ public:
|
||||
float GetWeightWordPenalty() const;
|
||||
float GetWeightUnknownWordPenalty() const;
|
||||
|
||||
const std::vector<const GenerationDictionary*>& GetGenerationDictionaries() const {
|
||||
return m_generationDictionary;
|
||||
}
|
||||
|
||||
const std::vector<DecodeGraph*>& GetDecodeGraphs() const {
|
||||
return m_decodeGraphs;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user