30
struct TAnony { //Some compiler do not support anonymous defaultly
30
struct TAnony { //Some compiler do not support anonymous defaultly
31
31
#ifdef WORDS_BIGENDIAN
34
unsigned m_csLevel : 2;
35
unsigned m_id : WORD_ID_WIDTH;
34
unsigned m_csLevel : 2;
35
unsigned m_id : WORD_ID_WIDTH;
37
unsigned m_id : WORD_ID_WIDTH;
38
unsigned m_csLevel : 2;
37
unsigned m_id : WORD_ID_WIDTH;
38
unsigned m_csLevel : 2;
45
TWordId() : m_all(0) { }
46
TWordId(const TWordId& b) : m_all(b.m_all) { }
47
TWordId(unsigned id, unsigned cost = 0, unsigned hide = 0, unsigned cslvl = 0)
51
anony.m_bHide= (hide)?1:0;
52
anony.m_csLevel=cslvl;
55
bool operator< (const TWordId& b) const
56
{ return anony.m_id < b.anony.m_id; }
58
bool operator==(const TWordId& b) const
59
{ return anony.m_id == b.anony.m_id; }
61
operator unsigned int() const
62
{ return anony.m_id; }
45
TWordId() : m_all(0) {
47
TWordId(const TWordId &b) : m_all(b.m_all) {
54
anony.m_cost = cost<31? cost: 31;
55
anony.m_bHide = (hide) ? 1 : 0;
56
anony.m_csLevel = cslvl<3? cslvl: 3;
59
bool operator<(const TWordId& b) const
60
{ return anony.m_id < b.anony.m_id; }
62
bool operator==(const TWordId& b) const
63
{ return anony.m_id == b.anony.m_id; }
65
operator unsigned int() const
66
{ return anony.m_id; }
65
69
typedef std::set<TWordId> CWordSet;
70
74
typedef std::vector<std::string> CLexicon;
78
TWordInfo(TWordId id = 0, double cost = 0.0, bool seen=false)
79
: m_id(id), m_cost(cost), m_bSeen(seen)
81
if (m_id.anony.m_bHide) {
84
m_cost = cost + m_id.anony.m_cost;
88
operator< (const TWordInfo& b) const
90
double fa = (m_bSeen)?(m_cost - 5000.0):(m_cost);
91
double fb = (b.m_bSeen)?(b.m_cost - 5000.0):(b.m_cost);
82
TWordInfo(TWordId id = 0, double cost = 0.0, bool seen = false)
83
: m_id(id), m_cost(cost), m_bSeen(seen){
84
if (m_id.anony.m_bHide) {
87
m_cost = cost + m_id.anony.m_cost;
90
bool operator<(const TWordInfo& b) const {
91
double fa = (m_bSeen) ? (m_cost - 5000.0) : (m_cost);
92
double fb = (b.m_bSeen) ? (b.m_cost - 5000.0) : (b.m_cost);
98
99
PNodeSet(const CNodeSet *pns) : m_pns(pns) { }
100
101
PNodeSet(const PNodeSet& another) : m_pns(another.m_pns) { }
103
operator->(void) { return m_pns; }
103
const CNodeSet*operator->(void) { return m_pns; }
106
operator*(void) { return *m_pns; }
105
const CNodeSet&operator*(void) { return *m_pns; }
109
operator< (const PNodeSet& another) const;
108
operator<(const PNodeSet& another) const;
112
111
operator==(const PNodeSet& another) const;
115
114
const CNodeSet * m_pns;
118
117
typedef std::map<PNodeSet, TNode*> CStateMap;
122
static CNodeList m_AllNodes;
125
bool m_bFullSyllableTransfer;
126
CWordSet m_WordIdSet;
121
static CNodeList m_AllNodes;
124
bool m_bFullSyllableTransfer;
125
CWordSet m_WordIdSet;
134
CStateMap m_StateMap;
133
CStateMap m_StateMap;
139
138
CPinyinTrieMaker();
150
149
threadNonCompletePinyin(void);
153
print(FILE* fp, TNode* root, std::string& pinyin);
156
152
write(const char* fileName, CWordEvaluator* psrt, bool revert_endian);
163
159
insertTransfer(TNode* pnode, unsigned s);
166
addCombinedTransfers (TNode *pnode, unsigned s, const CNodeSet& nodes);
162
addCombinedTransfers(TNode *pnode, unsigned s, const CNodeSet& nodes);
169
165
combineInitialTrans(TNode *pnode);