annotate dfa.h @ 2:754a4550c64e

- added arabic, greek, hebrew and turkish DFAs - new UCS-2LE/BE DFAs - now arabic_impl.c uses arabic DFAs - dfa common macros have been moved to dfa.h - minor cleanups
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Wed, 11 Jun 2008 00:11:30 +0900
parents
children 70e2c306231e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1 #ifndef __DFA_H__
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
2 #define __DFA_H__
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
3
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
4 /* data types */
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
5 typedef struct guess_arc_rec
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
6 {
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
7 unsigned int next; /* next state */
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
8 double score; /* score */
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
9 } guess_arc;
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
10
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
11 typedef struct guess_dfa_rec
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
12 {
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
13 signed char (*states)[256];
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
14 guess_arc *arcs;
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
15 int state;
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
16 double score;
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
17 } guess_dfa;
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
18
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
19 /* macros */
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
20 #define DFA_INIT(st, ar) \
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
21 { st, ar, 0, 1.0 }
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
22
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
23 #define DFA_NEXT(dfa, ch) \
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
24 do { \
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
25 int arc__; \
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
26 if (dfa.state >= 0) { \
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
27 arc__ = dfa.states[dfa.state][ch]; \
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
28 if (arc__ < 0) { \
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
29 dfa.state = -1; \
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
30 } else { \
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
31 dfa.state = dfa.arcs[arc__].next; \
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
32 dfa.score *= dfa.arcs[arc__].score; \
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
33 } \
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
34 } \
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
35 } while (0)
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
36
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
37 #define DFA_ALIVE(dfa) (dfa.state >= 0)
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
38
754a4550c64e - added arabic, greek, hebrew and turkish DFAs
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
39 #endif