mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
split Trie.hpp into (Trie.hpp & DictTrie.hpp) test ok
This commit is contained in:
parent
24120c92b1
commit
cae1503725
@ -36,7 +36,7 @@ namespace CppJieba
|
|||||||
{
|
{
|
||||||
string s;
|
string s;
|
||||||
s << unit.word;
|
s << unit.word;
|
||||||
return os << string_format("%s %u %s %llf", s.c_str(), unit.freq, unit.tag.c_str(), unit.logFreq);
|
return os << string_format("%s %u %s %.3lf", s.c_str(), unit.freq, unit.tag.c_str(), unit.logFreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef map<size_t, const DictUnit*> DagType;
|
typedef map<size_t, const DictUnit*> DagType;
|
||||||
|
@ -47,8 +47,8 @@ namespace CppJieba
|
|||||||
const TrieNodeType* ptNode = _root;
|
const TrieNodeType* ptNode = _root;
|
||||||
for(typename vector<KeyType>::const_iterator it = begin; it != end; it++)
|
for(typename vector<KeyType>::const_iterator it = begin; it != end; it++)
|
||||||
{
|
{
|
||||||
citer = ptNode->ptKeyMap->find(*it);
|
assert(ptNode);
|
||||||
if(ptNode->ptKeyMap->end() == citer)
|
if(NULL == ptNode->ptKeyMap || ptNode->ptKeyMap->end() == (citer = ptNode->ptKeyMap->find(*it)))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -63,8 +63,8 @@ namespace CppJieba
|
|||||||
ordererMap.clear();
|
ordererMap.clear();
|
||||||
for(typename vector<KeyType>::const_iterator itr = begin; itr != end ; itr++)
|
for(typename vector<KeyType>::const_iterator itr = begin; itr != end ; itr++)
|
||||||
{
|
{
|
||||||
citer = ptNode->ptKeyMap->find(*itr);
|
assert(ptNode);
|
||||||
if(ptNode->ptKeyMap->end() == citer)
|
if(NULL == ptNode->ptKeyMap || ptNode->ptKeyMap->end() == (citer = ptNode->ptKeyMap->find(*itr)))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ TEST(DictTrieTest, Test1)
|
|||||||
s1 << nodeInfo;
|
s1 << nodeInfo;
|
||||||
s2 << (*trie.find(uni.begin(), uni.end()));
|
s2 << (*trie.find(uni.begin(), uni.end()));
|
||||||
|
|
||||||
EXPECT_EQ("[\"26469\", \"21040\"]:8779:v:-8.87033", s2);
|
EXPECT_EQ("[\"26469\", \"21040\"] 8779 v -8.870", s2);
|
||||||
word = "清华大学";
|
word = "清华大学";
|
||||||
vector<pair<size_t, const DictUnit*> > res;
|
vector<pair<size_t, const DictUnit*> > res;
|
||||||
map<size_t, const DictUnit* > resMap;
|
map<size_t, const DictUnit* > resMap;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user