add -default-non-term-for-empty-range-only

This commit is contained in:
Hieu Hoang 2014-04-07 14:00:40 +01:00
parent 5d61639763
commit 6b1e147cff
4 changed files with 13 additions and 1 deletions

View File

@ -201,6 +201,8 @@ Parameter::Parameter()
AddParam("placeholder-factor", "Which source factor to use to store the original text for placeholders. The factor must not be used by a translation or gen model");
AddParam("no-cache", "Disable all phrase-table caching. Default = false (ie. enable caching)");
AddParam("default-non-term-for-empty-range-only", "Don't add [X] to all ranges, just ranges where there isn't a source non-term. Default = false (ie. add [X] everywhere)");
}
Parameter::~Parameter()

View File

@ -425,6 +425,9 @@ bool StaticData::LoadData(Parameter *parameter)
}
if (m_useConsensusDecoding) m_mbr=true;
SetBooleanParameter( &m_defaultNonTermOnlyForEmptyRange, "default-non-term-for-empty-range-only", false );
// Compact phrase table and reordering model
SetBooleanParameter( &m_minphrMemory, "minphr-memory", false );
SetBooleanParameter( &m_minlexrMemory, "minlexr-memory", false );

View File

@ -197,6 +197,7 @@ protected:
FactorType m_placeHolderFactor;
bool m_useLegacyPT;
bool m_defaultNonTermOnlyForEmptyRange;
FeatureRegistry m_registry;
@ -761,6 +762,9 @@ public:
m_treeStructure = treeStructure;
}
bool GetDefaultNonTermOnlyForEmptyRange() const
{ return m_defaultNonTermOnlyForEmptyRange; }
};
}

View File

@ -265,7 +265,10 @@ int TreeInput::Read(std::istream& in,const std::vector<FactorType>& factorOrder)
// default label
for (size_t startPos = 0; startPos < sourceSize; ++startPos) {
for (size_t endPos = startPos; endPos < sourceSize; ++endPos) {
AddChartLabel(startPos, endPos, staticData.GetInputDefaultNonTerminal(), factorOrder);
NonTerminalSet &list = GetLabelSet(startPos, endPos);
if (list.size() == 0 || !staticData.GetDefaultNonTermOnlyForEmptyRange()) {
AddChartLabel(startPos, endPos, staticData.GetInputDefaultNonTerminal(), factorOrder);
}
}
}