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();
|
return _segment.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyWordExt::loadSegDict(const string& filePath)
|
bool KeyWordExt::loadSegDict(const char * const filePath)
|
||||||
{
|
{
|
||||||
return _segment.loadSegDict(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()));
|
LogInfo(string_format("loadPriorSubWords(%s) start", filePath));
|
||||||
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;
|
return false;
|
||||||
}
|
}
|
||||||
if(!_priorSubWords.empty())
|
if(!_priorSubWords.empty())
|
||||||
@ -39,33 +39,33 @@ namespace CppJieba
|
|||||||
LogError("_priorSubWords has been initted before");
|
LogError("_priorSubWords has been initted before");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ifstream infile(filePath.c_str());
|
ifstream infile(filePath);
|
||||||
string subword;
|
string subword;
|
||||||
while(getline(infile, subword))
|
while(getline(infile, subword))
|
||||||
{
|
{
|
||||||
_priorSubWords.push_back(subword);
|
_priorSubWords.push_back(subword);
|
||||||
}
|
}
|
||||||
LogInfo(string_format("loadPriorSubWords(%s) end", filePath.c_str()));
|
LogInfo(string_format("loadPriorSubWords(%s) end", filePath));
|
||||||
infile.close();
|
infile.close();
|
||||||
return true;
|
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())
|
if(!_stopWords.empty())
|
||||||
{
|
{
|
||||||
LogError("_stopWords has been loaded before! ");
|
LogError("_stopWords has been loaded before! ");
|
||||||
return false;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifstream ifile(filePath.c_str());
|
ifstream ifile(filePath);
|
||||||
string line;
|
string line;
|
||||||
while(getline(ifile, line))
|
while(getline(ifile, line))
|
||||||
{
|
{
|
||||||
|
@ -50,13 +50,13 @@ namespace CppJieba
|
|||||||
~KeyWordExt();
|
~KeyWordExt();
|
||||||
bool init();
|
bool init();
|
||||||
|
|
||||||
bool loadSegDict(const string& filePath);
|
bool loadSegDict(const char * const filePath);
|
||||||
|
|
||||||
//load stopwords
|
//load stopwords
|
||||||
bool loadStopWords(const string& filePath);
|
bool loadStopWords(const char * const filePath);
|
||||||
|
|
||||||
//load prior words' prefix
|
//load prior words' prefix
|
||||||
bool loadPriorSubWords(const string& filePath);
|
bool loadPriorSubWords(const char * const filePath);
|
||||||
|
|
||||||
bool dispose();
|
bool dispose();
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@ namespace CppJieba
|
|||||||
return true;
|
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);
|
bool retFlag = _trie.loadDict(filePath);
|
||||||
LogInfo("_trie.loadDict end.");
|
LogInfo("_trie.loadDict end.");
|
||||||
return retFlag;
|
return retFlag;
|
||||||
|
@ -21,7 +21,7 @@ namespace CppJieba
|
|||||||
~Segment();
|
~Segment();
|
||||||
public:
|
public:
|
||||||
bool init();
|
bool init();
|
||||||
bool loadSegDict(const string& filePath);
|
bool loadSegDict(const char * const filePath);
|
||||||
bool dispose();
|
bool dispose();
|
||||||
double getWordWeight(const string& str);
|
double getWordWeight(const string& str);
|
||||||
public:
|
public:
|
||||||
|
10
src/Trie.cpp
10
src/Trie.cpp
@ -63,7 +63,7 @@ namespace CppJieba
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Trie::loadDict(const string& filePath)
|
bool Trie::loadDict(const char * const filePath)
|
||||||
{
|
{
|
||||||
if(!_getInitFlag())
|
if(!_getInitFlag())
|
||||||
{
|
{
|
||||||
@ -71,9 +71,9 @@ namespace CppJieba
|
|||||||
return false;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
bool res = false;
|
bool res = false;
|
||||||
@ -92,10 +92,10 @@ namespace CppJieba
|
|||||||
return true;
|
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;
|
string line;
|
||||||
vector<string> vecBuf;
|
vector<string> vecBuf;
|
||||||
while(getline(ifile, line))
|
while(getline(ifile, line))
|
||||||
|
@ -77,7 +77,7 @@ namespace CppJieba
|
|||||||
Trie();
|
Trie();
|
||||||
~Trie();
|
~Trie();
|
||||||
bool init();
|
bool init();
|
||||||
bool loadDict(const string& filePath);
|
bool loadDict(const char * const filePath);
|
||||||
bool dispose();
|
bool dispose();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -101,7 +101,7 @@ namespace CppJieba
|
|||||||
bool insert(const TrieNodeInfo& nodeInfo);
|
bool insert(const TrieNodeInfo& nodeInfo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _buildTree(const string& filePath);
|
bool _buildTree(const char * const filePath);
|
||||||
bool _countWeight();
|
bool _countWeight();
|
||||||
bool _deleteNode(TrieNode* node);
|
bool _deleteNode(TrieNode* node);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user