add some log debug & info

This commit is contained in:
wyy 2013-12-21 21:47:01 -08:00
parent 1b801c28a1
commit 679179859e
4 changed files with 16 additions and 10 deletions

View File

@ -46,6 +46,7 @@ namespace CppJieba
{
if(_getInitFlag())
{
LogError("inited already.");
return false;
}
memset(_startProb, 0, sizeof(_startProb));
@ -58,7 +59,13 @@ namespace CppJieba
_emitProbVec.push_back(&_emitProbE);
_emitProbVec.push_back(&_emitProbM);
_emitProbVec.push_back(&_emitProbS);
return _setInitFlag(_loadModel(filePath.c_str()));
if(!_setInitFlag(_loadModel(filePath.c_str())))
{
LogError("_loadModel(%s) failed.", filePath.c_str());
return false;
}
LogInfo("HMMSegment init(%s) ok.", filePath.c_str());
return true;
}
public:
using SegmentBase::cut;
@ -198,7 +205,7 @@ namespace CppJieba
}
bool _loadModel(const char* const filePath)
{
LogInfo("loadModel [%s] start ...", filePath);
LogDebug("loadModel [%s] start ...", filePath);
ifstream ifile(filePath);
string line;
vector<string> tmp;
@ -264,7 +271,7 @@ namespace CppJieba
return false;
}
LogInfo("loadModel [%s] end.", filePath);
LogDebug("loadModel [%s] end.", filePath);
return true;
}

View File

@ -56,6 +56,7 @@ namespace CppJieba
LogError("get a NULL pointor form getTrie(\"%s\").", dictPath.c_str());
return false;
}
LogInfo("MPSegment init(%s) ok", dictPath.c_str());
return _setInitFlag(true);
}
public:

View File

@ -15,9 +15,9 @@ namespace CppJieba
HMMSegment _hmmSeg;
public:
MixSegment(){_setInitFlag(false);};
explicit MixSegment(const string& mpSegDict, const string& hmmSegDict): _mpSeg(mpSegDict), _hmmSeg(hmmSegDict)
explicit MixSegment(const string& mpSegDict, const string& hmmSegDict)
{
_setInitFlag(_mpSeg && _hmmSeg);
_setInitFlag(init(mpSegDict, hmmSegDict));
}
virtual ~MixSegment(){}
public:
@ -38,6 +38,7 @@ namespace CppJieba
LogError("_hmmSeg init");
return false;
}
LogInfo("MixSegment init(%s, %s)", mpSegDict.c_str(), hmmSegDict.c_str());
return _setInitFlag(true);
}
public:

View File

@ -23,15 +23,13 @@ namespace CppJieba
LogError("error when getting md5 for file '%s'", dictpath);
return NULL;
}
LogInfo("md5 for file '%s': %s", dictpath, md5.c_str());
if (_tries.find(md5) != _tries.end())
{
LogInfo("find a exits trie for md5: '%s'", md5.c_str());
return _tries[md5.c_str()];
}
LogInfo("create a new trie for md5: '%s'", md5.c_str());
//LogDebug("create a new trie for md5: '%s'", md5.c_str());
Trie* trie = NULL;
try
{
@ -54,15 +52,14 @@ namespace CppJieba
return NULL;
}
LogInfo("trie->loadDict(%s) start...", dictpath);
if (!trie->loadDict(dictpath))
{
LogError("trie->loadDict(%s) failed...", dictpath);
return NULL;
}
LogInfo("trie->loadDict end...");
_tries[md5.c_str()] = trie;
LogDebug("trie->loadDict(%s)", dictpath);
return trie;
}