OSDN Git Service

Initial commit
[wordring-tm/wordring-tm.git] / third_party / mecab-0.996 / src / context_id.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_CONTEXT_ID_H
7 #define MECAB_CONTEXT_ID_H
8
9 #include <map>
10 #include <string>
11 #include <vector>
12
13 namespace MeCab {
14
15 class Param;
16 class Iconv;
17
18 class ContextID {
19  private:
20   std::map<std::string, int>  left_;
21   std::map<std::string, int>  right_;
22   std::string                 left_bos_;
23   std::string                 right_bos_;
24
25  public:
26   void clear();
27   void add(const char *l, const char *r);
28   void addBOS(const char *l, const char *r);
29   bool save(const char* lfile,
30             const char* rfile);
31   bool build();
32   bool open(const char *lfile,
33             const char *rfile,
34             Iconv *iconv = 0);
35   int  lid(const char *l) const;
36   int  rid(const char *r) const;
37
38   size_t left_size() const { return left_.size(); }
39   size_t right_size() const { return right_.size(); }
40
41   const std::map<std::string, int>& left_ids()  const { return left_; }
42   const std::map<std::string, int>& right_ids() const { return right_; }
43
44   bool is_valid(size_t lid, size_t rid) {
45     return (lid >= 0 && lid < left_size() &&
46             rid >= 0 && rid < right_size());
47   }
48 };
49 }
50 #endif