OSDN Git Service

Initial commit
[wordring-tm/wordring-tm.git] / third_party / mecab-0.996 / src / viterbi.h
1 //  MeCab -- Yet Another Part-of-Speech and Morphological Analyzer
2 //
3 //
4 //  Copyright(C) 2001-2006 Taku Kudo <taku@chasen.org>
5 //  Copyright(C) 2004-2006 Nippon Telegraph and Telephone Corporation
6 #ifndef MECAB_VITERBI_H_
7 #define MECAB_VITERBI_H_
8
9 #include <vector>
10 #include "mecab.h"
11 #include "thread.h"
12
13 namespace MeCab {
14
15 class Lattice;
16 class Param;
17 class Connector;
18 template <typename N, typename P> class Tokenizer;
19
20 class Viterbi {
21  public:
22   bool open(const Param &param);
23
24   bool analyze(Lattice *lattice) const;
25
26   const Tokenizer<Node, Path> *tokenizer() const;
27
28   const Connector *connector() const;
29
30   const char *what() { return what_.str(); }
31
32   static bool buildResultForNBest(Lattice *lattice);
33
34   Viterbi();
35   virtual ~Viterbi();
36
37  private:
38   template <bool IsAllPath, bool IsPartial> bool viterbi(Lattice *lattice) const;
39
40   static bool forwardbackward(Lattice *lattice);
41   static bool initPartial(Lattice *lattice);
42   static bool initNBest(Lattice *lattice);
43   static bool buildBestLattice(Lattice *lattice);
44   static bool buildAllLattice(Lattice *lattice);
45   static bool buildAlternative(Lattice *lattice);
46
47   scoped_ptr<Tokenizer<Node, Path> > tokenizer_;
48   scoped_ptr<Connector> connector_;
49   int                   cost_factor_;
50   whatlog               what_;
51 };
52 }
53 #endif  // MECAB_VITERBI_H_