2010-09-15 18:36:07 +04:00
|
|
|
/***********************************************************************
|
|
|
|
Moses - factored phrase-based language decoder
|
2010-09-15 19:38:46 +04:00
|
|
|
Copyright (C) 2010 University of Edinburgh
|
2010-09-15 18:36:07 +04:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
***********************************************************************/
|
2010-09-15 19:38:46 +04:00
|
|
|
#ifndef _MIRA_DECODER_H_
|
|
|
|
#define _MIRA_DECODER_H_
|
2010-09-15 18:36:07 +04:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <cstring>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
|
2010-09-17 14:17:27 +04:00
|
|
|
#include "BleuScoreFeature.h"
|
|
|
|
#include "ChartTrellisPathList.h"
|
2010-09-15 18:36:07 +04:00
|
|
|
#include "Hypothesis.h"
|
|
|
|
#include "Parameter.h"
|
|
|
|
#include "SearchNormal.h"
|
2010-09-17 14:17:27 +04:00
|
|
|
#include "Sentence.h"
|
2010-09-15 18:36:07 +04:00
|
|
|
#include "StaticData.h"
|
|
|
|
|
|
|
|
//
|
|
|
|
// Wrapper functions and objects for the decoder.
|
|
|
|
//
|
|
|
|
|
|
|
|
namespace Mira {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialise moses (including StaticData) using the given ini file and debuglevel, passing through any
|
2010-09-17 14:17:27 +04:00
|
|
|
* other command line arguments.
|
2010-09-15 18:36:07 +04:00
|
|
|
**/
|
|
|
|
void initMoses(const std::string& inifile, int debuglevel, int argc=0, char** argv=NULL );
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wraps moses decoder.
|
|
|
|
**/
|
2010-09-17 14:17:27 +04:00
|
|
|
class MosesDecoder {
|
2010-09-15 18:36:07 +04:00
|
|
|
public:
|
2010-09-17 12:33:22 +04:00
|
|
|
MosesDecoder();
|
2010-09-16 20:23:52 +04:00
|
|
|
|
2010-09-17 16:54:58 +04:00
|
|
|
void getNBest(const std::string& source,
|
2010-09-17 14:17:27 +04:00
|
|
|
size_t count,
|
2010-09-17 18:32:27 +04:00
|
|
|
float bleuObjectiveweight, //weight of bleu in objective
|
|
|
|
float bleuScoreWeight, //weight of bleu in score
|
|
|
|
std::vector<Moses::ScoreComponentCollection>& featureValues,
|
|
|
|
std::vector<float>& scores );
|
2010-09-17 16:54:58 +04:00
|
|
|
Moses::ScoreComponentCollection getWeights();
|
|
|
|
void setWeights(const Moses::ScoreComponentCollection& weights);
|
|
|
|
void cleanup();
|
2010-09-16 20:23:52 +04:00
|
|
|
|
|
|
|
private:
|
2010-09-17 18:32:27 +04:00
|
|
|
float getBleuScore(const Moses::ScoreComponentCollection& scores);
|
|
|
|
void setBleuScore(Moses::ScoreComponentCollection& scores, float bleu);
|
2010-09-17 14:17:27 +04:00
|
|
|
Moses::Manager *m_manager;
|
2010-09-16 20:23:52 +04:00
|
|
|
Moses::Sentence *m_sentence;
|
2010-09-17 14:17:27 +04:00
|
|
|
Moses::BleuScoreFeature *m_bleuScoreFeature;
|
2010-09-16 20:23:52 +04:00
|
|
|
|
|
|
|
|
2010-09-15 18:36:07 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} //namespace
|
|
|
|
|
2010-09-15 19:38:46 +04:00
|
|
|
#endif
|