KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
semantics::Semspear_tree Class Reference

The main syntactic tree object for semantic parsing. More...

#include <Semspear_tree.h>

Public Types

enum  Role {
  TOP, ROOT, UNARY, DEPENDENCY,
  PUNCTUATION, COORD, NUM_ROLES
}
 
typedef boost::shared_ptr
< Semspear_tree
Self_ptr
 
typedef Syntactic_event::Word_type Word
 
typedef boost::shared_ptr< WordWord_ptr
 
typedef Syntactic_event::Label_type Label
 
typedef boost::shared_ptr< LabelLabel_ptr
 
typedef std::list< Self_ptrChild_list
 
typedef Syntactic_event::Event_ptr Syn_event_ptr
 
typedef
Semantic_step_event::Event_ptr 
Sem_event_ptr
 
typedef Syntactic_event::Node_data Node_data
 
typedef boost::shared_ptr
< Elaboration_tree
Sem_tree_ptr
 
typedef Elaboration_tree::Elab_ptr Elab_ptr
 
typedef
Elaboration_tree::Elab_ptr_const 
Elab_ptr_const
 
typedef Elaboration_tree::Hash_pair Hash_pair
 
typedef std::map
< Lexicon_db::Val_type, bool > 
LF_map_t
 
typedef std::map< Word, size_t > Freq_map
 
typedef std::list
< Token_map::Key_type
Symbol_list
 

Public Member Functions

 Semspear_tree (const Role &role, const bool &learn=true, const bool &collins=false)
 default constructor, creates an empty tree More...
 
 Semspear_tree (const Word &word, const Label &label, const Role &role, const bool &learn=true, const bool &collins=false)
 constructor for terminal nodes, which directly specify word More...
 
 Semspear_tree (const Label &label, const Role &role, const bool &learn=true, const bool &collins=false)
 constructor for nonterminals, which only specify label More...
 
 Semspear_tree (const Self_ptr other, const bool &learn=false)
 copy constructor More...
 
 ~Semspear_tree ()
 decrements word count when destructed (if learn_ is true) More...
 
Word word () const
 
Label label () const
 returns the label field More...
 
const Self_ptr head () const
 returns a pointer to the head subtree More...
 
const Child_listchildren () const
 returns the list of children More...
 
Word head_word () const
 get the head word for this subtree More...
 
Label head_tag () const
 get the head tag for this subtree More...
 
Elab_ptr_const semantic_root () const
 get a pointer to the root of the associated semantic tree More...
 
const Hash_pairsemantic_codes () const
 get the pair of semantic codes at the root of this subtree More...
 
const Syn_event_ptr syntactic_event () const
 returns a pointer to the probabilistic event at the root More...
 
bool is_terminal () const
 is this subtree a leaf? More...
 
bool is_punctuation () const
 is this a punctuation node? More...
 
bool is_coordination () const
 is this a coordinating conjunction? More...
 
double node_log_probability () const
 compute log prob of this node by itself More...
 
double subtree_log_probability () const
 compute log prob of this tree according to events More...
 
void set_word (const Word &word)
 assign a new value to the word field More...
 
void set_label (const Label &label)
 assign a new value to the label field More...
 
void set_head (const Child_list::const_iterator head)
 assign a new head and acquire its info More...
 
void set_role (const Role &role)
 set the syntactic role of this node More...
 
void set_coord (const bool new_value)
 set the coordinated phrase flag More...
 
void set_semantic_tree (const Sem_tree_ptr new_tree)
 associate this syntactic tree w/ a new semantic tree More...
 
void set_semantic_data (const Elab_ptr_const semantic_parent, const Step_code_t &step_code)
 set semantic data for this node More...
 
void add_child (const Self_ptr &new_child, bool on_left=false)
 append a new child subtree More...
 
void preprocess_tree ()
 do some preprocessing in accordance with Collins' model More...
 
void complete_tree ()
 signals that tree is fully built, and to process data More...
 
void release_event_counts ()
 
void reacquire_event_counts ()
 
void reacquire_event_counts_recursively ()
 
void update_event_views_recursively ()
 
void print_constituency_tree (std::ostream &os, bool is_head=false, int indent_level=0) const
 print as constituency tree (marking head) More...
 
void print_dependency_tree (std::ostream &os, bool is_head=false, int indent_level=0) const
 display as dependency tree More...
 
void print_events_with_probabilities (std::ostream &os) const
 print events and associated log probabilities More...
 
void print_subtree_view_counts (std::ostream &os) const
 print count info at each node More...
 

Static Public Member Functions

static Lexicon_dblexicon ()
 return a reference to the underlying terminal lexicon More...
 
static Nonterminal_dbnt_lexicon ()
 return a reference to the underlying nonterminal lexicon More...
 
static LF_map_tlf_word_map ()
 return a reference to the map indexing whether words are rare More...
 
static Freq_mapword_freq_map ()
 return a reference to the map indexing actual word frequencies More...
 

Static Public Attributes

static bool VERBOSE = false
 should debugging messages be printed? More...
 

Friends

void initialize_special_symbols ()
 
boost::tuple< Self_ptr,
kjb::Vector
propose_new_tree (const Self_ptr source)
 
void resample_event_tables (Self_ptr &source)
 

Detailed Description

The main syntactic tree object for semantic parsing.

Member Typedef Documentation

typedef std::map<Word, size_t> semantics::Semspear_tree::Freq_map
typedef boost::shared_ptr<Label> semantics::Semspear_tree::Label_ptr
typedef boost::shared_ptr<Word> semantics::Semspear_tree::Word_ptr

Member Enumeration Documentation

