Debian Codegraph @

cuneiform_src/Kern/rling/sources/h/speldict.h

raw symbols SCIP
1 /*
2 Copyright (c) 1993-2008, Cognitive Technologies
3 All rights reserved.
4
5 Разрешается повторное распространение и использование как в виде исходного кода,
6 так и в двоичной форме, с изменениями или без, при соблюдении следующих условий:
7
8 * При повторном распространении исходного кода должны оставаться указанное
9 выше уведомление об авторском праве, этот список условий и последующий
10 отказ от гарантий.
11 * При повторном распространении двоичного кода в документации и/или в
12 других материалах, поставляемых при распространении, должны сохраняться
13 указанная выше информация об авторском праве, этот список условий и
14 последующий отказ от гарантий.
15 * Ни название Cognitive Technologies, ни имена ее сотрудников не могут
16 быть использованы в качестве средства поддержки и/или продвижения
17 продуктов, основанных на этом ПО, без предварительного письменного
18 разрешения.
19
20 ЭТА ПРОГРАММА ПРЕДОСТАВЛЕНА ВЛАДЕЛЬЦАМИ АВТОРСКИХ ПРАВ И/ИЛИ ДРУГИМИ ЛИЦАМИ "КАК
21 ОНА ЕСТЬ" БЕЗ КАКОГО-ЛИБО ВИДА ГАРАНТИЙ, ВЫРАЖЕННЫХ ЯВНО ИЛИ ПОДРАЗУМЕВАЕМЫХ,
22 ВКЛЮЧАЯ ГАРАНТИИ КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНОЙ ЦЕЛИ, НО НЕ
23 ОГРАНИЧИВАЯСЬ ИМИ. НИ ВЛАДЕЛЕЦ АВТОРСКИХ ПРАВ И НИ ОДНО ДРУГОЕ ЛИЦО, КОТОРОЕ
24 МОЖЕТ ИЗМЕНЯТЬ И/ИЛИ ПОВТОРНО РАСПРОСТРАНЯТЬ ПРОГРАММУ, НИ В КОЕМ СЛУЧАЕ НЕ
25 НЕСЁТ ОТВЕТСТВЕННОСТИ, ВКЛЮЧАЯ ЛЮБЫЕ ОБЩИЕ, СЛУЧАЙНЫЕ, СПЕЦИАЛЬНЫЕ ИЛИ
26 ПОСЛЕДОВАВШИЕ УБЫТКИ, СВЯЗАННЫЕ С ИСПОЛЬЗОВАНИЕМ ИЛИ ПОНЕСЕННЫЕ ВСЛЕДСТВИЕ
27 НЕВОЗМОЖНОСТИ ИСПОЛЬЗОВАНИЯ ПРОГРАММЫ (ВКЛЮЧАЯ ПОТЕРИ ДАННЫХ, ИЛИ ДАННЫЕ,
28 СТАВШИЕ НЕГОДНЫМИ, ИЛИ УБЫТКИ И/ИЛИ ПОТЕРИ ДОХОДОВ, ПОНЕСЕННЫЕ ИЗ-ЗА ДЕЙСТВИЙ
29 ТРЕТЬИХ ЛИЦ И/ИЛИ ОТКАЗА ПРОГРАММЫ РАБОТАТЬ СОВМЕСТНО С ДРУГИМИ ПРОГРАММАМИ,
30 НО НЕ ОГРАНИЧИВАЯСЬ ЭТИМИ СЛУЧАЯМИ), НО НЕ ОГРАНИЧИВАЯСЬ ИМИ, ДАЖЕ ЕСЛИ ТАКОЙ
31 ВЛАДЕЛЕЦ ИЛИ ДРУГОЕ ЛИЦО БЫЛИ ИЗВЕЩЕНЫ О ВОЗМОЖНОСТИ ТАКИХ УБЫТКОВ И ПОТЕРЬ.
32
33 Redistribution and use in source and binary forms, with or without modification,
34 are permitted provided that the following conditions are met:
35
36 * Redistributions of source code must retain the above copyright notice,
37 this list of conditions and the following disclaimer.
38 * Redistributions in binary form must reproduce the above copyright notice,
39 this list of conditions and the following disclaimer in the documentation
40 and/or other materials provided with the distribution.
41 * Neither the name of the Cognitive Technologies nor the names of its
42 contributors may be used to endorse or promote products derived from this
43 software without specific prior written permission.
44
45 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
46 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
49 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 */
56
57 /* ------------------------------------------------------------------ *\
58 |* 03-18-93 02:42pm, Mike *|
59 |* *|
60 |* Spelling dictionary project. Release 2.0 *|
61 |* 64-unit alphabet. *|
62 |* *|
63 \* ------------------------------------------------------------------ */
64
65 #ifndef __SPELLDICT_H
66 #define __SPELLDICT_H
67
68 #if _MSC_VER > 1000
69 #pragma once
70 #endif // _MSC_VER > 1000
71 /* ----------------------------------------------------------------- *
72 * File contents: *
73 * *
74 * The first generation of the internal structures of the static *
75 * dictionary. *
76 * *
77 * ------------------------------------------------------------------ *
78 * *
79 * List of types: *
80 * *
81 * TVertP *
82 * TVertV *
83 * TPostfics *
84 * TAccount *
85 * TAddr *
86 * TTailVar *
87 * TShiftType *
88 * TTailSet *
89 * TDictState; *
90 * TBuildInfo; *
91 * *
92 * ------------------------------------------------------------------ */
93
94 /* --- Dictionary constants. ---------------------------------------- */
95
96 #define STAT_DICT_SIGN "CTCDict"
97
98 #ifdef S_COMMENTS
99 #if sizeof( STAT_DICT_SIGN ) > 8
100 #error Check header size for static dictionary.
101 #endif
102 #endif
103
104 #define ABCSIZE 66 /* size of alfabet <= 64 ??? */
105 #define POS_ROOT 0x07 /* mask on 3 first buits in VERTV ??? */
106
107 #define MAX_WORD_SIZE 32 /* Maximal lth of word <-> tree depth */
108 #define MAXLEVEL 2 /* Depth of positional subtree */
109
110 /* --- Key type for search in the dictionary. ----------------------- */
111
112 #define KEYTYPE uchar
113 #define NATURAL uint16_t
114
115 /* --- Positional tree. --------------------------------------------- */
116
117 typedef struct {
118 uint16_t cont :1; /* 20 bits - addr of continuation */
119 uint16_t noterm :1; /* vert isn't terminal in tree */
120 uint16_t exist :1; /* vertex exists */
121 uint16_t shift0 :5; /* first 5 bits & next 8 + 8 bits */
122 uint16_t shift1 :8; /* in 21 bits relative address */
123 uint16_t shift2 :8; /* */
124 } TVertP;
125
126 typedef TVertP * PTVertP;
127
128 /* --- Pointer tree. ------------------------------------------------ */
129
130 typedef struct {
131 uint16_t cont :1; /* if == 1 then this vertex is */
132 /* followed by the continuation */
133 uint16_t noterm :1; /* vert isn't terminal in tree */
134 uint16_t key :6; /* letter no.: 0--63 */
135 } TVertV;
136
137 typedef TVertV * PTVertV;
138
139 /* --- Continuations of vertex. ------------------------------------- */
140
141 typedef struct {
142 uint16_t cont :1; /* continuation exists */
143 uint16_t tail :1; /* =1 (the cont is for tail/accnt) */
144 uint16_t accnt :1; /* =0 - tail, =1 - accnt */
145 uint16_t enter0 :5; /* tail kind number - first 5 bits */
146 uint16_t enter1 :8; /* tail kind number - next 8 bits */
147 } TPostfics;
148
149 typedef TPostfics * PTPostfics;
150
151 typedef struct {
152 uint16_t cont :1; /* continuation exists */
153 uint16_t tail :1; /* =1 (the cont is for tail/accnt) */
154 uint16_t accnt :1; /* =0 - tail, =1 - accnt */
155 uint16_t wrdterm :1; /* if == 1 - vertex may be end of word */
156 uint16_t spare :1; /* spare */
157 uint16_t freq :3; /* frequency of word occurence */
158 } TAccount;
159
160 typedef TAccount * PTAccount;
161
162 typedef struct {
163 uint16_t cont :1; /* continuation exists */
164 uint16_t tail :1; /* = 0 (the cont is for reference) */
165 uint16_t lth :1; /* lth of shift (bytes): 0->1, 1->2/3 */
166 uint16_t shift0 :5; /* first 5 bits or 1-byte shift */
167 uint16_t lth2 :1; /* lth of long shift: = 0 - 2 bytes */
168 uint16_t shift2 :7; /* next 7 bits of shift (lth=1,lth2=0) */
169 uint16_t shift3 :8; /* next 8 bits of shift (lth=1,lth2=1) */
170 } TAddr;
171
172 typedef TAddr * PTAddr;
173
174 /* --- Tail string unit structure. ---------------------------------- */
175
176 typedef struct {
177 uint16_t ch :6; /* character of the tail */
178 uint16_t :1; /* not used */
179 uint16_t tailend :1; /* flag of end of the tail */
180 } TTailSet;
181
182 typedef TTailSet * PTTailSet;
183
184 /* --- Tail rules. -------------------------------------------------- */
185
186 typedef struct {
187 uint16_t tablenum; /* tail table number */
188 uint16_t maxtaillth; /* max lth of tail in the table */
189 uint32_t tailmask; /* mask of tail set variant */
190 } TTailVar;
191
192 typedef TTailVar * PTTailVar;
193
194 typedef uint32_t TShiftType;
195 typedef TShiftType * PTShiftType;
196
197 /* --- Static dictionary control structure type. -------------------- */
198
199 struct dict_state { /* declaration for compatibility... */
200 uchar * root; /* pointer to dictionary tree */
201 uchar * tailset_root; /* pointer to tail set allocation */
202 PTTailVar vartable; /* table of "tail rules" */
203 PTShiftType table; /* table of shifts to "tail strings"*/
204 uint32_t size; /* size of used memory */
205 uint16_t abcSize; /* size of alphabet */
206 };
207
208 typedef struct dict_state TDictState;
209 typedef TDictState * PTDictState;
210
211 /* ------ Static dictionary header mask stucture. ------------------- */
212
213 typedef struct {
214
215 char sign[8]; /* "CTCDict" */
216 char cpuType[8]; /* "Mac" or "Intel" */
217 char language[8]; /* "FRA"/"RUS"/"ENG"/etc. */
218 char version[8]; /* "01.00" */
219 char treeLength[8]; /* RADIX 10 - in bytes */
220 char tailsLength[8]; /* RADIX 10 - in bytes */
221 char rulesLength[8]; /* RADIX 10 - in bytes */
222 char hushLength[8]; /* RADIX 10 - in bytes */
223 char abcSize[8]; /* size of the current alphabet */
224 char abcUpper[64]; /* string of uppercase letters */
225 char abcLower[64]; /* string of lowercase letters */
226
227 } TDictHeaderMask;
228
229 typedef TDictHeaderMask * PTDictHeaderMask;
230
231 /* ------ Dictionary builder information stucture. ------------------ */
232
233 typedef struct { /* -- information about vertex --- */
234 uint16_t key; /* key of vertex */
235 uint16_t levNum; /* absolute level number */
236 uint16_t wordTerm; /* vertex is terminal in a word */
237 uint16_t treeTerm; /* vertex is terminal in the tree */
238 uint16_t levTerm; /* vertex is most right in level */
239 uint16_t tailsNum; /* number of vertex's tails */
240 uint16_t refLth; /* length of reference to brother */
241 uint16_t sonsNum; /* number of vertex's sons */
242 } TBuildInfo;
243
244 typedef TBuildInfo * PTBuildInfo;
245
246 /* ------------------------------------------------------------------ */
247 #endif