mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-05 02:22:21 +03:00
Introduce parameter --distinct-nbest
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/branches/mira-mtm5@3740 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
parent
e7d3ddb358
commit
360c03b3bf
@ -90,7 +90,8 @@ namespace Mira {
|
||||
float bleuScoreWeight,
|
||||
vector< ScoreComponentCollection>& featureValues,
|
||||
vector< float>& bleuScores,
|
||||
bool oracle)
|
||||
bool oracle,
|
||||
bool distinct)
|
||||
{
|
||||
StaticData &staticData = StaticData::InstanceNonConst();
|
||||
|
||||
@ -113,11 +114,10 @@ namespace Mira {
|
||||
m_bleuScoreFeature->SetCurrentReference(sentenceid);
|
||||
|
||||
//run the decoder
|
||||
cerr << "Decoder: using weights:" << getWeights() << endl;
|
||||
m_manager = new Moses::Manager(*m_sentence, staticData.GetSearchAlgorithm(), &system);
|
||||
m_manager->ProcessSentence();
|
||||
TrellisPathList sentences;
|
||||
m_manager->CalcNBest(count,sentences);
|
||||
m_manager->CalcNBest(count,sentences, distinct);
|
||||
|
||||
// read off the feature values and bleu scores for each sentence in the nbest list
|
||||
Moses::TrellisPathList::const_iterator iter;
|
||||
|
@ -60,7 +60,8 @@ class MosesDecoder {
|
||||
float bleuScoreWeight, //weight of bleu in score
|
||||
std::vector< Moses::ScoreComponentCollection>& featureValues,
|
||||
std::vector< float>& scores,
|
||||
bool oracle);
|
||||
bool oracle,
|
||||
bool distinct);
|
||||
size_t getCurrentInputLength();
|
||||
void updateHistory(const std::vector<const Moses::Word*>& words);
|
||||
void updateHistory(const std::vector< std::vector< const Moses::Word*> >& words, std::vector<size_t>& sourceLengths, std::vector<size_t>& ref_ids);
|
||||
|
@ -85,6 +85,7 @@ int main(int argc, char** argv) {
|
||||
float marginScaleFactor;
|
||||
size_t n;
|
||||
size_t batchSize;
|
||||
bool distinctNbest;
|
||||
bool onlyViolatedConstraints;
|
||||
bool accumulateWeights;
|
||||
bool useScaledReference;
|
||||
@ -108,6 +109,7 @@ int main(int argc, char** argv) {
|
||||
("margin-scale-factor,m", po::value<float>(&marginScaleFactor)->default_value(1.0), "Margin scale factor, regularises the update by scaling the enforced margin")
|
||||
("nbest,n", po::value<size_t>(&n)->default_value(10), "Number of translations in nbest list")
|
||||
("batch-size,b", po::value<size_t>(&batchSize)->default_value(1), "Size of batch that is send to optimiser for weight adjustments")
|
||||
("distinct-nbest", po::value<bool>(&distinctNbest)->default_value(0), "Use nbest list with distinct translations in inference step")
|
||||
("only-violated-constraints", po::value<bool>(&onlyViolatedConstraints)->default_value(false), "Add only violated constraints to the optimisation problem")
|
||||
("accumulate-weights", po::value<bool>(&accumulateWeights)->default_value(false), "Accumulate and average weights over all epochs")
|
||||
("use-scaled-reference", po::value<bool>(&useScaledReference)->default_value(true), "Use scaled reference length for comparing target and reference length of phrases")
|
||||
@ -282,7 +284,8 @@ int main(int argc, char** argv) {
|
||||
1.0,
|
||||
featureValues[batchPosition],
|
||||
bleuScores[batchPosition],
|
||||
true);
|
||||
true,
|
||||
distinctNbest);
|
||||
inputLengths.push_back(decoder->getCurrentInputLength());
|
||||
ref_ids.push_back(*sid);
|
||||
decoder->cleanup();
|
||||
@ -303,7 +306,8 @@ int main(int argc, char** argv) {
|
||||
1.0,
|
||||
featureValues[batchPosition],
|
||||
bleuScores[batchPosition],
|
||||
true);
|
||||
true,
|
||||
distinctNbest);
|
||||
decoder->cleanup();
|
||||
oracles.push_back(oracle);
|
||||
for (size_t i = 0; i < oracle.size(); ++i) {
|
||||
@ -327,7 +331,8 @@ int main(int argc, char** argv) {
|
||||
1.0,
|
||||
featureValues[batchPosition],
|
||||
bleuScores[batchPosition],
|
||||
true);
|
||||
true,
|
||||
distinctNbest);
|
||||
decoder->cleanup();
|
||||
for (size_t i = 0; i < fear.size(); ++i) {
|
||||
cerr << *(fear[i]) << " ";
|
||||
|
Loading…
Reference in New Issue
Block a user