?? hypothesis.h
字號:
#ifndef HYPOTHESIS_H
#define HYPOTHESIS_H
#include <vector>
#include <strstream>
#include <ctime>
#include <list>
#include <deque>
#include "LanguageModel.h"
#include "TransOptions.h"
#include "HypothesisElement.h"
#include "ConfigINI.h"
#include "Vocab.h"
typedef vector<HypothesisElement> VECPOOL;
typedef deque<int> VECUNSED;
extern VECPOOL vecHypo;
extern VECUNSED vecNotUsed;
using namespace std;
class Greaters
{
public:
bool operator()(HypothesisElement *hyp1, HypothesisElement *hyp2)
{
double dTmp = hyp1->totalScore - hyp2->totalScore;
return (dTmp >= avs);
}
};
class Less
{
public:
bool operator()(int hyp1, int hyp2)
{
double dTmp = vecHypo[hyp1].totalScore - vecHypo[hyp2].totalScore;
return (dTmp <= avs);
}
};
//typedef multiset<HypothesisElement *, Greaters> multisetHYE;
//typedef vector<multisetHYE> HypothesisStack;
//typedef vector<HypothesisElement *> vecHYE;
//typedef vector<vecHYE> HypothesisStack;
class Arc
{
public:
int from;
int to;
double diffCost;
vector<int> tosPhrase;
};
typedef vector<Arc> ARC;
typedef vector<int> multisetHYE;
typedef vector<multisetHYE> HypothesisStack; //存放假設的在pool中的位置號(注意:不是假設的ID),
class Hypothesis
{
public:
Hypothesis(double thresholdI, int stackThrehold, int nBest, double dislimit, double lmlimit, int len);
bool load(string inifileName);//加載ini,lm,to
void initialize(string sentence);//根據輸入的句子,初始化stack大小
void clear();//釋放hypothesisStack
string decoder(string fileName);
~Hypothesis();
private:
void split(const string& line, vector<string>& strs);
double fcCal(set<int> phraseID, int stackSize);
double lmCal(int last1, int last2, vector<int> newPhrase, int& newlast1, int& newlast2);
void recombineAndbeam(int newHyp);
void eraseMultiSet(multisetHYE& multisethye, int limit);
void cutStack(multisetHYE& multisethye, int limit, int stackNO);
void CutStack(multisetHYE& multisethye, int limit, int stackNO);
void dealout(string& str);
void findNBest(string outputFile);
string findBest();
int findProper(VECUNSED& vecnused);
ConfigINI config;
Para para;
LanguageModel *lm;//LM
TransOptions *to;//Translation Option
Vocab *enVcb;
Vocab *cnVcb;
HypothesisStack hypothesisStack;
ARC arc;
PhraseSnippet phraseSnippet;
PhraseSnippetPosition phraseSnippetPosition;
int stackSize;//實際是nf,即stack的個數
int eachStackSize; //每個stack的最大容量 默認:100
double threshold;//beam-threshold在在假設入stack的閥值 0.00001
vector<double> THRESHOLD;
int NBEST; //輸出n-best
double DISTORTIONLIMIT;
double LMLimit;
int DISLENGHT;
// map<int, string> unkTMP;
vector<int> sentenceIDS;
};
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -