diff --git a/Segment.cpp b/Segment.cpp index 41710cb..e5654e1 100644 --- a/Segment.cpp +++ b/Segment.cpp @@ -174,7 +174,7 @@ using namespace CppJieba; int main() { Segment segment; - segment.init("jieba.dict.utf8"); + segment.init("dicts/segdict.utf8.v2.0"); vector res; string title = "我来到北京清华大学"; diff --git a/Trie.cpp b/Trie.cpp index c16651a..269a2e8 100644 --- a/Trie.cpp +++ b/Trie.cpp @@ -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) diff --git a/Trie.h b/Trie.h index 0cb7b78..904131c 100644 --- a/Trie.h +++ b/Trie.h @@ -1,5 +1,6 @@ #ifndef TRIE_H #define TRIE_H + #include #include //#include @@ -10,6 +11,7 @@ #include #include "cppcommon/str_functs.h" #include "cppcommon/vec_functs.h" +#include "cppcommon/file_functs.h" #include "cppcommon/logger.h" #include "globals.h"