ModErn Text Analysis
META Enumerates Textual Applications
transition_map.h
Go to the documentation of this file.
1 
9 #ifndef META_PARSER_TRANSITION_MAP_H_
10 #define META_PARSER_TRANSITION_MAP_H_
11 
12 #include "parser/transition.h"
13 #include "util/sparse_vector.h"
14 
15 namespace meta
16 {
17 namespace parser
18 {
19 
24 {
25  public:
29  transition_map() = default;
30 
35  transition_map(const std::string& prefix);
36 
41  const transition& at(trans_id id) const;
42 
47  trans_id at(const transition& trans) const;
48 
55  trans_id operator[](const transition& trans);
56 
61  void save(const std::string& prefix) const;
62 
66  uint64_t size() const;
67 
71  class exception : public std::runtime_error
72  {
73  public:
74  using std::runtime_error::runtime_error;
75  };
76 
77  private:
82 
86  std::vector<transition> transitions_;
87 };
88 }
89 }
90 #endif
uint64_t size() const
Definition: transition_map.cpp:97
std::vector< transition > transitions_
The "map" from id to transition.
Definition: transition_map.h:86
Represents a transition taken by the parser.
Definition: transition.h:27
Represents a sparse vector, indexed by type Index and storing values of type Value.
Definition: sparse_vector.h:28
Exception thrown from interactions with the transition_map.
Definition: transition_map.h:71
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
transition_map()=default
Default constructor.
trans_id operator[](const transition &trans)
Adds a transition to the map, if it doesn't already exist.
Definition: transition_map.cpp:86
An invertible map that maps transitions to ids.
Definition: transition_map.h:23
void save(const std::string &prefix) const
Saves the map to a file stored in the folder indicated by prefix.
Definition: transition_map.cpp:103
const transition & at(trans_id id) const
Definition: transition_map.cpp:72
util::sparse_vector< transition, trans_id > map_
The map from transition to id.
Definition: transition_map.h:81