00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef Tanl_POS_viterbi_H
00025 #define Tanl_POS_viterbi_H
00026
00027 #include "HMM.h"
00028 #include "State.h"
00029
00030 using namespace std;
00031
00032 namespace Tanl { namespace POS {
00033
00050 class Viterbi
00051 {
00052 public:
00053 struct Node {
00054 Node() {}
00055 Node(State const& state, Node const* from = 0, double weight = 0) :
00056 state(state), from(from), weight(weight) { }
00057
00058 State state;
00059 Node const* from;
00060 double weight;
00061 };
00062
00063 Viterbi(HMM& hmm) : hmm(hmm) { }
00064
00070 std::vector<State> decode(double logtheta, State& startState,
00071 HMM::Observations& observations);
00072
00073 private:
00078 void step_forward(double logtheta, std::vector<Node>& currentNodes,
00079 HMM::Observation const& obs);
00080
00081 HMM& hmm;
00082 };
00083
00084 }
00085 }
00086
00087 #endif // Tanl_POS_viterbi_H