vocab.h
来自「解码器是基于短语的统计机器翻译系统的核心模块」· C头文件 代码 · 共 51 行
H
51 行
#ifndef VOCAB_H
#define VOCAB_H
#include <map>
#include <string>
#include <iostream>
#include <strstream>
#include <vector>
#include <fstream>
#include <deque>
using namespace std;
typedef vector<string> IndexWord;
typedef map<string, int> WordIndex;
class Vocab
{
public:
Vocab();
int getIndex(string word);
string getWord(int index);
int getIndices(string words, vector<int>& indices);
string getWords(vector<int> indicesk);
int senToIDs(string sen, vector<int>& senids);
string IDsTosen(deque<int> senids);
bool load(string vcb);
void mapClear();
void split(const string& line, vector<string>& strs)
{
istrstream ist(line.c_str());
string w;
while(ist>>w) strs.push_back(w);
}
map<int, string> unkTMP;//存放未登录词
static int ID;
private:
IndexWord indexWord;
WordIndex wordIndex;
ifstream vcbFileName;
// int MaxIndex; //
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?