split Trie.hpp into (Trie.hpp & DictTrie.hpp) test ok

This commit is contained in:
wyy 2014-04-11 12:08:46 +08:00
parent 24120c92b1
commit cae1503725
3 changed files with 6 additions and 6 deletions

View File

@ -36,7 +36,7 @@ namespace CppJieba
{
string s;
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;

View File

@ -47,8 +47,8 @@ namespace CppJieba
const TrieNodeType* ptNode = _root;
for(typename vector<KeyType>::const_iterator it = begin; it != end; it++)
{
citer = ptNode->ptKeyMap->find(*it);
if(ptNode->ptKeyMap->end() == citer)
assert(ptNode);
if(NULL == ptNode->ptKeyMap || ptNode->ptKeyMap->end() == (citer = ptNode->ptKeyMap->find(*it)))
{
return NULL;
}
@ -63,8 +63,8 @@ namespace CppJieba
ordererMap.clear();
for(typename vector<KeyType>::const_iterator itr = begin; itr != end ; itr++)
{
citer = ptNode->ptKeyMap->find(*itr);
if(ptNode->ptKeyMap->end() == citer)
assert(ptNode);
if(NULL == ptNode->ptKeyMap || ptNode->ptKeyMap->end() == (citer = ptNode->ptKeyMap->find(*itr)))
{
break;
}

View File

@ -32,7 +32,7 @@ TEST(DictTrieTest, Test1)
s1 << nodeInfo;
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 = "清华大学";
vector<pair<size_t, const DictUnit*> > res;
map<size_t, const DictUnit* > resMap;