mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
add checkFileExists
This commit is contained in:
parent
47bc221662
commit
35b4676dd1
@ -174,7 +174,7 @@ using namespace CppJieba;
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
Segment segment;
|
Segment segment;
|
||||||
segment.init("jieba.dict.utf8");
|
segment.init("dicts/segdict.utf8.v2.0");
|
||||||
|
|
||||||
vector<string> res;
|
vector<string> res;
|
||||||
string title = "我来到北京清华大学";
|
string title = "我来到北京清华大学";
|
||||||
|
5
Trie.cpp
5
Trie.cpp
@ -24,6 +24,11 @@ namespace CppJieba
|
|||||||
|
|
||||||
bool Trie::init(const char* const filePath)
|
bool Trie::init(const char* const filePath)
|
||||||
{
|
{
|
||||||
|
if(!checkFileExist(filePath))
|
||||||
|
{
|
||||||
|
LogError(string_format("cann't find fiel[%s].",filePath));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
bool res = false;
|
bool res = false;
|
||||||
res = _buildTree(filePath);
|
res = _buildTree(filePath);
|
||||||
if(!res)
|
if(!res)
|
||||||
|
2
Trie.h
2
Trie.h
@ -1,5 +1,6 @@
|
|||||||
#ifndef TRIE_H
|
#ifndef TRIE_H
|
||||||
#define TRIE_H
|
#define TRIE_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
//#include <ext/hash_map>
|
//#include <ext/hash_map>
|
||||||
@ -10,6 +11,7 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
#include "cppcommon/str_functs.h"
|
#include "cppcommon/str_functs.h"
|
||||||
#include "cppcommon/vec_functs.h"
|
#include "cppcommon/vec_functs.h"
|
||||||
|
#include "cppcommon/file_functs.h"
|
||||||
#include "cppcommon/logger.h"
|
#include "cppcommon/logger.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user