⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vocab.h

📁 解码器是基于短语的统计机器翻译系统的核心模块
💻 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 + -