ModErn Text Analysis
META Enumerates Textual Applications
Public Types | Public Member Functions | Private Attributes | List of all members
meta::parser::internal_node Class Reference

An internal node in a parse tree. More...

#include <internal_node.h>

Inheritance diagram for meta::parser::internal_node:
meta::util::multilevel_clonable< Root, Base, Derived >

Public Types

using base = util::clonable< node, internal_node >
 

Public Member Functions

template<class FwdIt >
 internal_node (class_label cat, FwdIt begin, FwdIt end)
 Constructs a new internal node by moving the children into the node from a sequence denoted by iterators. More...
 
 internal_node (class_label cat, std::vector< std::unique_ptr< node >> &&children)
 Constructs a new internal node by moving the children into the node from another vector of children. More...
 
 internal_node (const internal_node &)
 Copies an internal node.
 
void add_child (std::unique_ptr< node > child)
 Adds a child to this node. More...
 
uint64_t num_children () const
 
const nodechild (uint64_t idx) const
 
bool is_leaf () const override
 
bool equal (const node &other) const override
 
const leaf_nodehead_lexicon () const
 
void head_lexicon (const leaf_node *l)
 
const nodehead_constituent () const
 
void head_constituent (const node *n)
 
void head (const node *n)
 Sets the head constituent and head lexicon based on a node whose head lexicon has already been determined. More...
 
template<class Fun >
void each_child (Fun &&fn) const
 Runs a functor over each child. More...
 
template<class Fun >
void each_child (Fun &&fn)
 Runs a functor over each child. More...
 
- Public Member Functions inherited from meta::util::multilevel_clonable< Root, Base, Derived >
virtual std::unique_ptr< Root > clone () const
 Clones the given object. More...
 

Private Attributes

std::vector< std::unique_ptr< node > > children_
 A list of the children of this node, from left to right.
 
const leaf_nodehead_lexicon_ = nullptr
 A pointer to the head word for this subtree.
 
const nodehead_constituent_ = nullptr
 A pointer to the head constituent for this subtree (one of this tree's children)
 

Detailed Description

An internal node in a parse tree.

Every node in the parse tree that is not a pre-terminal is an internal node.

Constructor & Destructor Documentation

template<class FwdIt >
meta::parser::internal_node::internal_node ( class_label  cat,
FwdIt  begin,
FwdIt  end 
)
inline

Constructs a new internal node by moving the children into the node from a sequence denoted by iterators.

Parameters
catThe desired category for this node
beginAn iterator to the beginning of a sequence of children for this node
endAn iterator to the ending of a sequence of children for this node
meta::parser::internal_node::internal_node ( class_label  cat,
std::vector< std::unique_ptr< node >> &&  children 
)

Constructs a new internal node by moving the children into the node from another vector of children.

Parameters
catThe desired category for this node
childrenThe vector of children, which will be moved into this node

Member Function Documentation

void meta::parser::internal_node::add_child ( std::unique_ptr< node child)

Adds a child to this node.

Parameters
childThe child to be added
uint64_t meta::parser::internal_node::num_children ( ) const
Returns
the number of children this node has
const node * meta::parser::internal_node::child ( uint64_t  idx) const
Parameters
idxThe index of the child to fetch
Returns
a non-owning pointer to the child at that index from left to right
const leaf_node * meta::parser::internal_node::head_lexicon ( ) const
Returns
the head lexicon of this node
void meta::parser::internal_node::head_lexicon ( const leaf_node l)
Parameters
lThe desired head lexicon for this node
const node * meta::parser::internal_node::head_constituent ( ) const
Returns
the head constituent for this node
void meta::parser::internal_node::head_constituent ( const node n)
Parameters
nThe desired head constituent for this node
void meta::parser::internal_node::head ( const node n)

Sets the head constituent and head lexicon based on a node whose head lexicon has already been determined.

Parameters
nThe desired head constituent for this node (must have the head lexicon determined)
template<class Fun >
void meta::parser::internal_node::each_child ( Fun &&  fn) const
inline

Runs a functor over each child.

Const version.

Parameters
fnThe functor to run over each child
template<class Fun >
void meta::parser::internal_node::each_child ( Fun &&  fn)
inline

Runs a functor over each child.

Non-const version.

Parameters
fnThe functor to run over each child.

The documentation for this class was generated from the following files: