~ubuntu-branches/ubuntu/precise/cuneiform/precise

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/hrstr/context.h

  • Committer: Bazaar Package Importer
  • Author(s): Jakub Wilk, c-assert.diff, slovenian-slv.diff
  • Date: 2011-01-26 21:53:07 UTC
  • mfrom: (5.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20110126215307-62x61mcesr607qb7
Tags: 1.0.0+dfsg-2
* Upload to unstable.
* Explicitly build-depend on pkg-config. Thanks to Stefano Rivera for the
  bug report.
* Add Vcs-* fields.
* Use the standard C assert() macro, rather than custom Cuneiform one.
  [c-assert.diff]
* Pass CFLAGS, CXXFLAGS and LDFLAGS (get from dpkg-buildflags) to cmake
  (closes: #608345). Thanks to Sami Liedes for the bug report.
  + Build depend on dpkg-dev (>= 1.15.7).
* Pass --parallel to dh.
  + Bump debhelper minimum version to 7.4.10.
* Update debian/copyright to the latest DEP-5 version.
* Bump year in debian/copyright.
* Explicitly link to GraphicsMagick (rather than via the ImageMagick
  compatibility layer).
* Don't ship /usr/lib/cuneiform/*.so symlinks. These libraries are
  considered private, at least until #598616 is fixed.
* Rename some private variables in debian/rules to make them lowercase.
* Update patch headers.
* Provide proper ‘build-arch’ and ‘build-indep’ targets in debian/rules.
* Document input format in the manual page (closes: #572061). Thanks to
  Janusz S. Bień for the bug report.
* Use ‘slv’ (rather than ‘slo’) as language code for Slovenian.
  [slovenian-slv.diff]
* Fix package description: Slovenian is supported, Slovak is not.
* Improve documentation of the language (-l) option (closes: #602512).
  Thanks to Jari Aalto for the bug report.
* Install reasons file for vrms.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
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
 
 
 
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
 */
57
56
 
58
57
#include <stdlib.h>
59
58
#include <stdio.h>
60
59
#include <string.h>
61
 
#include "nt_types.h"
62
60
#include "struct.h"
63
61
#include "lang.h"
64
62
#include "ligas.h"
70
68
# define    CONT_EXTERN extern
71
69
#endif
72
70
 
73
 
 
74
71
/****** Global Variables: *************/
75
 
extern BYTE language;
76
 
extern INT  line_number;
 
72
extern uchar language;
 
73
extern int16_t line_number;
77
74
 
78
75
/******* Context Internal Type Definitions: **********/
79
76
typedef cell * pCell;
80
 
typedef struct din_var
81
 
 {
82
 
 cell *C;
83
 
 BYTE pos;           // the version number
84
 
 BYTE class;         // the kind of symbol : big, small, digit, empty and undef
85
 
 BYTE first;
86
 
 BYTE res;
87
 
 INT est;            // current estimation
88
 
 INT back;           // refference to previous element
89
 
 } dv;
90
 
 
 
77
typedef struct din_var {
 
78
        cell *C;
 
79
        uchar pos; // the version number
 
80
        uchar class; // the kind of symbol : big, small, digit, empty and undef
 
81
        uchar first;
 
82
        uchar res;
 
83
        int16_t est; // current estimation
 
84
        int16_t back; // refference to previous element
 
85
} dv;
91
86
/*######## Constants Defenitions : ############*/
92
 
 
93
87
#define APOSTROPH       0x27
94
88
#define NEG_HALF_SPACE  0x1e
95
89
#define POS_HALF_SPACE  0x1f
96
90
#define REGULAR_SPACE   0x20
97
 
 
98
91
/*** Words types : *****/
99
 
#define WORD            0x01
 
92
#define UINT            0x01
100
93
#define NUMBER          0x02
101
94
#define UPPER           0x04
102
95
#define LOWER           0x08
104
97
#define AFTERAPOSTROPHE 0x20
105
98
#define COMPLEX         0x40
106
99
#define AFTERDOTCOM     0x80
107
 
 
108
100
#define BAD_SYM                  1
109
101
#define ALPHANUM                 2
110
102
#define SPEC_SYM                 4
111
103
#define DOT_SPACE                8
112
104
#define SPEC_SYM_SLASH        0x10
113
 
 
114
105
#define NOT_EXPECT_DELIM       0x80
115
106
#define DELIM_WORD_IS_POSSIBLE 0x01
116
107
#define DELIM_DIG_IS_POSSIBLE  0x02
117
108
#define DELIM_REGULAR          0x04
118
109
#define REAL_WORD_DELIM        0x10
119
110
#define REAL_DIG_DELIM         0x20
120
 
 
121
111
#define BONUS       16        // bonus for probability
122
112
#define MONUS       50        // antibonus for probability
123
113
#define MONUS1I     20        // antibonus for 1-i-l case
124
114
#define BONUS01      6        // bonus for 0 and 1 for neigboring digits
125
115
#define BONUS_SLASH  30       // bonus or monus for SLASH being between
126
 
                              // two letters
127
 
 
 
116
// two letters
128
117
#define MAX_VERS      8             // maximal number of alternatives
129
118
#define MAX_PROB      254           // maximal probability of letter
130
119
#define MIN_PROB      2             // minimal probability of letter
131
120
#define MAX_SYMB      80            // maximal admissible number of
132
 
                                    // symbols in word
 
121
// symbols in word
133
122
#define MAX_NUM_WORDS (MAX_SYMB/2)  // maximum admissible number of
134
 
                                    // words in line
135
 
 
 
123
// words in line
136
124
#undef COMPLEX_PROT                 /* Complex_word Protocol Flag */
137
 
 
138
125
#define COMP_NVAR     3             // Number of variants in Complex_word
139
 
 
140
126
/***** Complex_word --> Types of conserning symbols: *****/
141
127
#define L_BIG         0
142
128
#define L_SMALL       1
143
129
#define L_NUM         2
144
130
#define L_UNDEF       3
145
131
#define L_EMPTY       4
146
 
 
147
132
/******* Complex_word --> Penalties types: ************/
148
133
#define JMP          35      // Jump penalty (was 25)
149
134
#define JMP_SN        8      // Additional jump penalty
150
 
                             // from small to numeric
 
135
// from small to numeric
151
136
#define ADD_JMP_SN    12     // One more additional jump penalty from small
152
 
                             // to numeric, if small is single version
 
137
// to numeric, if small is single version
153
138
#define NUM_INC       5      // Increase numeric power (was 10)
154
139
#define SMALL_INC     3      // Increase small power
155
 
 
156
140
/******  Context Penalties:  **********/
157
141
#define REFUSE_BOUND     66      // Refuse boundary for version selection
158
 
 
159
142
#define ADM_PROB         120
160
143
#define CONS_VOWEL_JMP   50    // penalty for conson. letter after 'l' and
161
 
                             // for vowel letter after 'I'
 
144
// for vowel letter after 'I'
162
145
#define TITLE_JMP        25      // after dot small letter penalty
163
 
 
164
146
#define BON_DIG_CHAR     50
165
 
 
166
147
#define FRANCH_ART_BONUS   30
167
148
#define GER_DOUBLE_S_MONUS 40
168
149
#define SWED_LJU_BONUS     50
172
153
#define  LOWER_A           'a'
173
154
#define  LOWER_C           'c'
174
155
#define  AFTER_C            1
175
 
 
176
156
/****** Numeral object Processing Variants *********/
177
157
#define VAR_1st      1
178
158
#define VAR_2nd      2
179
159
#define VAR_3rd      4
180
160
#define VAR_09th     8
181
 
 
182
161
#define CONTINUE_ACTION     0
183
162
#define NO_ACTION           1
184
 
 
185
163
/***** Common variables and functions **********/
186
 
CONT_EXTERN BYTE word_flag;
187
 
CONT_EXTERN INT n_ltr;                    // number of letters in word
188
 
CONT_EXTERN INT total_words;
189
 
CONT_EXTERN INT roman_sym_num;
190
 
CONT_EXTERN BYTE swed_lju_flag;
191
 
CONT_EXTERN BYTE fl_beg_irish_name;
 
164
CONT_EXTERN uchar word_flag;
 
165
CONT_EXTERN int16_t n_ltr; // number of letters in word
 
166
CONT_EXTERN int16_t total_words;
 
167
CONT_EXTERN int16_t roman_sym_num;
 
168
CONT_EXTERN uchar swed_lju_flag;
 
169
CONT_EXTERN uchar fl_beg_irish_name;
192
170
 
193
 
void vers_to_first_place     ( cell *A, INT nver);
194
 
INT get_nvers                ( cell *A, INT Let );
195
 
INT check_numb_2_9   (BYTE);
196
 
INT check_numb_0_9   (BYTE);
197
 
INT check_upper      (BYTE);
198
 
INT check_lower      (BYTE);
199
 
INT check_alphanum   (BYTE);
200
 
INT check_lowerconson(BYTE);
 
171
void vers_to_first_place(cell *A, int16_t nver);
 
172
int16_t get_nvers(cell *A, int16_t Let);
 
173
int16_t check_numb_2_9(uchar);
 
174
int16_t check_numb_0_9(uchar);
 
175
int16_t check_upper(uchar);
 
176
int16_t check_lower(uchar);
 
177
int16_t check_alphanum(uchar);
 
178
int16_t check_lowerconson(uchar);
201
179
void test_O_and_slash();
202
 
INT english_context_process     ( cell* C );
203
 
INT franch_context_process      ( cell* C );
204
 
INT german_context_process      ( cell* C );
205
 
INT swedish_context_process     ( cell* C );
206
 
INT spanish_context_process     ( cell* C );
207
 
void test_roma_num_sym          ( cell *C );
208
 
void test_irish_name_cur_sym    ( INT Let );
 
180
int16_t english_context_process(cell* C);
 
181
int16_t franch_context_process(cell* C);
 
182
int16_t german_context_process(cell* C);
 
183
int16_t swedish_context_process(cell* C);
 
184
int16_t spanish_context_process(cell* C);
 
185
void test_roma_num_sym(cell *C);
 
186
void test_irish_name_cur_sym(int16_t Let);
209
187
/*========================================================*/
210
188
 
211
189
#ifdef MAIN_CONTEXT_MODULE
212
 
static INT find_dig_chr_var         ();
213
 
static void make_dig_chr_chain      ();
214
 
static void up_substr               ( PCHAR substr );
215
 
static void up_rest_str             ();
216
 
static INT get_est_substr_in_word   ( PCHAR );
217
 
static INT est_rest_dig             ( dv *);
218
 
static INT test_var                 ( PCHAR );
 
190
static int16_t find_dig_chr_var ();
 
191
static void make_dig_chr_chain ();
 
192
static void up_substr ( pchar substr );
 
193
static void up_rest_str ();
 
194
static int16_t get_est_substr_in_word ( pchar );
 
195
static int16_t est_rest_dig ( dv *);
 
196
static int16_t test_var ( pchar );
219
197
/*****************/
220
198
static dv * cdv, *last_dv, *last_dig_dv, *beg_dv;
221
 
static INT best_l, num_v, admvar = 0, maxest;
222
 
INT delim_flag, possible_delim_flag;
 
199
static int16_t best_l, num_v, admvar = 0, maxest;
 
200
int16_t delim_flag, possible_delim_flag;
223
201
/***********************************************************************/
224
202
 
225
 
cell *WB;                     // first cell in word
226
 
cell *EB;                     // last cell in word
227
 
BYTE after_word_flag;
228
 
BYTE fl_cap_first;            // first letter has capital version flag
229
 
INT num_dig, num_upper, num_lower, num_bad, num_let;
230
 
BYTE   irish_name_pos;
 
203
cell *WB; // first cell in word
 
204
cell *EB; // last cell in word
 
205
uchar after_word_flag;
 
206
uchar fl_cap_first; // first letter has capital version flag
 
207
int16_t num_dig, num_upper, num_lower, num_bad, num_let;
 
208
uchar irish_name_pos;
231
209
static pCell use_word_flags[MAX_NUM_WORDS];
232
210
static pCell pDotComCell;
233
211
 
234
 
 
235
 
static INT find_and_class_word        (cell *);
236
 
static BYTE classify                  (cell *);
237
 
static BOOL find_delim                ( INT  );
238
 
static void set_after_word_flag       ( INT );
239
 
static void set_word_flag             ( INT );
240
 
static void check_vers                (cell *);
241
 
static void set_word_type             ();
242
 
static BOOL real_delim                ();
243
 
static void Livers          (cell *);
244
 
static BOOL Lbs_word        ();
245
 
static void cut_lower_ver   (cell *);
246
 
static BOOL roma_num         (void);
247
 
static BOOL is_roma_num      (void);
248
 
static void make_roma_num    (void);
249
 
static INT best_estimation  (void);
250
 
static void estimate_chain  (INT);
251
 
static void estimate_letter (cell *, INT);
252
 
static INT class_of_letter  (CHAR);
253
 
static void setup_complex   (void);
254
 
static INT make_best_choice (INT);
 
212
static int16_t find_and_class_word (cell *);
 
213
static uchar classify (cell *);
 
214
static Bool find_delim ( int16_t );
 
215
static void set_after_word_flag ( int16_t );
 
216
static void set_word_flag ( int16_t );
 
217
static void check_vers (cell *);
 
218
static void set_word_type ();
 
219
static Bool real_delim ();
 
220
static void Livers (cell *);
 
221
static Bool Lbs_word ();
 
222
static void cut_lower_ver (cell *);
 
223
static Bool roma_num (void);
 
224
static Bool is_roma_num (void);
 
225
static void make_roma_num (void);
 
226
static int16_t best_estimation (void);
 
227
static void estimate_chain (int16_t);
 
228
static void estimate_letter (cell *, int16_t);
 
229
static int16_t class_of_letter (char);
 
230
static void setup_complex (void);
 
231
static int16_t make_best_choice (int16_t);
255
232
/*******************
256
 
static INT is_cons_jmp          ( dv *prv, dv *crn );
257
 
static INT is_vowel_jmp         ( dv *prv, dv *crn );
258
 
********************/
 
233
 static int16_t is_cons_jmp          ( dv *prv, dv *crn );
 
234
 static int16_t is_vowel_jmp         ( dv *prv, dv *crn );
 
235
 ********************/
259
236
#endif