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::string &) | |
Constructor. Load a tree-completion grammar. | |
parse_tree | complete (parse_tree &, const std::string &) |
find best completions for given parse tree | |
Private Member Functions | |
completerRule | find_grammar_rule (const std::vector< parse_tree * > &, const size_t) |
retrieve rule from grammar | |
parse_tree * | applyRule (const completerRule &, parse_tree *, parse_tree *) |
apply a completion rule | |
bool | matching_condition (parse_tree::iterator, const std::list< std::string > &, RegEx &) 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, completerRule &) 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< std::string > &, const size_t) const |
check left or right context | |
void | extract_conds (std::string &, std::list< std::string > &, RegEx &) const |
Separate extra lemma/form/class conditions from the chunk label. | |
bool | match_pattern (parse_tree::iterator, const std::string &) const |
check if a chunk matches the given pattern "label<lemma>" or the like | |
bool | enabled_rule (const completerRule &) const |
Find out if currently active flags enable the given rule. | |
Private Attributes | |
std::map< std::pair < std::string, std::string > , std::list< completerRule > > | chgram |
set of rules, indexed by labels of nodes | |
std::set< std::string > | active_flags |
set of active flags, which control applicability of rules |
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.
completer::completer | ( | const std::string & | ) |
Constructor. Load a tree-completion grammar.
parse_tree * completer::applyRule | ( | const completerRule & | r, | |
parse_tree * | chunkLeft, | |||
parse_tree * | chunkRight | |||
) | [private] |
apply a completion rule
apply a tree completion rule
References active_flags, ERROR_CRASH, completerRule::flags_toggle_off, completerRule::flags_toggle_on, last, completerRule::last, completerRule::newNode1, completerRule::newNode2, completerRule::operation, and TRACE.
parse_tree completer::complete | ( | parse_tree & | , | |
const std::string & | ||||
) |
find best completions for given parse tree
bool completer::enabled_rule | ( | const completerRule & | r | ) | const [private] |
Find out if currently active flags enable the given rule.
References active_flags, and completerRule::enabling_flags.
void completer::extract_conds | ( | std::string & | , | |
std::list< std::string > & | , | |||
RegEx & | ||||
) | const [private] |
Separate extra lemma/form/class conditions from the chunk label.
completerRule completer::find_grammar_rule | ( | const std::vector< parse_tree * > & | , | |
const | size_t | |||
) | [private] |
retrieve rule from grammar
bool completer::match_pattern | ( | parse_tree::iterator | , | |
const std::string & | ||||
) | const [private] |
check if a chunk matches the given pattern "label<lemma>" or the like
bool completer::match_side | ( | const | int, | |
const std::vector< parse_tree * > & | , | |||
const | size_t, | |||
const std::vector< std::string > & | , | |||
const | size_t | |||
) | const [private] |
check left or right context
bool completer::matching_condition | ( | parse_tree::iterator | , | |
const std::list< std::string > & | , | |||
RegEx & | ||||
) | const [private] |
check if the extra lemma/form/class conditions are satisfied
bool completer::matching_context | ( | const std::vector< parse_tree * > & | , | |
const | size_t, | |||
const completerRule & | ||||
) | const [private] |
check if the current context matches the given rule
bool completer::matching_operation | ( | const std::vector< parse_tree * > & | , | |
const | size_t, | |||
completerRule & | ||||
) | const [private] |
check if the operation is executable (for last_left/last_right cases)
std::set<std::string> completer::active_flags [private] |
set of active flags, which control applicability of rules
Referenced by applyRule(), and enabled_rule().
std::map<std::pair<std::string,std::string>,std::list<completerRule> > completer::chgram [private] |
set of rules, indexed by labels of nodes