FreeLing
3.1
|
The class completer implements a parse tree completer, which given a partial parse tree (chunker output), completes the full parse according to some grammar rules. More...
#include <dependencies.h>
Public Member Functions | |
completer (const std::wstring &) | |
Constructor. Load a tree-completion grammar. | |
parse_tree | complete (parse_tree &, const std::wstring &, dep_txala_status *) const |
find best completions for given parse tree | |
Static Public Member Functions | |
static void | load_classes (const std::wstring &, const std::wstring &, const std::wstring &, std::set< std::wstring > &) |
auxiliary to load CLASS section of config file, used both by completer and labeler. | |
Private Member Functions | |
completerRule | find_grammar_rule (const std::vector< parse_tree * > &, const size_t, dep_txala_status *) const |
retrieve rule from grammar | |
parse_tree * | applyRule (const completerRule &, int, parse_tree *, parse_tree *, dep_txala_status *) const |
apply a completion rule | |
bool | match_condition (parse_tree::iterator, const matching_condition &) const |
check if the extra lemma/form/class conditions are satisfied | |
bool | matching_context (const std::vector< parse_tree * > &, const size_t, const completerRule &) const |
check if the current context matches the given rule | |
bool | matching_operation (const std::vector< parse_tree * > &, const size_t, const completerRule &, dep_txala_status *) const |
check if the operation is executable (for last_left/last_right cases) | |
bool | match_side (const int, const std::vector< parse_tree * > &, const size_t, const std::vector< matching_condition > &) const |
check left or right context | |
void | extract_conds (std::wstring &, matching_condition &) const |
Separate extra lemma/form/class conditions from the chunk label. | |
bool | enabled_rule (const completerRule &, dep_txala_status *) const |
Find out if currently active flags enable the given rule. | |
Private Attributes | |
std::map< std::pair < std::wstring, std::wstring > , std::list< completerRule > > | chgram |
set of rules, indexed by labels of nodes | |
std::set< std::wstring > | wordclasses |
The class completer implements a parse tree completer, which given a partial parse tree (chunker output), completes the full parse according to some grammar rules.
freeling::completer::completer | ( | const std::wstring & | ) |
Constructor. Load a tree-completion grammar.
Constructor.
Load a tree-completion grammar
References freeling::config_file::add_section(), freeling::config_file::close(), freeling::completerRule::context_neg, freeling::completerRule::enabling_flags, ERROR_CRASH, freeling::completerRule::flags_toggle_off, freeling::completerRule::flags_toggle_on, freeling::config_file::get_content_line(), freeling::config_file::get_line_num(), freeling::config_file::get_section(), int2wstring, freeling::completerRule::leftChk, freeling::completerRule::leftConds, freeling::completerRule::leftContext, freeling::completerRule::line, freeling::completerRule::matchingCond, freeling::completerRule::newNode1, freeling::completerRule::newNode2, freeling::config_file::open(), freeling::completerRule::operation, freeling::completerRule::rightChk, freeling::completerRule::rightConds, freeling::completerRule::rightContext, TRACE, WARNING, freeling::completerRule::weight, wstring2set, and wstring2vector.
parse_tree * freeling::completer::applyRule | ( | const completerRule & | r, |
int | chk, | ||
parse_tree * | chunkLeft, | ||
parse_tree * | chunkRight, | ||
dep_txala_status * | st | ||
) | const [private] |
apply a completion rule
apply a tree completion rule
References freeling::dep_txala_status::active_flags, freeling::tree< T >::begin(), ERROR_CRASH, freeling::completerRule::flags_toggle_off, freeling::completerRule::flags_toggle_on, freeling::tree< T >::hang_child(), int2wstring, freeling::matching_condition::label, freeling::dep_txala_status::last, last, freeling::completerRule::line, freeling::completerRule::matchingCond, freeling::completerRule::newNode1, freeling::completerRule::newNode2, freeling::completerRule::operation, and TRACE.
parse_tree freeling::completer::complete | ( | parse_tree & | , |
const std::wstring & | , | ||
dep_txala_status * | |||
) | const |
find best completions for given parse tree
Complete a partial parse tree.
References freeling::tree< T >::begin(), freeling::tree< T >::hang_child(), freeling::tree< T >::info, int2wstring, freeling::dep_txala_status::last, freeling::completerRule::line, freeling::tree< T >::num_children(), freeling::parse_tree::rebuild_node_index(), freeling::node::set_chunk(), freeling::node::set_head(), freeling::tree< T >::sibling_begin(), freeling::tree< T >::sibling_end(), TRACE, and freeling::completerRule::weight.
Referenced by freeling::dep_txala::analyze().
bool freeling::completer::enabled_rule | ( | const completerRule & | r, |
dep_txala_status * | st | ||
) | const [private] |
Find out if currently active flags enable the given rule.
References freeling::dep_txala_status::active_flags, and freeling::completerRule::enabling_flags.
void freeling::completer::extract_conds | ( | std::wstring & | , |
matching_condition & | |||
) | const [private] |
Separate extra lemma/form/class conditions from the chunk label.
References freeling::matching_condition::attrs, closing, freeling::matching_condition::label, freeling::matching_condition::neg, freeling::matching_attrib::re, freeling::matching_attrib::type, freeling::matching_attrib::value, and WARNING.
completerRule freeling::completer::find_grammar_rule | ( | const std::vector< parse_tree * > & | , |
const size_t | , | ||
dep_txala_status * | |||
) | const [private] |
retrieve rule from grammar
Look for a completer grammar rule matching the given chunk in "chk" position of "trees" and his right-hand-side mate.
References int2wstring, and TRACE.
void freeling::completer::load_classes | ( | const std::wstring & | , |
const std::wstring & | , | ||
const std::wstring & | , | ||
std::set< std::wstring > & | |||
) | [static] |
auxiliary to load CLASS section of config file, used both by completer and labeler.
References ERROR_CRASH.
Referenced by freeling::depLabeler::depLabeler().
bool freeling::completer::match_condition | ( | parse_tree::iterator | chunk, |
const matching_condition & | cond | ||
) | const [private] |
check if the extra lemma/form/class conditions are satisfied
check if the extra lemma/form/class conditions are satisfied.
References freeling::matching_condition::attrs, freeling::word::get_form(), freeling::word::get_lemma(), freeling::word::get_tag(), freeling::matching_condition::label, freeling::matching_condition::neg, TRACE, and WARNING.
bool freeling::completer::match_side | ( | const int | , |
const std::vector< parse_tree * > & | , | ||
const size_t | , | ||
const std::vector< matching_condition > & | |||
) | const [private] |
check left or right context
References first_chk, first_cond, int2wstring, last, LEFT, next, prev, and TRACE.
bool freeling::completer::matching_context | ( | const std::vector< parse_tree * > & | , |
const size_t | , | ||
const completerRule & | |||
) | const [private] |
check if the current context matches the given rule
Check if the current context matches the one specified in the given rule.
References freeling::completerRule::context_neg, LEFT, freeling::completerRule::leftContext, RIGHT, freeling::completerRule::rightContext, and TRACE.
bool freeling::completer::matching_operation | ( | const std::vector< parse_tree * > & | , |
const size_t | , | ||
const completerRule & | , | ||
dep_txala_status * | |||
) | const [private] |
check if the operation is executable (for last_left/last_right cases)
References int2wstring, freeling::dep_txala_status::last, freeling::completerRule::line, freeling::completerRule::matchingCond, freeling::completerRule::newNode1, freeling::completerRule::operation, and TRACE.
std::map<std::pair<std::wstring,std::wstring>,std::list<completerRule> > freeling::completer::chgram [private] |
set of rules, indexed by labels of nodes
std::set<std::wstring> freeling::completer::wordclasses [private] |