ModErn Text Analysis
META Enumerates Textual Applications
scorer.h
Go to the documentation of this file.
1 
10 #ifndef META_SEQUENCE_CRF_SCORER_H_
11 #define META_SEQUENCE_CRF_SCORER_H_
12 
13 #include "sequence/crf/crf.h"
14 
15 namespace meta
16 {
17 namespace sequence
18 {
19 
25 {
26  public:
34  void score(const crf& model, const sequence& seq);
35 
41  void transition_scores(const crf& model);
42 
49  void state_scores(const crf& model, const sequence& seq);
50 
54  void forward();
55 
59  void backward();
60 
65  void marginals();
66 
73  double state(uint64_t time, label_id lbl) const;
74 
80  double state_exp(uint64_t time, label_id lbl) const;
81 
87  double trans(label_id from, label_id to) const;
88 
94  double trans_exp(label_id from, label_id to) const;
95 
101  double forward(uint64_t time, label_id lbl) const;
102 
108  double backward(uint64_t time, label_id lbl) const;
109 
116  double state_marginal(uint64_t time, label_id lbl) const;
117 
124  double trans_marginal(label_id from, label_id to) const;
125 
133  double loss(const sequence& seq) const;
134 
135  private:
139  void transition_marginals();
140 
144  void state_marginals();
145 
154 
163 };
164 
165 }
166 }
167 
168 #endif
double state_marginal(uint64_t time, label_id lbl) const
Definition: scorer.cpp:214
A class for representing optional values.
Definition: vocabulary_map.h:21
double state_exp(uint64_t time, label_id lbl) const
Definition: scorer.cpp:194
void state_scores(const crf &model, const sequence &seq)
Finds only the state scores.
Definition: scorer.cpp:41
void score(const crf &model, const sequence &seq)
Finds both transition and state scores, in logarithm and exponential domains.
Definition: scorer.cpp:13
void transition_scores(const crf &model)
Finds only the transition scores.
Definition: scorer.cpp:23
Internal class that holds scoring information for sequences under the current model.
Definition: scorer.h:24
util::optional< double_matrix > trans_mrg_
Stores the transition marginals, if computed.
Definition: scorer.h:162
Represents a tagged sequence of observations.
Definition: sequence.h:24
util::optional< forward_trellis > fwd_
Stores the forward trellis, if computed.
Definition: scorer.h:156
double_matrix trans_exp_
Stores the transition scores.
Definition: scorer.h:153
double state(uint64_t time, label_id lbl) const
Definition: scorer.cpp:189
Linear-chain conditional random field for POS tagging and chunking applications.
Definition: crf.h:40
util::optional< trellis > bwd_
Stores the backward trellis, if computed.
Definition: scorer.h:158
double trans_exp(label_id from, label_id to) const
Definition: scorer.cpp:204
double_matrix state_exp_
Stores the state scores.
Definition: scorer.h:149
void marginals()
Computes the marginal probabilities of states and transitions by using the forward-backward algorithm...
Definition: scorer.cpp:124
util::optional< double_matrix > state_mrg_
Stores the state marginals, if computed.
Definition: scorer.h:160
void state_marginals()
Computes the state marginals.
Definition: scorer.cpp:154
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
double_matrix trans_
Stores the transition scores in log-domain.
Definition: scorer.h:151
void transition_marginals()
Computes the transition marginals.
Definition: scorer.cpp:136
double trans_marginal(label_id from, label_id to) const
Definition: scorer.cpp:209
double trans(label_id from, label_id to) const
Definition: scorer.cpp:199
double_matrix state_
Stores the state scores in log-domain.
Definition: scorer.h:147
void backward()
Computes the backward trellis.
Definition: scorer.cpp:93
double loss(const sequence &seq) const
Computes the loss function for a given sequence.
Definition: scorer.cpp:169
void forward()
Computes the forward trellis.
Definition: scorer.cpp:65