terrible bug in PenaltyDAG and Penalty2DAG.
[vspell.git] / libvspell / dictionary.h
blob972780bcb494e2f9c2ed96e914c351ebeb48f18c
1 #ifndef __DICTIONARY_H__ // -*- tab-width: 2 mode: c++ -*-
2 #define __DICTIONARY_H__
4 #ifndef __STRING__
5 #include <string>
6 #endif
7 #ifndef __MAP__
8 #include <map>
9 #endif
10 #include <libsrilm/Vocab.h>
11 #include <libsrilm/Ngram.h>
12 #include "debug.h"
14 #define sarch get_sarch()
16 namespace Dictionary {
19 typedef VocabIndex strid; // for easy migration
20 #ifndef __MYSTRING_H__
21 #include "mystring.h"
22 #endif
24 typedef struct {
25 strid id; // real id
26 strid cid; // case-insensitive comparision
27 } strpair;
29 class StringArchive {
30 private:
31 Vocab dict;
32 Vocab *rest;
33 bool blocked;
35 public:
36 StringArchive():rest(NULL),blocked(false) {}
37 void set_blocked(bool _blocked);
38 Vocab& get_dict() { return dict; }
39 void clear_rest();
41 strid operator[] (VocabString s);
42 strid operator[] (const std::string &s) { return (*this)[s.c_str()]; }
43 VocabString operator[] (strid i);
44 bool in_dict(VocabString s);
45 bool in_dict(const std::string &s) { return in_dict(s.c_str()); }
46 bool in_dict(strid i) { return i < dict.numWords(); }
48 void dump();
51 //strpair make_strpair(strid id);
53 int viet_toupper(int ch);
54 int viet_tolower(int ch);
55 bool viet_isupper(int ch);
56 bool viet_islower(int ch);
57 bool viet_isalpha(int ch);
58 bool viet_isdigit (int ch);
59 bool viet_isxdigit(int ch);
60 bool viet_isspace(int ch);
61 bool viet_ispunct(int ch);
63 bool dic_init();
64 void dic_clean();
65 bool is_syllable_exist(strid);
66 bool is_syllable_exist(const std::string &syll);
67 float get_syllable(const std::string &syll);
68 bool is_word_exist(const std::string &word);
69 float get_word(const std::string &word);
71 #define UNK_ID 0
72 #define PUNCT_ID 1
73 #define PROPER_NAME_ID 2
74 #define START_ID 3
75 #define STOP_ID 4
76 #define POEM_ID 5
77 #define NUMBER_ID 6
78 #define LEAF_ID 7
79 #define TOTAL_ID 8
80 StringArchive& get_sarch();
81 const std::map<strid,strid_string>& get_pnames();
82 Ngram& get_ngram();
83 Ngram& get_syngram();
84 strid get_id(int id);
86 inline bool is_syllable_exist(const std::string &syll) {
87 return is_syllable_exist(get_sarch()[syll]);
94 #endif