Enumerator
TOP 
ROOT 
UNARY 
DEPENDENCY 
PUNCTUATION 
COORD 
NUM_ROLES 

Constructor & Destructor Documentation

semantics::Semspear_tree::Semspear_tree ( const Role role,
const bool &  learn = true,
const bool &  collins = false 
)

default constructor, creates an empty tree

Parameters
learngoverns whether to update model using this tree
semantics::Semspear_tree::Semspear_tree ( const Word word,
const Label label,
const Role role,
const bool &  learn = true,
const bool &  collins = false 
)

constructor for terminal nodes, which directly specify word

Parameters
wordthe literal word at this node (terminals only)
labelthe non- or preterminal label
learngoverns whether to update model using this tree
semantics::Semspear_tree::Semspear_tree ( const Label label,
const Role role,
const bool &  learn = true,
const bool &  collins = false 
)

constructor for nonterminals, which only specify label

semantics::Semspear_tree::Semspear_tree ( const Self_ptr  other,
const bool &  learn = false 
)

copy constructor

Remarks
copies self-contained data and creates new copies of child trees (rather than simply copying the pointers). Resulting copy defaults to have learn_ = false so that any training tree is only counted once.
semantics::Semspear_tree::~Semspear_tree ( )

decrements word count when destructed (if learn_ is true)

Member Function Documentation

void semantics::Semspear_tree::add_child ( const Self_ptr new_child,
bool  on_left = false 
)

append a new child subtree

const Child_list& semantics::Semspear_tree::children ( ) const
inline

returns the list of children

void semantics::Semspear_tree::complete_tree ( )
inline

signals that tree is fully built, and to process data

const Self_ptr semantics::Semspear_tree::head ( ) const
inline

returns a pointer to the head subtree

Semspear_tree::Label semantics::Semspear_tree::head_tag ( ) const

get the head tag for this subtree

Semspear_tree::Word semantics::Semspear_tree::head_word ( ) const

get the head word for this subtree

bool semantics::Semspear_tree::is_coordination ( ) const
inline

is this a coordinating conjunction?

bool semantics::Semspear_tree::is_punctuation ( ) const
inline

is this a punctuation node?

bool semantics::Semspear_tree::is_terminal ( ) const
inline

is this subtree a leaf?

Label semantics::Semspear_tree::label ( ) const
inline

returns the label field

static Lexicon_db& semantics::Semspear_tree::lexicon ( )
inlinestatic

return a reference to the underlying terminal lexicon

static LF_map_t& semantics::Semspear_tree::lf_word_map ( )
inlinestatic

return a reference to the map indexing whether words are rare

double semantics::Semspear_tree::node_log_probability ( ) const

compute log prob of this node by itself

Nonterminal_db & semantics::Semspear_tree::nt_lexicon ( )
static

return a reference to the underlying nonterminal lexicon

void semantics::Semspear_tree::preprocess_tree ( )

do some preprocessing in accordance with Collins' model

void semantics::Semspear_tree::print_constituency_tree ( std::ostream &  os,
bool  is_head = false,
int  indent_level = 0 
) const

print as constituency tree (marking head)

void semantics::Semspear_tree::print_dependency_tree ( std::ostream &  os,
bool  is_head = false,
int  indent_level = 0 
) const

display as dependency tree

void semantics::Semspear_tree::print_events_with_probabilities ( std::ostream &  os) const

print events and associated log probabilities

void semantics::Semspear_tree::print_subtree_view_counts ( std::ostream &  os) const

print count info at each node

void semantics::Semspear_tree::reacquire_event_counts ( )
inline
void semantics::Semspear_tree::reacquire_event_counts_recursively ( )
inline
void semantics::Semspear_tree::release_event_counts ( )
inline
const Hash_pair& semantics::Semspear_tree::semantic_codes ( ) const
inline

get the pair of semantic codes at the root of this subtree

Semspear_tree::Elab_ptr_const semantics::Semspear_tree::semantic_root ( ) const

get a pointer to the root of the associated semantic tree

void semantics::Semspear_tree::set_coord ( const bool  new_value)
inline

set the coordinated phrase flag

void semantics::Semspear_tree::set_head ( const Child_list::const_iterator  head)

assign a new head and acquire its info

void semantics::Semspear_tree::set_label ( const Label label)

assign a new value to the label field

void semantics::Semspear_tree::set_role ( const Role role)
inline

set the syntactic role of this node

void semantics::Semspear_tree::set_semantic_data ( const Elab_ptr_const  semantic_parent,
const Step_code_t step_code 
)

set semantic data for this node

void semantics::Semspear_tree::set_semantic_tree ( const Sem_tree_ptr  new_tree)

associate this syntactic tree w/ a new semantic tree

void semantics::Semspear_tree::set_word ( const Word word)

assign a new value to the word field

double semantics::Semspear_tree::subtree_log_probability ( ) const

compute log prob of this tree according to events

const Syn_event_ptr semantics::Semspear_tree::syntactic_event ( ) const
inline

returns a pointer to the probabilistic event at the root

void semantics::Semspear_tree::update_event_views_recursively ( )
Word semantics::Semspear_tree::word ( ) const
inline
static Freq_map& semantics::Semspear_tree::word_freq_map ( )
inlinestatic

return a reference to the map indexing actual word frequencies

Friends And Related Function Documentation

void initialize_special_symbols ( )
friend
boost::tuple<Self_ptr, kjb::Vector> propose_new_tree ( const Self_ptr  source)
friend
void resample_event_tables ( Self_ptr source)
friend

Member Data Documentation

bool semantics::Semspear_tree::VERBOSE = false
static

should debugging messages be printed?


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