1 #ifndef EVENT_PARSER_H_
2 #define EVENT_PARSER_H_
12 #include <boost/shared_ptr.hpp>
19 #define PRINT(a) std::cout << #a << " = " << a << std::endl
33 typedef boost::shared_ptr<Syntactic_event> Event_ptr;
35 typedef std::vector<Event_ptr> Event_list;
37 typedef std::map<Lexicon_db::Val_type, bool> LF_map_t;
42 Event_db() : event_list_(), tree_list_(), num_events_(0), learn_(false)
50 std::string event_file,
51 std::string lexicon_file,
54 ) : event_list_(), tree_list_(), num_events_(0), learn_(learn)
56 read_lexicon(lexicon_file);
57 event_list_.push_back(Event_ptr());
58 read_events(event_file, num_lines);
64 Event_ptr
get_tree(
const int&
i)
const {
return tree_list_[
i];}
70 tree_list_[
i] -> print_subtree(os);
75 size_t num_trees()
const {
return tree_list_.size();}
95 static boost::shared_ptr<LF_map_t> lfwm(
new LF_map_t);
100 Event_list event_list_;
101 Event_list tree_list_;
107 void read_lexicon(
const std::string& lexicon_file);
113 void read_events(
const std::string& event_file,
const int& num_lines);
118 bool read_event(std::istringstream& event_stream);
123 bool read_event_f(std::istringstream&)
125 num_events_ += event_list_.size();
134 bool read_event_u(std::istringstream& input);
140 bool read_event_d(std::istringstream& input);
146 std::string train_path,
147 std::string lexicon_file,
149 std::string test_path =
""
static bool VERBOSE
Definition: Event_parser.h:98
Database class to read and count parse tree events.
Definition: Event_parser.h:30
size_t num_trees() const
returns number of trees in list
Definition: Event_parser.h:75
Event_db(std::string event_file, std::string lexicon_file, bool learn=true, int num_lines=10000)
constructs an event database object
Definition: Event_parser.h:49
static LF_map_t & lf_word_map()
accessor to a global map flagging low frequency words
Definition: Event_parser.h:93
Event_ptr get_tree(const int &i) const
gets pointer to tree in position i in the list
Definition: Event_parser.h:64
static Lexicon_db & lexicon()
returns a reference to the map between words and codes
Definition: Event_parser.h:83
size_t num_events() const
returns number of events
Definition: Event_parser.h:79
Definition: Lexicon_db.h:17
Event_db()
default ctor, creates empty database
Definition: Event_parser.h:42
static Nonterminal_db & nt_lexicon()
returns a reference to the map between nonterminals and codes
Definition: Event_parser.h:87
get the indices of edges in each direction for i
Definition: APPgetLargeConnectedEdges.m:48
static Lexicon_db & lexicon()
Definition: Tree_event.cpp:20
Event_db process_event_file(std::string train_path, std::string lexicon_file, size_t max_events, std::string test_path)
Free_function definitions.
Definition: Event_parser.cpp:272
Definition: Nonterminal_db.h:16
void print_tree(const int &i, std::ostream &os) const
print tree in position i to ostream os
Definition: Event_parser.h:68
static Nonterminal_db & nt_lexicon()
Definition: Tree_event.cpp:26