mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
rename Trie -> DictTrie
This commit is contained in:
parent
f70b654b66
commit
abd23a4d79
@ -12,7 +12,7 @@
|
|||||||
#include "Limonp/logger.hpp"
|
#include "Limonp/logger.hpp"
|
||||||
#include "Limonp/InitOnOff.hpp"
|
#include "Limonp/InitOnOff.hpp"
|
||||||
#include "TransCode.hpp"
|
#include "TransCode.hpp"
|
||||||
#include "Trie.hpp"
|
#include "DictTrie.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "Limonp/logger.hpp"
|
#include "Limonp/logger.hpp"
|
||||||
#include "Trie.hpp"
|
#include "DictTrie.hpp"
|
||||||
#include "ISegment.hpp"
|
#include "ISegment.hpp"
|
||||||
#include "SegmentBase.hpp"
|
#include "SegmentBase.hpp"
|
||||||
#include "TransCode.hpp"
|
#include "TransCode.hpp"
|
||||||
@ -15,7 +15,7 @@ namespace CppJieba
|
|||||||
class FullSegment: public SegmentBase
|
class FullSegment: public SegmentBase
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Trie _trie;
|
DictTrie _dictTrie;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FullSegment(){_setInitFlag(false);};
|
FullSegment(){_setInitFlag(false);};
|
||||||
@ -29,8 +29,8 @@ namespace CppJieba
|
|||||||
LogError("already inited before now.");
|
LogError("already inited before now.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_trie.init(dictPath.c_str());
|
_dictTrie.init(dictPath.c_str());
|
||||||
assert(_trie);
|
assert(_dictTrie);
|
||||||
return _setInitFlag(true);
|
return _setInitFlag(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ namespace CppJieba
|
|||||||
for (Unicode::const_iterator uItr = begin; uItr != end; uItr++)
|
for (Unicode::const_iterator uItr = begin; uItr != end; uItr++)
|
||||||
{
|
{
|
||||||
//find word start from uItr
|
//find word start from uItr
|
||||||
if (_trie.find(uItr, end, tRes, 0))
|
if (_dictTrie.find(uItr, end, tRes, 0))
|
||||||
{
|
{
|
||||||
for(DagType::const_iterator itr = tRes.begin(); itr != tRes.end(); itr++)
|
for(DagType::const_iterator itr = tRes.begin(); itr != tRes.end(); itr++)
|
||||||
//for (vector<pair<size_t, const TrieNodeInfo*> >::const_iterator itr = tRes.begin(); itr != tRes.end(); itr++)
|
//for (vector<pair<size_t, const TrieNodeInfo*> >::const_iterator itr = tRes.begin(); itr != tRes.end(); itr++)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "TransCode.hpp"
|
#include "TransCode.hpp"
|
||||||
#include "ISegment.hpp"
|
#include "ISegment.hpp"
|
||||||
#include "SegmentBase.hpp"
|
#include "SegmentBase.hpp"
|
||||||
#include "Trie.hpp"
|
#include "DictTrie.hpp"
|
||||||
|
|
||||||
namespace CppJieba
|
namespace CppJieba
|
||||||
{
|
{
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "Limonp/logger.hpp"
|
#include "Limonp/logger.hpp"
|
||||||
#include "Trie.hpp"
|
#include "DictTrie.hpp"
|
||||||
#include "Trie.hpp"
|
#include "DictTrie.hpp"
|
||||||
#include "ISegment.hpp"
|
#include "ISegment.hpp"
|
||||||
#include "SegmentBase.hpp"
|
#include "SegmentBase.hpp"
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ namespace CppJieba
|
|||||||
class MPSegment: public SegmentBase
|
class MPSegment: public SegmentBase
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Trie _trie;
|
DictTrie _dictTrie;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MPSegment(){_setInitFlag(false);};
|
MPSegment(){_setInitFlag(false);};
|
||||||
@ -49,8 +49,8 @@ namespace CppJieba
|
|||||||
LogError("already inited before now.");
|
LogError("already inited before now.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_trie.init(dictPath);
|
_dictTrie.init(dictPath);
|
||||||
assert(_trie);
|
assert(_dictTrie);
|
||||||
LogInfo("MPSegment init(%s) ok", dictPath.c_str());
|
LogInfo("MPSegment init(%s) ok", dictPath.c_str());
|
||||||
return _setInitFlag(true);
|
return _setInitFlag(true);
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ namespace CppJieba
|
|||||||
schar.uniCh = *it;
|
schar.uniCh = *it;
|
||||||
offset = it - begin;
|
offset = it - begin;
|
||||||
schar.dag.clear();
|
schar.dag.clear();
|
||||||
_trie.find(it, end, schar.dag, offset);
|
_dictTrie.find(it, end, schar.dag, offset);
|
||||||
if(!isIn(schar.dag, offset))
|
if(!isIn(schar.dag, offset))
|
||||||
{
|
{
|
||||||
schar.dag[offset] = NULL;
|
schar.dag[offset] = NULL;
|
||||||
@ -165,7 +165,7 @@ namespace CppJieba
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
val += _trie.getMinLogFreq();
|
val += _dictTrie.getMinLogFreq();
|
||||||
}
|
}
|
||||||
if(val > segContext[i].weight)
|
if(val > segContext[i].weight)
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "MixSegment.hpp"
|
#include "MixSegment.hpp"
|
||||||
#include "Limonp/str_functs.hpp"
|
#include "Limonp/str_functs.hpp"
|
||||||
#include "Trie.hpp"
|
#include "DictTrie.hpp"
|
||||||
|
|
||||||
namespace CppJieba
|
namespace CppJieba
|
||||||
{
|
{
|
||||||
@ -13,7 +13,7 @@ namespace CppJieba
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
MixSegment _segment;
|
MixSegment _segment;
|
||||||
Trie _trie;
|
DictTrie _dictTrie;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PosTagger(){_setInitFlag(false);};
|
PosTagger(){_setInitFlag(false);};
|
||||||
@ -27,8 +27,8 @@ namespace CppJieba
|
|||||||
{
|
{
|
||||||
|
|
||||||
assert(!_getInitFlag());
|
assert(!_getInitFlag());
|
||||||
_trie.init(dictPath);
|
_dictTrie.init(dictPath);
|
||||||
assert(_trie);
|
assert(_dictTrie);
|
||||||
return _setInitFlag(_segment.init(dictPath, hmmFilePath));
|
return _setInitFlag(_segment.init(dictPath, hmmFilePath));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ namespace CppJieba
|
|||||||
LogError("decode failed.");
|
LogError("decode failed.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
tmp = _trie.find(unico.begin(), unico.end());
|
tmp = _dictTrie.find(unico.begin(), unico.end());
|
||||||
res.push_back(make_pair(*itr, tmp == NULL ? "x" : tmp->tag));
|
res.push_back(make_pair(*itr, tmp == NULL ? "x" : tmp->tag));
|
||||||
}
|
}
|
||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "Limonp/logger.hpp"
|
#include "Limonp/logger.hpp"
|
||||||
#include "Trie.hpp"
|
#include "DictTrie.hpp"
|
||||||
#include "ISegment.hpp"
|
#include "ISegment.hpp"
|
||||||
#include "SegmentBase.hpp"
|
#include "SegmentBase.hpp"
|
||||||
#include "FullSegment.hpp"
|
#include "FullSegment.hpp"
|
||||||
#include "MixSegment.hpp"
|
#include "MixSegment.hpp"
|
||||||
#include "TransCode.hpp"
|
#include "TransCode.hpp"
|
||||||
#include "Trie.hpp"
|
#include "DictTrie.hpp"
|
||||||
|
|
||||||
namespace CppJieba
|
namespace CppJieba
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user