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

Represents the parse tree for a sentence. More...

#include <parse_tree.h>

Public Member Functions

 parse_tree (std::unique_ptr< node > root)
 Creates a new parse tree by taking ownership of a subtree pointed to by the argument. More...
 
 parse_tree (const parse_tree &)
 Copy constructor.
 
 parse_tree (parse_tree &&)=default
 Move constructor.
 
parse_treeoperator= (parse_tree)
 Assignment operator.
 
void swap (parse_tree &)
 Swaps this parse tree with the given parse tree.
 
void transform (tree_transformer &)
 Transforms the current parse tree by using the given tree_transformer.
 
template<class Visitor >
std::remove_reference< Visitor >::type::result_type visit (Visitor &&vtor)
 Runs a visitor over the parse tree. More...
 
template<class Visitor >
std::remove_reference< Visitor >::type::result_type visit (Visitor &&vtor) const
 Runs a visitor over the parse tree. More...
 
void pretty_print (std::ostream &os) const
 Prints a parse tree to a stream. More...
 

Private Attributes

std::unique_ptr< noderoot_
 The root of the parse tree.
 

Friends

std::ostream & operator<< (std::ostream &os, const parse_tree &tree)
 Prints a parse tree to a stream. More...
 
bool operator== (const parse_tree &lhs, const parse_tree &rhs)
 

Detailed Description

Represents the parse tree for a sentence.

This may either be a sentence parsed from training data, or the output from a trained parser on test data.

Todo:
determine what parts of analyzers::parse_tree are worth keeping—that class deals specifically with trees read from the output of the Stanford parser. When we have our own, we may still want some of that functionality to allow people to use parsers that are not our own?

Constructor & Destructor Documentation

meta::parser::parse_tree::parse_tree ( std::unique_ptr< node root)

Creates a new parse tree by taking ownership of a subtree pointed to by the argument.

Parameters
rootThe desired root of the parse tree

Member Function Documentation

template<class Visitor >
std::remove_reference<Visitor>::type::result_type meta::parser::parse_tree::visit ( Visitor &&  vtor)
inline

Runs a visitor over the parse tree.

Non-const version.

Returns
the result from the visitor.
template<class Visitor >
std::remove_reference<Visitor>::type::result_type meta::parser::parse_tree::visit ( Visitor &&  vtor) const
inline

Runs a visitor over the parse tree.

Const version.

Returns
the result from the visitor.
void meta::parser::parse_tree::pretty_print ( std::ostream &  os) const

Prints a parse tree to a stream.

This is indented.

Parameters
osThe stream to print to

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const parse_tree tree 
)
friend

Prints a parse tree to a stream.

This is non-indented.

Parameters
osThe stream to print to
treeThe tree to be printed
Returns
the stream
bool operator== ( const parse_tree lhs,
const parse_tree rhs 
)
friend
Parameters
lhsThe left hand side of the expression
rhsThe right hand side of the expression
Returns
whether the two parse trees are equivalent

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