~ubuntu-branches/debian/wheezy/cuneiform/wheezy

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/rstr/src/p2_cour.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-07-10 17:58:10 UTC
  • Revision ID: james.westby@ubuntu.com-20090710175810-rqc89d2i3tki9m89
Tags: upstream-0.7.0+dfsg
Import upstream version 0.7.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
//#define _SAVE_INVALID_CLU_
 
58
 
 
59
#include <stdlib.h>
 
60
#include <string.h>
 
61
#include <memory.h>
 
62
/*#include <io.h>*/
 
63
 
 
64
#include "nt_types.h"
 
65
#include "struct.h"
 
66
#include "status.h"
 
67
#include "func.h"
 
68
#include "lang.h"
 
69
#include "cstr.h" // OLEG
 
70
#include "fon.h"
 
71
#include "std.h"
 
72
//#include "linear.h"
 
73
 
 
74
#include "msk.h"
 
75
//#include "r35.h"
 
76
#include "leo.h"
 
77
#include "ctb.h"
 
78
#include "linutil.h"
 
79
extern  char    alphabet[256];
 
80
extern  BYTE    decode_ASCII_to_[256][4];
 
81
static  int            HndTab=0, HndTabInc=0;
 
82
static  char    alpha_str[]="��������������������������������/0123456789��������������������������������#%^()";
 
83
static  char    alpha_str_lat[]="QWERTYUIOPASDFGHJKLZXCVBNM/0123456789qwertyuiopasdfghjklzxcvbnm#%^()";
 
84
static  char    alpha_str_cap[]="��������������������������������";
 
85
static  char    alpha_str_lat_cap[]="QWERTYUIOPASDFGHJKLZXCVBNM";
 
86
static  char    alpha_str_all_cap[]="��������������������������������QWERTYUIOPASDFGHJKLZXCVBNM";
 
87
static  char    alphabet1[256];
 
88
 
 
89
void set_alphabet(unsigned char *alpha,unsigned char *letters)
 
90
{
 
91
memset(alpha,0,256);
 
92
 
 
93
while( *letters )
 
94
    {
 
95
        alpha[ *letters++ ] = 1;
 
96
    }
 
97
return;
 
98
}
 
99
 
 
100
static void print_method(FILE *fp,RecVersions *res,char *s,int ansi)
 
101
{
 
102
int ii;
 
103
fprintf(fp,s);
 
104
if( !res->lnAltCnt )
 
105
    {
 
106
    fprintf(fp,"-\n");
 
107
    return;
 
108
    }
 
109
fprintf(fp,"%c(%d)",ansi?stdAnsiToAscii(res->Alt[0].Code):res->Alt[0].Code,res->Alt[0].Prob);
 
110
for(ii=1;ii<res->lnAltCnt;ii++)
 
111
    {
 
112
    fprintf(fp,",%c(%d)",ansi?stdAnsiToAscii(res->Alt[ii].Code):res->Alt[ii].Code,res->Alt[ii].Prob);
 
113
    }
 
114
fprintf(fp,"\n");
 
115
return;
 
116
}
 
117
 
 
118
Bool32 TestFontProtocol(void)
 
