|
FreeLing
3.0
|
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 &) |
| 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::wstring > &, boost::u32regex &) 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::wstring > &, const size_t) const |
| check left or right context | |
| void | extract_conds (std::wstring &, std::list< std::wstring > &, boost::u32regex &) const |
| Separate extra lemma/form/class conditions from the chunk label. | |
| bool | match_pattern (parse_tree::iterator, const std::wstring &) 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::wstring, std::wstring > , std::list< completerRule > > | chgram |
| set of rules, indexed by labels of nodes | |
| std::set< std::wstring > | 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::wstring & | ) |
Constructor. Load a tree-completion grammar.
Constructor.
Load a tree-completion grammar
References util::absolute(), completerRule::context, completerRule::context_neg, completerRule::enabling_flags, ERROR_CRASH, completerRule::flags_toggle_off, completerRule::flags_toggle_on, util::int2wstring(), completerRule::leftChk, completerRule::leftConds, completerRule::leftRE, completerRule::line, util::list2wstring(), completerRule::newNode1, completerRule::newNode2, util::open_utf8_file(), completerRule::operation, completerRule::rightChk, completerRule::rightConds, completerRule::rightRE, util::set2wstring(), TRACE, WARNING, completerRule::weight, check_wordclass::wordclasses, and util::wstring2set().
| parse_tree * completer::applyRule | ( | const completerRule & | r, |
| parse_tree * | chunkLeft, | ||
| parse_tree * | chunkRight | ||
| ) | [private] |
apply a completion rule
apply a tree completion rule
References tree< T >::begin(), ERROR_CRASH, completerRule::flags_toggle_off, completerRule::flags_toggle_on, tree< T >::hang_child(), completerRule::last, last, completerRule::newNode1, completerRule::newNode2, completerRule::operation, and TRACE.
| parse_tree completer::complete | ( | parse_tree & | , |
| const std::wstring & | |||
| ) |
find best completions for given parse tree
Complete a partial parse tree.
References tree< T >::begin(), completerRule::context, completerRule::context_neg, completerRule::enabling_flags, completerRule::flags_toggle_off, completerRule::flags_toggle_on, tree< T >::hang_child(), tree< T >::info, util::int2wstring(), completerRule::leftChk, completerRule::leftConds, completerRule::line, util::list2wstring(), completerRule::newNode1, completerRule::newNode2, tree< T >::num_children(), completerRule::operation, parse_tree::rebuild_node_index(), completerRule::rightChk, completerRule::rightConds, util::set2wstring(), node::set_chunk(), node::set_head(), tree< T >::sibling_begin(), tree< T >::sibling_end(), TRACE, traces::TraceLevel, and completerRule::weight.
Referenced by dep_txala::analyze().
| bool completer::enabled_rule | ( | const completerRule & | r | ) | const [private] |
Find out if currently active flags enable the given rule.
References completerRule::enabling_flags.
| void completer::extract_conds | ( | std::wstring & | , |
| std::list< std::wstring > & | , | ||
| boost::u32regex & | |||
| ) | const [private] |
| completerRule completer::find_grammar_rule | ( | const std::vector< parse_tree * > & | , |
| const size_t | |||
| ) | [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 util::int2wstring(), util::list2wstring(), util::set2wstring(), and TRACE.
| bool completer::match_pattern | ( | parse_tree::iterator | , |
| const std::wstring & | |||
| ) | const [private] |
check if a chunk matches the given pattern "label<lemma>" or the like
check if a pattern of the type label<lemma>, label(form), etc., matches a given node in the tree.
References TRACE, and util::wstring2vector().
| bool completer::match_side | ( | const int | , |
| const std::vector< parse_tree * > & | , | ||
| const size_t | , | ||
| const std::vector< std::wstring > & | , | ||
| const size_t | |||
| ) | const [private] |
check left or right context
References first_chk, first_cond, util::int2wstring(), last, LEFT, next, prev, and TRACE.
| bool completer::matching_condition | ( | parse_tree::iterator | , |
| const std::list< std::wstring > & | , | ||
| boost::u32regex & | |||
| ) | const [private] |
check if the extra lemma/form/class conditions are satisfied
check if the extra lemma/form/class conditions are satisfied.
References word::get_form(), word::get_lemma(), word::get_tag(), TRACE, WARNING, and check_wordclass::wordclasses.
| 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
Check if the current context matches the one specified in the given rule.
References completerRule::context, completerRule::context_neg, util::int2wstring(), LEFT, RIGHT, TRACE, and util::wstring2vector().
| 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)
References completerRule::last, completerRule::newNode1, completerRule::operation, and TRACE.
std::set<std::wstring> completer::active_flags [private] |
set of active flags, which control applicability of rules
std::map<std::pair<std::wstring,std::wstring>,std::list<completerRule> > completer::chgram [private] |
set of rules, indexed by labels of nodes
1.7.6.1