ZGen  0.2.0
a linearization system for natural language.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
model.h
Go to the documentation of this file.
1 #ifndef __ZGEN_SHIFTREDUCE_MODEL_MODEL_H__
2 #define __ZGEN_SHIFTREDUCE_MODEL_MODEL_H__
3 
4 #include "shiftreduce/option.h"
5 #include "score.h"
6 #include "score_map.h"
7 #include <vector>
8 
9 namespace ZGen {
10 namespace ShiftReduce {
11 
12 class Model {
13 public:
14  Model(const option_t& opts);
15 
24  floatval_t score(const StateItem& state, const Action& act, bool avg);
25 
35  floatval_t score(const ScoreContext& ctx, const Action& act, bool avg);
36 
45  void update(const StateItem& state, const Action& act, int timestamp,
46  floatval_t scale);
47 
56  void update(const ScoreContext& ctx, const Action& act, int timestamp,
57  floatval_t scale);
58 
61  void flush(int timestamp);
62 
70  bool save(std::ostream& os);
71 
79  bool load(std::istream& is);
80 private:
81  std::vector< ScoreMap<UnigramScore> > uscore_repo;
82  std::vector< ScoreMap<BigramScore> > bscore_repo;
83  std::vector< ScoreMap<TrigramScore> > tscore_repo;
84 
85  std::vector< UnigramScore > uscore_cache;
86  std::vector< BigramScore > bscore_cache;
87  std::vector< TrigramScore > tscore_cache;
88 };
89 
90 }
91 }
92 
93 #endif // end for __ZGEN_SHIFTREDUCE_MODEL_MODEL_H__
Definition: score_context.h:47
Definition: state.h:15
bool save(std::ostream &os)
Definition: model.cc:232
Definition: option.h:10
Definition: model.h:12
Definition: action.h:18
double floatval_t
Definition: settings.h:24
floatval_t score(const StateItem &state, const Action &act, bool avg)
Definition: model.cc:186
void flush(int timestamp)
Definition: model.cc:222
void update(const StateItem &state, const Action &act, int timestamp, floatval_t scale)
Definition: model.cc:204
bool load(std::istream &is)
Definition: model.cc:244
Model(const option_t &opts)
Definition: model.cc:46