?? vocab.h
字號:
#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 + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -