mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
replace const string& filePath with const char * const
This commit is contained in:
parent
a20aa21f70
commit
2e85c1c833
@ -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))
|
||||
{
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
|
10
src/Trie.cpp
10
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<string> vecBuf;
|
||||
while(getline(ifile, line))
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user