119
 {
 
120
 #ifdef _USE_LEO_
 
121
 Int32          name;
 
122
 int            i; //,j;
 
123
 int            nClust;
 
124
 int            numCourier,nC;
 
125
 FILE          *fp;
 
126
 LeoFieldSetup  fs={0};
 
127
 RecRaster   rec;
 
128
 RecObject   ro={0};
 
129
 LeoPageSetup ps={0};
 
130
 int jj;
 
131
 
 
132
 if( _access("c:\\met.ini",0)==-1 )
 
133
    return FALSE;
 
134
 
 
135
  nClust=FONGetClustCount();
 
136
 
 
137
  set_alphabet(alphabet1, alpha_str);
 
138
 
 
139
  LEOSetPlatform(586);
 
140
  fs.nStyle = LS_PRINT;
 
141
  memcpy(fs.AlphaTable,alphabet1,256);
 
142
  LEOSetupField(&fs);
 
143
  CTB_unlink("CLUST2");
 
144
 
 
145
fp=fopen(".\\clu_met.pro","wt");
 
146
for(i=0,nC=numCourier=0;i<nClust;i++)
 
147
  {
 
148
  for(jj=0;jj<3;jj++)
 
149
        {
 
150
        name=0;
 
151
        FONGetClusterAsBW(&name,i,jj*25,&rec);
 
152
        CTB_AddRecRaster("CLUST2", &rec,decode_ASCII_to_[name][0]);
 
153
        memset(&ro,0,sizeof(RecObject));
 
154
        memcpy(&ro.recData.recRaster,&rec,REC_MAX_RASTER_SIZE);
 
155
        ps.nIdPage=-1;
 
156
        ro.recData.lwStatus=0;
 
157
        LEOSetupPage(&ps);
 
158
        fprintf(fp,"Nclu=%d(%d) let=%c tresh=%d%s\n",i,i*3+jj, name, jj,jj?"":"(default)" );
 
159
 
 
160
        LEORecogPrintChar(&ro);
 
161
        print_method(fp,&ro.recResults,"         leo : ",1);
 
162
 
 
163
 
 
164
        LEORecogPrnMethod( &ro , REC_METHOD_MSK, 1);
 
165
        print_method(fp,&ro.recResults,"         msk : ",0);
 
166
 
 
167
        LEORecogCharDebug( &ro );
 
168
        print_method(fp,&ro.recResults,"     evn+3x5 : ",1);
 
169
        } // end treshold
 
170
    fprintf(fp,"\n");
 
171
    }   // end clusters
 
172
 
 
173
fclose(fp);
 
174
#endif
 
175
return TRUE;
 
176
}
 
177
////////////////
 
178
Bool32 TestFontCourier(void)
 
179
 {
 
180
 #ifdef _USE_LEO_
 
181
 Word8          p;
 
182
 Int32          name;
 
183
 RecRaster      recRast;
 
184
 int            i,j;
 
185
 int            nClust;
 
186
 int            porog=0; // test !!!
 
187
 int            numCourier,nC;
 
188
 
 
189
 RecVersions    MSKres;
 
190
 ClustInfo      clustinfo;
 
191
 Int32          nf=FONGetFontCount();
 
192
 
 
193
  if( nf<1 || nf>2)
 
194
    return FALSE;
 
195
  nClust=FONGetClustCount();
 
196
  if(nClust < 20 )
 
197
    return FALSE;
 
198
 
 
199
  if(!HndTab)
 
200
     return FALSE;
 
201
  MSKSetAlphabet  ( alphabet );
 
202
 
 
203
  for(i=0,nC=numCourier=0;i<nClust;i++)
 
204
  {
 
205
   name=0;
 
206
   j=FONGetClusterAsBW(&name,i,porog,&recRast);
 
207
   if(j<0)
 
208
        continue;
 
209
 
 
210
   if( name>'9' && name<128 )
 
211
        continue;
 
212
   clustinfo.let = 0;  // from all clusters
 
213
   FONGetClustInfo( &clustinfo, i+1 );
 
214
   if( clustinfo.weight<3 )
 
215
        continue;
 
216
   if(0)
 
217
    CTB_AddRecRaster("CLUST2", &recRast,decode_ASCII_to_[name][0]);
 
218
   MSKres.lnAltCnt=2;
 
219
   MSKres.lnAltMax=REC_MAX_VERS;
 
220
   MSKres.Alt[0].Code=(Word8)to_upper((Word8)name);
 
221
   MSKres.Alt[0].Prob=255;
 
222
   MSKres.Alt[1].Code=(Word8)to_lower((Word8)name);
 
223
   MSKres.Alt[1].Prob=255;
 
224
 
 
225
   if(!MSKRecogCharExp( HndTab, &recRast,       &MSKres )  )
 
226
            continue;
 
227
   p = MAX(MSKres.Alt[0].Prob,MSKres.Alt[1].Prob);
 
228
   if( p> 150)
 
229
       numCourier++;
 
230
    nC++;
 
231
  }
 
232
 
 
233
  if(numCourier*3 > nC*2)
 
234
    return TRUE;
 
235
#endif
 
236
  return FALSE;
 
237
}
 
