1 #ifndef __DICTIONARY_H__
2 #include "dictionary.h"
12 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
13 #include <boost/shared_ptr.hpp>
19 typedef boost::shared_ptr
<NNode
> NNodeRef
;
24 virtual bool is_leaf() const = 0;
28 class BranchNNode
:public NNode
31 typedef std::multimap
<strid
,NNodeRef
> node_map
;
32 typedef std::pair
<node_map::const_iterator
,node_map::const_iterator
> const_np_range
;
33 typedef std::pair
<node_map::iterator
,node_map::iterator
> np_range
;
36 virtual ~BranchNNode() {}
37 bool is_leaf() const { return false; }
38 void get_leaves(strid
,std::vector
<LeafNNode
*> &nodes
) const;
39 void get_branches(strid
,std::vector
<BranchNNode
*> &nodes
) const;
40 BranchNNode
* get_branch(strid
) const;
41 const node_map
& get_nodes() const { return nodes
; }
43 BranchNNode
* add_path(std::vector
<strid
> toks
);
44 void add(strid
,NNodeRef
);
47 class LeafNNode
:public NNode
52 virtual ~LeafNNode() {}
53 bool is_leaf() const { return true; }
54 strid
get_id() const { return id
; }
55 void set_id(strid _id
) { id
= _id
; }
57 uint
get_syllable_count() const;
58 void get_syllables(std::vector
<strid
> &syllables
) const;
65 DNNode(NNode
* _node
= NULL
):node(_node
),distance(0) {}
66 int operator == (const DNNode
&dn1
) const {
67 return dn1
.node
== node
;
69 int operator < (const DNNode
&dn1
) const {
70 return (int)node
+distance
< (int)dn1
.node
+dn1
.distance
;
72 NNode
& operator* () const { return *node
; }
73 NNode
* operator-> () const { return node
; }