mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
use assert for getinitflag
This commit is contained in:
parent
acb4150e3c
commit
1e29d25855
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <cassert>
|
||||||
#include "Limonp/logger.hpp"
|
#include "Limonp/logger.hpp"
|
||||||
#include "Trie.hpp"
|
#include "Trie.hpp"
|
||||||
#include "ISegment.hpp"
|
#include "ISegment.hpp"
|
||||||
@ -63,15 +64,16 @@ namespace CppJieba
|
|||||||
public:
|
public:
|
||||||
bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<Unicode>& res) const
|
bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<Unicode>& res) const
|
||||||
{
|
{
|
||||||
|
assert(_getInitFlag());
|
||||||
#ifndef NO_CODING_LOG
|
#ifndef NO_CODING_LOG
|
||||||
if (!_getInitFlag())
|
//if (!_getInitFlag())
|
||||||
|
//{
|
||||||
|
// LogError("not inited.");
|
||||||
|
// return false;
|
||||||
|
//}
|
||||||
|
if (begin >= end)
|
||||||
{
|
{
|
||||||
LogError("not inited.");
|
LogError("begin >= end");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (begin > end)
|
|
||||||
{
|
|
||||||
LogError("begin > end");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
#include <cassert>
|
||||||
#include "Limonp/str_functs.hpp"
|
#include "Limonp/str_functs.hpp"
|
||||||
#include "Limonp/logger.hpp"
|
#include "Limonp/logger.hpp"
|
||||||
#include "TransCode.hpp"
|
#include "TransCode.hpp"
|
||||||
@ -93,11 +94,12 @@ namespace CppJieba
|
|||||||
public:
|
public:
|
||||||
virtual bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<string>& res)const
|
virtual bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<string>& res)const
|
||||||
{
|
{
|
||||||
if(!_getInitFlag())
|
//if(!_getInitFlag())
|
||||||
{
|
//{
|
||||||
LogError("not inited.");
|
// LogError("not inited.");
|
||||||
return false;
|
// return false;
|
||||||
}
|
//}
|
||||||
|
assert(_getInitFlag());
|
||||||
if(begin == end)
|
if(begin == end)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <cassert>
|
||||||
#include "Limonp/logger.hpp"
|
#include "Limonp/logger.hpp"
|
||||||
#include "Trie.hpp"
|
#include "Trie.hpp"
|
||||||
#include "ISegment.hpp"
|
#include "ISegment.hpp"
|
||||||
@ -73,11 +74,13 @@ namespace CppJieba
|
|||||||
public:
|
public:
|
||||||
virtual bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<string>& res)const
|
virtual bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<string>& res)const
|
||||||
{
|
{
|
||||||
if(!_getInitFlag())
|
//if(!_getInitFlag())
|
||||||
{
|
//{
|
||||||
LogError("not inited.");
|
// LogError("not inited.");
|
||||||
return false;
|
// return false;
|
||||||
}
|
//}
|
||||||
|
assert(_getInitFlag());
|
||||||
|
|
||||||
vector<TrieNodeInfo> segWordInfos;
|
vector<TrieNodeInfo> segWordInfos;
|
||||||
if(!cut(begin, end, segWordInfos))
|
if(!cut(begin, end, segWordInfos))
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef CPPJIEBA_MIXSEGMENT_H
|
#ifndef CPPJIEBA_MIXSEGMENT_H
|
||||||
#define CPPJIEBA_MIXSEGMENT_H
|
#define CPPJIEBA_MIXSEGMENT_H
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include "MPSegment.hpp"
|
#include "MPSegment.hpp"
|
||||||
#include "HMMSegment.hpp"
|
#include "HMMSegment.hpp"
|
||||||
#include "Limonp/str_functs.hpp"
|
#include "Limonp/str_functs.hpp"
|
||||||
@ -56,11 +57,12 @@ namespace CppJieba
|
|||||||
public:
|
public:
|
||||||
virtual bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<string>& res)const
|
virtual bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<string>& res)const
|
||||||
{
|
{
|
||||||
if(!_getInitFlag())
|
//if(!_getInitFlag())
|
||||||
{
|
//{
|
||||||
LogError("not inited.");
|
// LogError("not inited.");
|
||||||
return false;
|
// return false;
|
||||||
}
|
//}
|
||||||
|
assert(_getInitFlag());
|
||||||
if(begin == end)
|
if(begin == end)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <cassert>
|
||||||
#include "Limonp/logger.hpp"
|
#include "Limonp/logger.hpp"
|
||||||
#include "Trie.hpp"
|
#include "Trie.hpp"
|
||||||
#include "ISegment.hpp"
|
#include "ISegment.hpp"
|
||||||
@ -64,15 +65,16 @@ namespace CppJieba
|
|||||||
public:
|
public:
|
||||||
bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<Unicode>& res) const
|
bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<Unicode>& res) const
|
||||||
{
|
{
|
||||||
|
assert(_getInitFlag());
|
||||||
#ifndef NO_CODING_LOG
|
#ifndef NO_CODING_LOG
|
||||||
if (!_getInitFlag())
|
//if (!_getInitFlag())
|
||||||
|
//{
|
||||||
|
// LogError("not inited.");
|
||||||
|
// return false;
|
||||||
|
//}
|
||||||
|
if (begin >= end)
|
||||||
{
|
{
|
||||||
LogError("not inited.");
|
LogError("begin >= end");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (begin > end)
|
|
||||||
{
|
|
||||||
LogError("begin > end");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user