238
////////////////////////
 
239
static int curNumFile=0;
 
240
static Word8 hasNearSame[]="\xa7\xed";  // ��
 
241
static Word8 NearSame[]="\xed\xa7";     // ��
 
242
Int32 TestFontClusters(void)
 
243
 {
 
244
 #ifdef _USE_LEO_
 
245
 Int32          name;
 
246
 int            i,j;
 
247
 int            nClust;
 
248
 int            porog=50; // test !!!
 
249
 int            numInvalid;
 
250
 
 
251
 LeoFieldSetup  fs={0};
 
252
 RecRaster   rec;
 
253
 RecObject   ro={0};
 
254
 LeoPageSetup ps={0};
 
255
 ClustInfo cluInfo;
 
256
 Word8 addLet,resLet;
 
257
 
 
258
#ifdef _SAVE_INVALID_CLU_
 
259
 FILE          *fp;
 
260
#endif
 
261
 
 
262
  curNumFile++;
 
263
 
 
264
  nClust=FONGetClustCount();
 
265
  set_alphabet(alphabet1, alpha_str);
 
266
 
 
267
#ifdef _SAVE_INVALID_CLU_
 
268
  fp=fopen("clust.tst","at");
 
269
  fprintf(fp,"file %d\n",curNumFile);
 
270
#endif
 
271
 
 
272
  LEOSetPlatform(LEOGetCPU());
 
273
  fs.nStyle = LS_PRINT;
 
274
  memcpy(fs.AlphaTable,alphabet1,256);
 
275
  LEOSetupField(&fs);
 
276
 
 
277
  for(i=0,numInvalid=0;i<nClust;i++)
 
278
  {
 
279
    cluInfo.let = 0;
 
280
    j=FONGetClustInfo(&cluInfo,i+1);
 
281
    if(j<=0)
 
282
         continue;
 
283
 
 
284
        if(cluInfo.attr & CTB_PRINT_ITALIC)
 
285
                 continue;
 
286
 
 
287
        if(cluInfo.attr & CTB_PRINT_BOLD)
 
288
                 continue;
 
289
 
 
290
        // now - test only russian ASCII letters
 
291
        if(cluInfo.let < 128 ||
 
292
           cluInfo.let >= 176 && cluInfo.let < 224 ||
 
293
           cluInfo.let > 240
 
294
           )
 
295
           continue;
 
296
 
 
297
        addLet=(cluInfo.let < 144 ? cluInfo.let +32 :
 
298
                cluInfo.let < 160 ? cluInfo.let +80 :
 
299
                cluInfo.let < 176 ? cluInfo.let -32 :
 
300
                cluInfo.let - 80
 
301
               );
 
302
 
 
303
 
 
304
    name=0;
 
305
    FONGetClusterAsBW(&name,i,porog,&rec);
 
306
 
 
307
    memset(&ro,0,sizeof(RecObject));
 
308
        memcpy(&ro.recData.recRaster,&rec,sizeof(RecRaster));
 
309
    ps.nIdPage=-1;
 
310
    ro.recData.lwStatus=0;
 
311
    LEOSetupPage(&ps);
 
312
 
 
313
    LEORecogPrintChar(&ro);
 
314
 
 
315
    // ������ �������� �� LEO ?
 
316
    if( ro.recResults.lnAltCnt <= 0 ||
 
317
        ro.recResults.Alt[0].Prob < 150
 
318
      )
 
319
          continue;
 
320
 
 
321
    for(j=0;j<ro.recResults.lnAltCnt;j++)
 
322
        {
 
323
         resLet = stdAnsiToAscii(ro.recResults.Alt[j].Code);
 
324
 
 
325
         if( resLet == cluInfo.let ||
 
326
             resLet == addLet )
 
327
                 break;
 
328
        }
 
329
 
 
330
    if(j==0)
 
331
                continue;
 
332
 
 
333
        { char *qq;
 
334
 
 
335
          resLet = stdAnsiToAscii(ro.recResults.Alt[0].Code);
 
336
          if( !is_lower(resLet) )
 
337
               resLet =  to_lower(resLet);
 
338
          if( (qq=strchr(hasNearSame,cluInfo.let)) &&
 
339
                  NearSame[qq-(char*)hasNearSame] == resLet
 
340
                )
 
341
                continue;
 
342
        }
 
343
 
 
344
        // �������� ��� ���-�� ���� ?
 
345
        // ���� ������ �� ������������ - ������ ('�' � sten91)
 
346
     if( j >= ro.recResults.lnAltCnt ||
 
347
         ro.recResults.Alt[j].Prob < 180 ||
 
348
         ro.recResults.Alt[j].Prob < 220 &&
 
349
         ro.recResults.Alt[j].Prob + 25 < ro.recResults.Alt[0].Prob
 
350
       )
 
351
     {
 
352
     FonTestInfo testInfo[MAXCHECKALT];
 
353
 
 
354
         // ��������
 
355
     resLet = stdAnsiToAscii(ro.recResults.Alt[0].Code);
 
356
     j=FONTestChar(&rec,resLet,testInfo,0);
 
357
 
 
358
     if( j <=0 || testInfo[0].prob <= 215 )
 
359
         {
 
360
        resLet=(resLet < 144 ? resLet +32 :
 
361
                resLet < 160 ? resLet +80 :
 
362
                resLet < 176 ? resLet -32 :
 
363
                resLet - 80
 
364
               );
 
365
        j=FONTestChar(&rec,resLet,testInfo,0);
 
366
         }
 
367
 
 
368
      if( j > 0 && testInfo[0].prob > 215 )
 
369
      {
 
370
       numInvalid++;
 
371
       FONSetClusterInvalid(i+1);
 
372
#ifdef _SAVE_INVALID_CLU_
 
373
          fprintf(fp,"    invalid %d (%c -> %c(%d))\n",i+1,cluInfo.let,
 
374
                 stdAnsiToAscii(ro.recResults.Alt[0].Code),
 
375
                 ro.recResults.Alt[0].Prob);
 
376
#endif
 
377
      }
 
378
         } // end if j
 
379
 
 
380
  }   // end clusters
 
381
 
 
382
 
 
383
 
 
384
#ifdef _SAVE_INVALID_CLU_
 
385
 fclose(fp);
 
386
#endif
 
387
 
 
388
 return numInvalid;
 
389
#else
 
390
 return 0;
 
391
#endif
 
392
}
 
