dict.cpp
来自「Chinese segmentation in C」· C++ 代码 · 共 40 行
CPP
40 行
// 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 + =
减小字号Ctrl + -
显示快捷键?