1 #ifndef __DICTIONARY_H__ // -*- tab-width: 2 mode: c++ -*-
2 #define __DICTIONARY_H__
18 #define sarch get_ngram()
20 namespace Dictionary {
23 typedef int32 VocabIndex
;
24 typedef int32 strid
; // for easy migration
25 #ifndef __MYSTRING_H__
31 strid cid
; // case-insensitive comparision
39 std::vector
<const char *> oov
;
43 bool read(const char *f
);
44 double wordProb(VocabIndex w1
, const VocabIndex
*wcontext
);
45 const lm_t
* get_lm() const { return lm
; }
50 void set_blocked(bool _blocked
);
53 strid
operator[] (const char* s
);
54 strid
operator[] (const std::string
&s
) { return (*this)[s
.c_str()]; }
55 const char* operator[] (strid i
);
56 bool in_dict(const char* s
);
57 bool in_dict(const std::string
&s
) { return in_dict(s
.c_str()); }
58 bool in_dict(strid i
) { return i
< lm3g_word_str_size(lm
); }
63 //strpair make_strpair(strid id);
65 double LogPtoProb(double v
);
67 int viet_toupper(int ch
);
68 int viet_tolower(int ch
);
69 bool viet_isupper(int ch
);
70 bool viet_islower(int ch
);
71 bool viet_isalpha(int ch
);
72 bool viet_isdigit (int ch
);
73 bool viet_isxdigit(int ch
);
74 bool viet_isspace(int ch
);
75 bool viet_ispunct(int ch
);
79 bool is_syllable_exist(strid
);
80 bool is_syllable_exist(const std::string
&syll
);
81 float get_syllable(const std::string
&syll
);
82 bool is_word_exist(const std::string
&word
);
83 float get_word(const std::string
&word
);
87 #define PROPER_NAME_ID 2
94 const std::map
<strid
,strid_string
>& get_pnames();
99 inline bool is_syllable_exist(const std::string
&syll
) {
100 return is_syllable_exist(get_ngram()[syll
]);