add checkFileExists

This commit is contained in:
gwdwyy 2013-07-10 18:43:38 +08:00
parent 47bc221662
commit 35b4676dd1
3 changed files with 8 additions and 1 deletions

View File

@ -174,7 +174,7 @@ using namespace CppJieba;
int main()
{
Segment segment;
segment.init("jieba.dict.utf8");
segment.init("dicts/segdict.utf8.v2.0");
vector<string> res;
string title = "我来到北京清华大学";

View File

@ -24,6 +24,11 @@ namespace CppJieba
bool Trie::init(const char* const filePath)
{
if(!checkFileExist(filePath))
{
LogError(string_format("cann't find fiel[%s].",filePath));
return false;
}
bool res = false;
res = _buildTree(filePath);
if(!res)

2
Trie.h
View File

@ -1,5 +1,6 @@
#ifndef TRIE_H
#define TRIE_H
#include <iostream>
#include <fstream>
//#include <ext/hash_map>
@ -10,6 +11,7 @@
#include <limits>
#include "cppcommon/str_functs.h"
#include "cppcommon/vec_functs.h"
#include "cppcommon/file_functs.h"
#include "cppcommon/logger.h"
#include "globals.h"