📄 decoder.h
字号:
/** Decoder.h - Decoder class declaration** Copyright (C) 2006 by Zhongjun He <zjhe@ict.ac.cn> Yajuan Lv <lvyajuan@ict.ac.cn>Multilingual Interaction Technology and Evaluation Laboratory, ICT, CAS* Begin : 04/13/2006* Last Change : 04/13/2006** This program 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 program 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 General Public License for more details.** You should have received a copy of the GNU Lesser General Public* License along with this program; if not, write to the Free Software* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/#ifndef DECODER_H#define DECODER_H#ifndef _WIN32
#include <unistd.h>
#endif#include <fstream>#include "Candidate.h"#include "Hypotheses.h"#include "LanguageModel.h"#include "SentPair.h"#include "TTable.h"using namespace std;class Decoder{
public:
Decoder();
~Decoder();
//Read configure
void ReadConfigure(const char *conf);
//Set argument
void SetArg(int bplimit, int dis, int stack, int nbestlist, int print_nbest, int print_info,
const string &tf, const string &rf, const string &nf);
//Initialize
void Initialize();
// Translate a sentence
vector<CandTrans> TranslateSent(const string &chinese);
//Translate file
void TranslateFile();
//Read Chinese sentences from file
void ReadChinese(const char *filename, vector<string> &sents);
//Change Format
void ChangeFormatTo863(const char *srcfile, const char *tempfile, const char *resultfile);
string testfile, resultfile, nbestfile;
int BP_TABLE_LIMIT;
int MAX_DISTORTION;
int HP_STACK_SIZE;
int NBEST_LIST;
bool IS_PRINT_NBEST;//if print n best or not ;
bool INFO;//INFO=1 show the search information in logfile;
private:
//search possible translations for a Chinese phrase
void SearchPhrase(const vector<string> &phrase, TransMap &transoption);
//Compute the Future Cost
void ComputeFutureCost(int WordLen, const map<pair<int,int>, TransMap> &TransOption,
map<pair<int,int> ,double> &FutureCost);
//Beam Search
void BeamSearch(int WordLen, const map<pair<int,int>,TransMap> &TransOption,
vector<vector<Hypotheses> > &HpStack, map<pair<int,int>,double> &FutureCost);
//Generate Nbest-list
void GenerateNbest(vector<vector<Hypotheses> > &HpStack, vector<CandTrans> &CandNbest);
void Generate1best(vector<vector<Hypotheses> > &HpStack, vector<CandTrans> &CandNbest);
//Push a hypothesis to HpStack
bool AddToStack(vector<Hypotheses> &HpStack, Hypotheses &hp);
//get distortion distance
int GetDistortionDistance(const vector<int> CoveredWord, const pair<int,int> LastPhraseBeginEnd,
const pair<int,int> BeginEnd);
//Change the first letter to its upper case
void TrueCase(string &s);
vector<double> lambda;//feature function weight
TTable bptable;//bilingual phrase translation table
string bpfile;//bilingual phrase file
LanguageModel lm;//language model
string lmfile;//language model file
int lmngram;//n-gram of Language Model,default is 3-gram
ofstream logs;//logfile
};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -