diff --git a/src/KeyWordExt.cpp b/src/KeyWordExt.cpp index f3f92b5..55c7beb 100644 --- a/src/KeyWordExt.cpp +++ b/src/KeyWordExt.cpp @@ -21,17 +21,17 @@ namespace CppJieba return _segment.init(); } - bool KeyWordExt::loadSegDict(const string& filePath) + bool KeyWordExt::loadSegDict(const char * const filePath) { return _segment.loadSegDict(filePath); } - bool KeyWordExt::loadPriorSubWords(const string& filePath) + bool KeyWordExt::loadPriorSubWords(const char * const filePath) { - LogInfo(string_format("loadPriorSubWords(%s) start", filePath.c_str())); - if(!checkFileExist(filePath.c_str())) + LogInfo(string_format("loadPriorSubWords(%s) start", filePath)); + if(!checkFileExist(filePath)) { - LogError(string_format("cann't find file[%s].",filePath.c_str())); + LogError(string_format("cann't find file[%s].",filePath)); return false; } if(!_priorSubWords.empty()) @@ -39,33 +39,33 @@ namespace CppJieba LogError("_priorSubWords has been initted before"); return false; } - ifstream infile(filePath.c_str()); + ifstream infile(filePath); string subword; while(getline(infile, subword)) { _priorSubWords.push_back(subword); } - LogInfo(string_format("loadPriorSubWords(%s) end", filePath.c_str())); + LogInfo(string_format("loadPriorSubWords(%s) end", filePath)); infile.close(); return true; } - bool KeyWordExt::loadStopWords(const string& filePath) + bool KeyWordExt::loadStopWords(const char * const filePath) { - LogInfo(string_format("loadStopWords(%s) start", filePath.c_str())); + LogInfo(string_format("loadStopWords(%s) start", filePath)); if(!_stopWords.empty()) { LogError("_stopWords has been loaded before! "); return false; } - if(!checkFileExist(filePath.c_str())) + if(!checkFileExist(filePath)) { - LogError(string_format("cann't find file[%s].",filePath.c_str())); + LogError(string_format("cann't find file[%s].",filePath)); return false; } - ifstream ifile(filePath.c_str()); + ifstream ifile(filePath); string line; while(getline(ifile, line)) { diff --git a/src/KeyWordExt.h b/src/KeyWordExt.h index 2049f8b..f204211 100644 --- a/src/KeyWordExt.h +++ b/src/KeyWordExt.h @@ -50,13 +50,13 @@ namespace CppJieba ~KeyWordExt(); bool init(); - bool loadSegDict(const string& filePath); + bool loadSegDict(const char * const filePath); //load stopwords - bool loadStopWords(const string& filePath); + bool loadStopWords(const char * const filePath); //load prior words' prefix - bool loadPriorSubWords(const string& filePath); + bool loadPriorSubWords(const char * const filePath); bool dispose(); diff --git a/src/Segment.cpp b/src/Segment.cpp index edbdfb2..8254b39 100644 --- a/src/Segment.cpp +++ b/src/Segment.cpp @@ -25,9 +25,9 @@ namespace CppJieba return true; } - bool Segment::loadSegDict(const string& filePath) + bool Segment::loadSegDict(const char * const filePath) { - LogInfo(string_format("_trie.loadDict(%s) start...", filePath.c_str())); + LogInfo(string_format("_trie.loadDict(%s) start...", filePath)); bool retFlag = _trie.loadDict(filePath); LogInfo("_trie.loadDict end."); return retFlag; diff --git a/src/Segment.h b/src/Segment.h index a5374a2..1526411 100644 --- a/src/Segment.h +++ b/src/Segment.h @@ -21,7 +21,7 @@ namespace CppJieba ~Segment(); public: bool init(); - bool loadSegDict(const string& filePath); + bool loadSegDict(const char * const filePath); bool dispose(); double getWordWeight(const string& str); public: diff --git a/src/Trie.cpp b/src/Trie.cpp index 6880ea0..71251e5 100644 --- a/src/Trie.cpp +++ b/src/Trie.cpp @@ -63,7 +63,7 @@ namespace CppJieba return true; } - bool Trie::loadDict(const string& filePath) + bool Trie::loadDict(const char * const filePath) { if(!_getInitFlag()) { @@ -71,9 +71,9 @@ namespace CppJieba return false; } - if(!checkFileExist(filePath.c_str())) + if(!checkFileExist(filePath)) { - LogError(string_format("cann't find fiel[%s].",filePath.c_str())); + LogError(string_format("cann't find fiel[%s].",filePath)); return false; } bool res = false; @@ -92,10 +92,10 @@ namespace CppJieba return true; } - bool Trie::_buildTree(const string& filePath) + bool Trie::_buildTree(const char * const filePath) { - ifstream ifile(filePath.c_str()); + ifstream ifile(filePath); string line; vector vecBuf; while(getline(ifile, line)) diff --git a/src/Trie.h b/src/Trie.h index 39c5a40..39e3a91 100644 --- a/src/Trie.h +++ b/src/Trie.h @@ -77,7 +77,7 @@ namespace CppJieba Trie(); ~Trie(); bool init(); - bool loadDict(const string& filePath); + bool loadDict(const char * const filePath); bool dispose(); private: @@ -101,7 +101,7 @@ namespace CppJieba bool insert(const TrieNodeInfo& nodeInfo); private: - bool _buildTree(const string& filePath); + bool _buildTree(const char * const filePath); bool _countWeight(); bool _deleteNode(TrieNode* node);