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

📄 dict.cpp

📁 Chinese segmentation in C
💻 CPP
字号:
// Dict handling

#include "Dict.h"

CDict::CDict()
{
	OpenDict();
}

CDict::~CDict()
{
	mapDict.clear();
}

void CDict::OpenDict()
{
	FILE *fpDict;
	if ((fpDict = fopen(DICTFILENAME.c_str(), "r")) == NULL) {
		cout << "Can not open the Dictionary file!";
		exit(1);
	}
  
	int id, freq;
	char word[16];
	while (fscanf(fpDict, "%d %s %d", &id, word, &freq) != EOF) {
		//fscanf(fpDict, "%d %s %d", &id, word, &freq);
		mapDict.insert(map<string,int>::value_type (word, 0));
	}
  
	fclose(fpDict);
  
}

bool CDict::IsWord(string& str) const
{
	if (mapDict.find(str) != mapDict.end())
		return true;
	return false;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -