23 #ifndef TESS_LANG_MOD_EDGE_H
24 #define TESS_LANG_MOD_EDGE_H
35 #define LEAD_PUNC_EDGE_REF_MASK (inT64) 0x0000000100000000i64
36 #define TRAIL_PUNC_EDGE_REF_MASK (inT64) 0x0000000200000000i64
37 #define TRAIL_PUNC_REPEAT_MASK (inT64) 0xffff000000000000i64
39 #define LEAD_PUNC_EDGE_REF_MASK (inT64) 0x0000000100000000ll
40 #define TRAIL_PUNC_EDGE_REF_MASK (inT64) 0x0000000200000000ll
41 #define TRAIL_PUNC_REPEAT_MASK (inT64) 0xffff000000000000ll
45 #define NUMBER_STATE_SHIFT 0
46 #define NUMBER_STATE_MASK 0x0000000fl
47 #define NUMBER_LITERAL_SHIFT 4
48 #define NUMBER_LITERAL_MASK 0x000000f0l
49 #define NUMBER_REPEAT_SHIFT 8
50 #define NUMBER_REPEAT_MASK 0x00000f00l
52 #define TRAIL_PUNC_REPEAT_SHIFT 48
54 #define IsLeadingPuncEdge(edge_mask) \
55 ((edge_mask & LEAD_PUNC_EDGE_REF_MASK) != 0)
56 #define IsTrailingPuncEdge(edge_mask) \
57 ((edge_mask & TRAIL_PUNC_EDGE_REF_MASK) != 0)
58 #define TrailingPuncCount(edge_mask) \
59 ((edge_mask & TRAIL_PUNC_REPEAT_MASK) >> TRAIL_PUNC_REPEAT_SHIFT)
60 #define TrailingPuncEdgeMask(Cnt) \
61 (TRAIL_PUNC_EDGE_REF_MASK | ((Cnt) << TRAIL_PUNC_REPEAT_SHIFT))
83 inline void SetRoot(
bool flag) { root_ = flag; }
102 inline int ClassID ()
const {
return class_id_; }
128 if (params !=
NULL) {
147 if (params !=
NULL) {
178 inline unsigned int Hash()
const {
179 return static_cast<unsigned int>(
180 ((start_edge_ | end_edge_) ^ ((reinterpret_cast<uintptr_t>(dawg_)))) ^
181 ((
unsigned int)edge_mask_) ^ class_id_);
190 reinterpret_cast<TessLangModEdge *>(lang_mod_edge)->class_id_ &&
191 str_ == reinterpret_cast<TessLangModEdge *>(lang_mod_edge)->str_ &&
192 dawg_ == reinterpret_cast<TessLangModEdge *>(lang_mod_edge)->dawg_ &&
194 reinterpret_cast<TessLangModEdge *>(lang_mod_edge)->start_edge_ &&
196 reinterpret_cast<TessLangModEdge *>(lang_mod_edge)->end_edge_ &&
198 reinterpret_cast<TessLangModEdge *>(lang_mod_edge)->edge_mask_);
218 inline int Cost()
const {
219 if (cntxt_ !=
NULL) {
233 #endif // TESS_LANG_MOD_EDGE_H
unsigned int Hash() const
virtual bool end_of_word(EDGE_REF edge_ref) const =0
#define IsTrailingPuncEdge(edge_mask)
EDGE_REF StartEdge() const
void SetNumWgt(double wgt)
const char_32 * EdgeString() const
TessLangModEdge(CubeRecoContext *cntxt, const Dawg *edge_array, EDGE_REF edge, int class_id)
char * Description() const
void SetEndEdge(EDGE_REF edge_idx)
bool IsIdentical(LangModEdge *lang_mod_edge) const
static int CreateChildren(CubeRecoContext *cntxt, const Dawg *edges, NODE_REF edge_reg, LangModEdge **lm_edges)
EDGE_REF EdgeMask() const
void SetStartEdge(EDGE_REF edge_idx)
void SetEdgeMask(EDGE_REF edge_mask)
TuningParams * Params() const
const Dawg * GetDawg() const
void SetOODWgt(double wgt)
double SignalWgt(int signal) const
virtual NODE_REF next_node(EDGE_REF edge_ref) const =0
void SetSignalWgt(int signal, double wgt)