393
////////////////
 
394
 
 
395
Bool32 RecogLEOcap(RecRaster *Rs,Word8 Language,RecVersions *Vs)
 
396
 {
 
397
 #ifdef _USE_LEO_
 
398
 LeoFieldSetup  fs={0};
 
399
 RecObject      ro={0};
 
400
 LeoPageSetup   ps={0};
 
401
 char    *      alpha;
 
402
 
 
403
 switch(Language)
 
404
    {
 
405
    case LANG_RUSSIAN:
 
406
        alpha = alpha_str_cap;
 
407
        break;
 
408
    case LANG_ENGLISH:
 
409
        alpha = alpha_str_lat_cap;
 
410
        break;
 
411
    default:
 
412
        alpha = alpha_str_all_cap;
 
413
        break;
 
414
    }
 
415
 
 
416
  set_alphabet(alphabet1, alpha);
 
417
 
 
418
  LEOSetPlatform(586);
 
419
  fs.nStyle = LS_PRINT;
 
420
  memcpy(fs.AlphaTable,alphabet1,256);
 
421
  LEOSetupField(&fs);
 
422
 
 
423
        memset(&ro,0,sizeof(RecObject));
 
424
        memcpy(&ro.recData.recRaster,Rs,REC_MAX_RASTER_SIZE);
 
425
        ps.nIdPage=-1;
 
426
        ro.recData.lwStatus=0;
 
427
        LEOSetupPage(&ps);
 
428
 
 
429
        LEORecogPrintChar(&ro);
 
430
        memcpy(Vs,&ro.recResults,sizeof(RecVersions));
 
431
#endif
 
432
return TRUE;
 
433
}
 
