mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-10-26 11:28:48 +03:00
get ready to delete source phrase from TargetPhrase class
This commit is contained in:
parent
441acf15e6
commit
b3a860fd4f
@ -313,7 +313,7 @@ public:
|
||||
std::vector<std::pair<float,size_t> >& costs,
|
||||
const std::vector<Phrase> &sourcePhrases) const {
|
||||
// convert into TargetPhraseCollection
|
||||
CHECK(tCands.size() == sourcePhrases.size());
|
||||
CHECK(tCands.size() == sourcePhrases.size());
|
||||
|
||||
TargetPhraseCollectionWithSourcePhrase *rv=new TargetPhraseCollectionWithSourcePhrase;
|
||||
|
||||
@ -330,7 +330,10 @@ public:
|
||||
// add n top phrases to the return list
|
||||
for(std::vector<std::pair<float,size_t> >::iterator
|
||||
it = costs.begin(); it != nth; ++it) {
|
||||
rv->Add(new TargetPhrase(tCands[it->second]));
|
||||
size_t ind = it->second;
|
||||
TargetPhrase *targetPhrase = new TargetPhrase(tCands[ind]);
|
||||
const Phrase &sourcePhrase = sourcePhrases[ind];
|
||||
rv->Add(targetPhrase, sourcePhrase);
|
||||
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include <algorithm>
|
||||
#include "TargetPhraseCollection.h"
|
||||
#include "util/exception.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -84,6 +85,18 @@ std::ostream& operator<<(std::ostream &out, const TargetPhraseCollection &obj)
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
void TargetPhraseCollectionWithSourcePhrase::Add(TargetPhrase *targetPhrase)
|
||||
{
|
||||
UTIL_THROW(util::Exception, "Must use method Add(TargetPhrase*, const Phrase&)");
|
||||
}
|
||||
|
||||
void TargetPhraseCollectionWithSourcePhrase::Add(TargetPhrase *targetPhrase, const Phrase &sourcePhrase)
|
||||
{
|
||||
m_collection.push_back(targetPhrase);
|
||||
m_sourcePhrases.push_back(sourcePhrase);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
@ -109,6 +109,8 @@ public:
|
||||
return m_sourcePhrases;
|
||||
}
|
||||
|
||||
void Add(TargetPhrase *targetPhrase);
|
||||
void Add(TargetPhrase *targetPhrase, const Phrase &sourcePhrase);
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user