ModErn Text Analysis
META Enumerates Textual Applications
head_finder.h
Go to the documentation of this file.
1 
9 #ifndef META_PARSER_HEAD_FINDER_H_
10 #define META_PARSER_HEAD_FINDER_H_
11 
12 #include <unordered_map>
13 
14 #include "meta.h"
15 #include "parser/trees/visitors/visitor.h"
16 #include "util/shim.h"
17 
18 namespace meta
19 {
20 namespace parser
21 {
22 
23 struct head_rule
24 {
25  virtual uint64_t find_head(const internal_node&) const = 0;
26  virtual ~head_rule() = default;
27 };
28 
37 class head_finder : public visitor<void>
38 {
39  public:
43  using rule_table
44  = std::unordered_map<class_label, std::unique_ptr<head_rule>>;
45 
50  head_finder();
51 
55  head_finder(rule_table&& table);
56 
57  void operator()(leaf_node&) override;
58  void operator()(internal_node&) override;
59 
60  private:
65 };
66 }
67 }
68 
69 #endif
Contains top-level namespace documentation for the META toolkit.
std::unordered_map< class_label, std::unique_ptr< head_rule >> rule_table
The storage type used for holding the head finding rules.
Definition: head_finder.h:44
head_finder()
Constructs a default head finder, using the head finding rules for English from Michael Collins' thes...
Definition: head_finder.cpp:159
Abstract base class for visitors over parse trees that are allowed to modify the underlying tree...
Definition: visitor.h:50
An internal node in a parse tree.
Definition: internal_node.h:28
Definition: head_finder.h:23
A visitor that annotates the internal nodes of parse trees with their head constituents/lexicons.
Definition: head_finder.h:37
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retreival, data mining, and other applications of text processing.
Definition: analyzer.h:24
rule_table rules_
The head finding rules used for this head_finder.
Definition: head_finder.h:64
void operator()(leaf_node &) override
Definition: head_finder.cpp:249
A leaf node (pre-terminal) in a parse tree.
Definition: leaf_node.h:24