31 #include <boost/tokenizer.hpp>
44 Family::Family(
int defaultThreshold)
45 : _thresh(defaultThreshold), _children()
49 const tokenizer::iterator& end)
56 ChildMap::iterator out =
_children->find(*toptoken);
63 if (++toptoken == end)
71 const tokenizer::iterator& end,
78 ChildMap::const_iterator found =
_children->find(*toptoken);
84 const Family *out = found->second;
85 if (++toptoken != end) out = out->
findDescendant(toptoken, end, orNearest);
93 const tokenizer::iterator& end)
98 _children->insert(ChildMap::value_type(*toptoken, next));
100 if (++toptoken == end)
return next;
109 const tokenizer::iterator& end,
121 const tokenizer::iterator& end)
131 for(ChildMap::iterator it =
_children->begin();
135 if (it->second != 0)
delete it->second;
147 const std::string& prefix)
const
152 ChildMap::const_iterator it;
154 out << prefix << it->first;
155 if (it->second != 0 && it->second->_thresh !=
INHERIT) {
156 for(i = prefix.length()+it->first.length(); i < 20; ++i)
158 if (it->second->_thresh >= 0 && it->second->_thresh < 10)
160 out << it->second->_thresh;
165 it->second->printDescThresholds(out, prefix+
' ');
172 : _tree(), _sep(delims.c_str())
181 if (top < 10 && top >= 0) out <<
' ';
Memory(const std::string &delims=".")
void setThresholdFor(tokenizer::iterator toptoken, const tokenizer::iterator &end, int threshold)
std::map< std::string, Family * > ChildMap
void printDescThresholds(std::ostream &out, const std::string &prefix) const
Family(int defaultThreshold=INHERIT)
void printThresholds(std::ostream &out)
Family * makeDescendants(tokenizer::iterator toptoken, const tokenizer::iterator &end)
Family * ensureDescendant(tokenizer::iterator toptoken, const tokenizer::iterator &end)
definition of the Memory class
void resetThresholdFor(tokenizer::iterator toptoken, const tokenizer::iterator &end)
A hierarchical tree structure for holding mappings of names to threshold values.
const Family * findDescendant(tokenizer::iterator toptoken, const tokenizer::iterator &end, bool orNearest=false) const