434
 
 
435
Bool32 RecogLEO(RecRaster *Rs,Word8 Language,UniVersions *Us)
 
436
 {
 
437
 #ifdef _USE_LEO_
 
438
 LeoFieldSetup  fs={0};
 
439
 RecObject      ro={0};
 
440
 LeoPageSetup   ps={0};
 
441
 char    *      alpha;
 
442
 Word8          c, cw;
 
443
 Int32          i, up=-1;
 
444
 
 
445
 
 
446
  alpha = alpha_str;
 
447
  set_alphabet(alphabet1, alpha);
 
448
 
 
449
  LEOSetPlatform(586);
 
450
  fs.nStyle = LS_PRINT;
 
451
  memcpy(fs.AlphaTable,alphabet1,256);
 
452
  LEOSetupField(&fs);
 
453
 
 
454
        memset(&ro,0,sizeof(RecObject));
 
455
        memcpy(&ro.recData.recRaster,Rs,REC_MAX_RASTER_SIZE);
 
456
        ps.nIdPage=-1;
 
457
        ro.recData.lwStatus=0;
 
458
        LEOSetupPage(&ps);
 
459
 
 
460
        LEORecogPrintChar(&ro);
 
461
//        memcpy(Vs,&ro.recResults,sizeof(RecVersions));
 
462
        if( Us->lnAltCnt )
 
463
            {
 
464
            c = Us->Alt[0].Liga     ;
 
465
            if( is_upper(c) )
 
466
                up=1;
 
467
            else  if( is_lower(c) )
 
468
                up=0;
 
469
            }
 
470
        Us->lnAltCnt=ro.recResults.lnAltCnt;
 
471
        Us->lnAltMax=REC_MAX_VERS;
 
472
 
 
473
        for(i=0;i<ro.recResults.lnAltCnt;i++)
 
474
            {
 
475
            c  = stdAnsiToAscii( ro.recResults.Alt[i].Code);
 
476
            switch( up )
 
477
                {
 
478
                case    1: // upper
 
479
                    c=to_upper(c);
 
480
                    break;
 
481
                case    0: // lower
 
482
                    c=to_lower(c);
 
483
                    break;
 
484
                default:
 
485
                    break;
 
486
                }
 
487
            cw = stdAsciiToAnsi( c );
 
488
            Us->Alt[i].Code[0]=cw;
 
489
            Us->Alt[i].Code[1]=0;
 
490
            Us->Alt[i].Liga=c;
 
491
            Us->Alt[i].Charset=CSTR_RUSSIAN_CHARSET;
 
492
            Us->Alt[i].Method =REC_METHOD_LEO;
 
493
            Us->Alt[i].Prob   = ro.recResults.Alt[i].Prob ;
 
494
            }
 
495
#endif
 
496
return TRUE;
 
497
}
 
498
 
 
499
Bool32  p2_msk_init()
 
500
{
 
501
#ifdef _USE_MSK_
 
502
HndTab=MSKInit( NULL, "rec4cour.dat");
 
503
HndTabInc=MSKInit( NULL, "rec4inc.dat");
 
504
#endif
 
505
return HndTab;
 
506
}
 
507
 
 
508
void    p2_msk_done(void)
 
509
{
 
510
#ifdef _USE_MSK_
 
511
MSKDone();
 
512
#endif
 
513
return;
 
514
}
 
515
 
 
516
#define MIN_MSK_PROB        207
 
517
#define MIN_MSK_PROB_SIM    230
 
518
static char similar_letters[]="����Ꭾ��";
 
