KJB
|
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< Word > | Word_ptr |
typedef Syntactic_event::Label_type | Label |
typedef boost::shared_ptr< Label > | Label_ptr |
typedef std::list< Self_ptr > | Child_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_list & | children () 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_pair & | semantic_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_db & | lexicon () |
return a reference to the underlying terminal lexicon More... | |
static Nonterminal_db & | nt_lexicon () |
return a reference to the underlying nonterminal lexicon More... | |
static LF_map_t & | lf_word_map () |
return a reference to the map indexing whether words are rare More... | |
static Freq_map & | word_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) |
The main syntactic tree object for semantic parsing.
typedef std::list<Self_ptr> semantics::Semspear_tree::Child_list |
typedef std::map<Word, size_t> semantics::Semspear_tree::Freq_map |
typedef boost::shared_ptr<Label> semantics::Semspear_tree::Label_ptr |
typedef std::map<Lexicon_db::Val_type, bool> semantics::Semspear_tree::LF_map_t |
typedef boost::shared_ptr<Semspear_tree> semantics::Semspear_tree::Self_ptr |
typedef boost::shared_ptr<Elaboration_tree> semantics::Semspear_tree::Sem_tree_ptr |
typedef std::list<Token_map::Key_type> semantics::Semspear_tree::Symbol_list |
typedef boost::shared_ptr<Word> semantics::Semspear_tree::Word_ptr |
semantics::Semspear_tree::Semspear_tree | ( | const Role & | role, |
const bool & | learn = true , |
||
const bool & | collins = false |
||
) |
default constructor, creates an empty tree
learn | governs 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
word | the literal word at this node (terminals only) |
label | the non- or preterminal label |
learn | governs 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
semantics::Semspear_tree::~Semspear_tree | ( | ) |
decrements word count when destructed (if learn_ is true)
void semantics::Semspear_tree::add_child | ( | const Self_ptr & | new_child, |
bool | on_left = false |
||
) |
append a new child subtree
|
inline |
returns the list of children
|
inline |
signals that tree is fully built, and to process data
|
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
|
inline |
is this a coordinating conjunction?
|
inline |
is this a punctuation node?
|
inline |
is this subtree a leaf?
|
inline |
returns the label field
|
inlinestatic |
return a reference to the underlying terminal lexicon
|
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
|
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
|
inline |
|
inline |
|
inline |
|
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
|
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
|
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
|
inline |
returns a pointer to the probabilistic event at the root
void semantics::Semspear_tree::update_event_views_recursively | ( | ) |
|
inline |
|
inlinestatic |
return a reference to the map indexing actual word frequencies
|
friend |
|
friend |
|
friend |
|
static |
should debugging messages be printed?