mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
ci MPSegment.hpp
This commit is contained in:
parent
687ebfc19b
commit
f254691e53
@ -59,18 +59,22 @@ namespace CppJieba
|
|||||||
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
|
||||||
{
|
{
|
||||||
assert(_getInitFlag());
|
assert(_getInitFlag());
|
||||||
|
if(begin == end)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
vector<TrieNodeInfo> segWordInfos;
|
vector<TrieNodeInfo> segWordInfos;
|
||||||
if(!cut(begin, end, segWordInfos))
|
if(!cut(begin, end, segWordInfos))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
string tmp;
|
string word;
|
||||||
for(size_t i = 0; i < segWordInfos.size(); i++)
|
for(size_t i = 0; i < segWordInfos.size(); i++)
|
||||||
{
|
{
|
||||||
if(TransCode::encode(segWordInfos[i].word, tmp))
|
if(TransCode::encode(segWordInfos[i].word, word))
|
||||||
{
|
{
|
||||||
res.push_back(tmp);
|
res.push_back(word);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -114,12 +118,6 @@ namespace CppJieba
|
|||||||
private:
|
private:
|
||||||
bool _calcDAG(Unicode::const_iterator begin, Unicode::const_iterator end, SegmentContext& segContext) const
|
bool _calcDAG(Unicode::const_iterator begin, Unicode::const_iterator end, SegmentContext& segContext) const
|
||||||
{
|
{
|
||||||
if(begin >= end)
|
|
||||||
{
|
|
||||||
LogError("begin >= end.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Unicode::const_iterator it = begin; it != end; it++)
|
for(Unicode::const_iterator it = begin; it != end; it++)
|
||||||
{
|
{
|
||||||
SegmentChar schar(*it);
|
SegmentChar schar(*it);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user