@@ -35,7 +35,7 @@ PhraseDictionaryMultiModel::PhraseDictionaryMultiModel(const std::string &line)
35
35
UTIL_THROW_IF2 (m_pdStr.size () != m_multimodelweights.size () &&
36
36
m_pdStr.size ()*numWeights != m_multimodelweights.size (),
37
37
" Number of scores and weights are not equal" );
38
- } else if (m_mode == " all" ) {
38
+ } else if (m_mode == " all" || m_mode == " all-restrict " ) {
39
39
size_t componentWeights = 0 ;
40
40
for (size_t i = 0 ; i < m_numModels; ++i) {
41
41
const string &ptName = m_pdStr[i];
@@ -115,7 +115,9 @@ const TargetPhraseCollection *PhraseDictionaryMultiModel::GetTargetPhraseCollect
115
115
RemoveAllInMap (*allStats);
116
116
delete allStats;
117
117
} else if (m_mode == " all" ) {
118
- ret = CreateTargetPhraseCollectionAll (src);
118
+ ret = CreateTargetPhraseCollectionAll (src, false );
119
+ } else if (m_mode == " all-restrict" ) {
120
+ ret = CreateTargetPhraseCollectionAll (src, true );
119
121
}
120
122
121
123
ret->NthElement (m_tableLimit); // sort the phrases for pruning later
@@ -204,7 +206,7 @@ TargetPhraseCollection* PhraseDictionaryMultiModel::CreateTargetPhraseCollection
204
206
return ret;
205
207
}
206
208
207
- TargetPhraseCollection* PhraseDictionaryMultiModel::CreateTargetPhraseCollectionAll (const Phrase& src) const
209
+ TargetPhraseCollection* PhraseDictionaryMultiModel::CreateTargetPhraseCollectionAll (const Phrase& src, const bool restricted ) const
208
210
{
209
211
// Collect phrases from all models
210
212
std::map<std::string, multiModelPhrase*> allPhrases;
@@ -227,7 +229,12 @@ TargetPhraseCollection* PhraseDictionaryMultiModel::CreateTargetPhraseCollection
227
229
std::vector<float > raw_scores = targetPhrase->GetScoreBreakdown ().GetScoresForProducer (&pd);
228
230
229
231
std::string targetString = targetPhrase->GetStringRep (m_output);
232
+ // Phrase not in collection -> add if unrestricted (all) or first model (all-restrict)
230
233
if (allPhrases.find (targetString) == allPhrases.end ()) {
234
+ // all-restrict and not first model: skip adding unseen phrase
235
+ if (restricted && i > 0 ) {
236
+ continue ;
237
+ }
231
238
232
239
multiModelPhrase* phrase = new multiModelPhrase;
233
240
phrase->targetPhrase = new TargetPhrase (*targetPhrase); // make a copy so that we don't overwrite the original phrase table info
0 commit comments