FreeLing  3.0
Public Member Functions | Private Member Functions | Private Attributes
completer Class Reference

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>

List of all members.

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_treeapplyRule (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

Detailed Description

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.


Constructor & Destructor Documentation

completer::completer ( const std::wstring &  )

Member Function Documentation

parse_tree * completer::applyRule ( const completerRule r,
parse_tree chunkLeft,
parse_tree chunkRight 
) [private]
parse_tree completer::complete ( parse_tree ,
const std::wstring &   
)
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]

Separate extra lemma/form/class conditions from the chunk label.

References closing, and WARNING.

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.


Member Data Documentation

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


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