519
Bool32   p2_msk_inc(CSTR_rast    rst)
 
520
{
 
521
#ifdef _USE_MSK_
 
522
Word8       prob=0, name, lim, code;
 
523
RecRaster   rc;
 
524
RecVersions ver;
 
525
Int32       i;
 
526
 
 
527
if(!HndTabInc )
 
528
     return 0;
 
529
if(language!=LANG_RUSSIAN && language!=LANG_RUSENG )
 
530
     return 0;
 
531
CSTR_GetImage(rst,(Word8*)&rc,CSTR_TYPE_IMAGE_RS);
 
532
if( !rc.lnPixHeight || !rc.lnPixWidth )
 
533
     return 0;
 
534
MSKSetAlphabet  ( alphabet );
 
535
 
 
536
CSTR_GetCollection(rst,&ver);
 
537
ver.lnAltCnt=2;
 
538
ver.lnAltMax=REC_MAX_VERS;
 
539
name = ver.Alt[0].Code;
 
540
ver.Alt[0].Code=(Word8)to_upper((Word8)name);
 
541
ver.Alt[0].Prob=255;
 
542
ver.Alt[1].Code=(Word8)to_lower((Word8)name);
 
543
ver.Alt[1].Prob=255;
 
544
if( name=='0' )
 
545
    {
 
546
    ver.Alt[1].Code=(Word8)'�';
 
547
    ver.Alt[2].Code=(Word8)'�';
 
548
    ver.Alt[2].Prob=255;
 
549
    ver.lnAltCnt=3;
 
550
    }
 
551
if( name=='3' )
 
552
    {
 
553
    ver.Alt[1].Code=(Word8)'�';
 
554
    ver.Alt[2].Code=(Word8)'�';
 
555
    ver.Alt[2].Prob=255;
 
556
    ver.lnAltCnt=3;
 
557
    }
 
558
if( !MSKRecogCharExpPuma( HndTabInc, &rc, &ver,1 ) )
 
559
    return 0;
 
560
if( !ver.lnAltCnt )
 
561
    return 0;
 
562
 
 
563
for(prob=0, i=0;i<ver.lnAltCnt;i++)
 
564
    {
 
565
    if( prob<ver.Alt[i].Prob)
 
566
        {
 
567
        prob=ver.Alt[i].Prob ;
 
568
        code=ver.Alt[i].Code;
 
569
        }
 
570
    }
 
571
lim = MIN_MSK_PROB;
 
572
if( strchr(similar_letters,code) )
 
573
    lim = MIN_MSK_PROB_SIM;
 
574
return (prob>lim);
 
575
#else
 
576
return FALSE;
 
577
#endif
 
578
}
 
579
 
 
580
 
 
581
Bool32 RecogLEO_SetAlphabet(char *letters)
 
582
{
 
583
    set_alphabet(alphabet1, letters);
 
584
    return TRUE;
 
585
}
 
586
 
 
587
Bool32 RecogLEOall(RecRaster *Rs,RecVersions *Us,Int32 nType)
 
588
 {
 
589
 #ifdef _USE_LEO_
 
590
 LeoFieldSetup  fs={0};
 
591
 RecObject      ro={0};
 
592
 LeoPageSetup   ps={0};
 
593
 
 
594
  fs.nStyle = LS_PRINT;
 
595
  memcpy(fs.AlphaTable,alphabet1,256);
 
596
  LEOSetupField(&fs);
 
597
  memset(&ro,0,sizeof(RecObject));
 
598
  memcpy(&ro.recData.recRaster,Rs,REC_MAX_RASTER_SIZE);
 
599
  ps.nIdPage=-1;
 
600
  ro.recData.lwStatus=0;
 
601
  LEOSetupPage(&ps);
 
602
 
 
603
  if( nType==0 )
 
604
  {
 
605
      LEORecogPrintChar(&ro);
 
606
  }
 
607
 
 
608
  *Us=ro.recResults;
 
609
#endif
 
610
return TRUE;
 
611
}