Esempio n. 1
0
cell * create_cell_work(MN * mn, cell * ci, char bdiff, char dflag)
{
 cell * c = new_cell();
 accept_cell (c,(c_comp *)comp_to_kit(mn));
 c->basflg=c->bas1=c->bas2=c->bas3=c->bas4=0;
 c->difflg=dflag;
 c->bdiff=bdiff; c->reasno=0; c->cg_flag=0; c->dens=255;
 if (if_dust(c) & 0x0c)   c->flg=c_f_dust;
 else			c->flg=c_f_bad;
 set_bad_cell(c);
 c->col        += ci->col;
 c->r_col      += ci->r_col;
 c->row        += ci->row;
 c->r_row      += ci->r_row;
 c->env->upper += ci->r_row;
 c->env->left  += ci->r_col;
 if( ci->pos_inc&erect_rot )
   {
   c->pos_inc   = erect_rot;
   c->stick_inc = ci->stick_inc;
   }
 else
   {
   c->stick_inc = NO_INCLINE;
   c->pos_inc   = erect_no;
   }
 insert_cell(c,ci);
 return c;
}
Esempio n. 2
0
cell * create_cell1(MN * mn, cell * ci, char bdiff, char dflag) {
	cell * c = new_cell();
	accept_cell(c, (c_comp *) comp_to_kit(mn));
	c->basflg = c->bas1 = c->bas2 = c->bas3 = c->bas4 = 0;
	c->difflg = dflag;
	c->bdiff = bdiff;
	c->reasno = 0;
	c->cg_flag = 0;
	c->dens = 255;
	if (if_dust(c) & 0x0c)
		c->flg = c_f_dust;
	else
		c->flg = c_f_bad;
	set_bad_cell(c);
	c->pos_inc = erect_no;
	c->accent_leader = 0;
	c->bottom_accent = 0;
	c->n_baton = NO_BATONS;
	c->flg_new = 0;
	c->save_stick_inc = c->stick_inc = NO_INCLINE;
	c->cg_flag_fine = 0;
	c->dupstart = 0;
	c->dupend = 0;
	c->dlang_dup = 0; // Nick 17.02.2001 - was error!
	insert_cell1(c, ci);
	return c;
}
Esempio n. 3
0
static void v2_pidx_crit(CSTR_rast c) {
	int16_t pidx;
	// version *v, *wv;
	UniVersions vers, wvers = { 0 };
	uint16_t let;
	int i, j;
	CSTR_rast_attr attr;

	CSTR_GetAttr(c, &attr);
	CSTR_GetCollectionUni(c, &vers);
	// Paul 07-12-99
	if (vers.lnAltCnt <= 0)
		return;
	//

	attr.reasno = 0;
	pidx = prop_index(attr.h, attr.w);
	// wv = v = c->vers;
	wvers.lnAltMax = REC_MAX_VERS;

	// while (v->let)
	for (i = j = 0; i < vers.lnAltCnt; i++) {
		if (is_cen_language(language) && !attr.accent_leader)
			//let = (wv->let=v->let) * 2;
			let = ((uint16_t) vers.Alt[i].Liga) * 2;
		else
			//let = (let_sans_acc[wv->let=v->let]) * 2;
			let = (let_sans_acc[vers.Alt[i].Liga]) * 2;

		//   wv->prob = v->prob;
		if (pidx + prop_l_delta < letters_pidx_table[let]) {
			attr.reasno |= CSTR_rn_left;
			continue;
		}

		if (pidx - prop_r_delta > letters_pidx_table[let + 1]) {
			attr.reasno |= CSTR_rn_right;
			continue;
		}

		//   v++;
		//   wv++;
		wvers.Alt[j] = vers.Alt[i];
		j++;
	}

	// wv->let = 0;
	CSTR_SetAttr(c, &attr);

	wvers.lnAltCnt = j;

	// if ((c->nvers -= v-wv) == 0)
	if (wvers.lnAltCnt <= 0)
		set_bad_cell(c);
	else
		CSTR_StoreCollectionUni(c, &wvers);
}
Esempio n. 4
0
void sort_vers(cell *c)
 {
 version *v,*vs,*vm;
 uchar l;

 if (c->nvers <= 0)  {set_bad_cell(c); return; }
 for (vs=c->vers+1,vm=c->vers+c->nvers; vs<vm; vs++)
  for (v=vs; v>c->vers && (v-1)->prob<v->prob; v--)
   {
   l=(v-1)->prob;
   (v-1)->prob=v->prob;
   v->prob=l;
   l=(v-1)->let;
   (v-1)->let=v->let;
   v->let=l;
   }
 for (v=vm-1; v>=c->vers && !v->prob; v--,(c->nvers)--) ;
 if (!c->nvers) set_bad_cell(c);
 }
Esempio n. 5
0
static int16_t vers_to_cell(cell *c)
{
 int16_t i;
 c->recsource = 0;
 if ((i=rec_ptr-start_rec) !=0)
  {
   memcpy(c->vers,start_rec,i*sizeof(version)); c->nvers=i;
   c->vers[i].let=0;
   c->flg = c_f_let;
   c->recsource |= c_rs_ev;
   c->history   |= c_rs_ev;
   return i;

  }
 set_bad_cell(c); return 0;
}
Esempio n. 6
0
Bool digital_last_context(void)
{
  cell *curr,*tmp;
  char punct_list[]="'\"=:";
  char sign_list[]="+-_";
  int16_t  l = strlen(punct_list),num,num_dig,num_bad,num_broken;
  uchar c,p;

if( db_status && snap_activity('c') )
 {
 snap_show_text("DIG : Digital last context");
 snap_monitor();
 }

 tmp = cell_f();
  while(   (tmp=tmp->next)->next )
    {
    if( tmp->nvers && tmp->vers[0].prob==2 )
      set_bad_cell(tmp);
    }
  num=num_dig=num_bad=num_broken=0;

  tmp = cell_f();
  while(   (tmp=tmp->next)->next && !(tmp->flg&(c_f_let|c_f_bad)) ); /* find let */
  curr = cell_f();
  if( tmp->next )
  {
  while( (curr=curr->next)!=tmp )
    if( (curr->flg&c_f_punct) &&
       !(curr->nvers>0 && memchr(sign_list,curr->vers[0].let,sizeof(sign_list))) )
      {
      curr = del_cell(curr);        /* kill first punctuation-cell */
      if( curr->next==NULL )break;
      }
  }

  curr = cell_l();
  while(   (curr=curr->prev)->prev && !(curr->flg&(c_f_let|c_f_bad)) ); /* find let */
  if( curr->next )
  {
  while( (curr=curr->next)->next )
    if( (curr->flg&c_f_punct) )
      {
      curr = del_cell(curr);        /* kill last punctuation-cell */
      if( curr->next==NULL )break;
      }

  }

  curr = cell_f();
  while(   (curr=curr->next)->next )
    {
    if( curr->flg&c_f_bad ) num_bad++;
    if( !(curr->flg&(c_f_let|c_f_punct)))  continue;

    c = curr->vers[0].let;
    if( memchr(punct_list,c,l) ||
        c==left_quocket || c==right_quocket ||
        c==low_quotes  // macros E.P.
	)
        {
        curr = del_cell(curr);
        if( curr->next==NULL )break;
        continue;
        }
        /*
    if( !enable_setup_alphabet && !test_alphabet_elem(c) )
        {
        curr = del_cell(curr);
        if( curr->next==NULL )break;
        continue;
        }
         */
    if( (curr->flg&c_f_let) )
      {
      //if( memchr("0123456789ОЃ°ЗІТВшl",c,19) &&
      if( isLikeDigit(c) && // 21.05.2002 E.P.
		  curr->vers[0].prob > 150  // Nick 26.02.2001
		)
		  num_dig++;
      if( memchr("С",c,1) )num_broken++;
      if( curr->flg&c_f_let )num++;
      }
    }

if( digital_mode==2     ||
    num_dig*4>=num*3 ||
    num_dig==2 && num==3 ||
    num_dig==1 && num==1 && num_bad==1 )
  { /* digital string */
  curr = cell_f();
  if( digital_mode==2 )
  while(   (curr=curr->next)->next )
      {
      if( !(curr->flg&(c_f_let|c_f_punct)))  continue;

      c = curr->vers[0].let;
      if ( c==liga_exm || c=='!' )
          curr=del_cell(curr);

      }

  curr = cell_f();
  while(   (curr=curr->next)->next )
      {
      if( curr->nvers<1 )  continue;

      c = curr->vers[0].let;
      p = curr->vers[0].prob;
      if( c==(uchar)'_' )
        curr->vers[0].let='-' ;
      if( c==(uchar)'ш' )
        curr->vers[0].let='2' ;
      if( c==(uchar)'О' ||
			// 21.05.2002 E.P.
			( c==(uchar)'Ѓ')&& !is_russian_turkish_conflict(c)
		)
        curr->vers[0].let='0' ;
      if( c==(uchar)'°' )
        curr->vers[0].let='6' ;
      if( c==(uchar)'З' || c==(uchar)'І')
        curr->vers[0].let='3' ;
      if( c==(uchar)'В' )
        curr->vers[0].let='8' ;
      if( c==(uchar)'С' && (p<190 || num_broken+num_dig==num ) )
        curr->vers[0].let='0' ;
      if( c==(uchar)'Т' || c==liga_exm || c=='!' || c=='|' )
        curr->vers[0].let='1' ;
      if( c==(uchar)'l' )
        curr->vers[0].let='1' ;

      if( c=='$' && curr->nvers==1 )
        {
        curr->vers[0].let='5';
        curr->vers[1].let='$';
        curr->vers[1].prob=curr->vers[0].prob-10;
        curr->nvers=2;
        }

      if( c=='5' && curr->nvers>2 && curr->vers[1].let==(uchar)'°' &&
          p==curr->vers[1].prob && curr->vers[2].let=='6' &&
          curr->vers[2].prob>150 )
          { /* alternates : °56 -->>CONTEXT-->> 5°6 */
          curr->vers[0].let='6';
          curr->vers[2].let='5';
          }
      }
  }

digital_mode=0;
set_all_alphabet();
for(curr=cell_f()->nextl;curr!=cell_l();curr=curr->nextl)
    {
    if( curr->flg&c_f_bad )
        {
        s_glue GL={0};
        short_recog_cell(curr);
        if( curr->nvers<1 )
          {
          GL.celist[0]=curr;
          GL.maxlist[0]=curr;
          GL.complist[0]=curr->env;
          GL.maxlist[1]=GL.celist[1]=NULL;
          GL.complist[1]=NULL;
          GL.ncell=1;
          GL.row   = curr->row; GL.col    = curr->col;
          GL.width = curr->w;   GL.height = curr->h;

          if( crecell(curr,&GL,3)>=0)
            dmBOX(curr,&GL);
          }
        criteria(curr);
        levcut(curr,1);

        if( curr->nvers<1 || curr->vers[0].prob<220 )
          { // restore bad sybmol
          set_bad_cell(curr);
          }

        if( curr->nvers && curr->vers[0].let=='|' )
		{
            curr->vers[0].let='1';

			// Nick add 26.02.2001 - test artificial '1'
			levcut(curr,1);
            if( curr->nvers<1 || curr->nvers==1 && curr->vers[0].let!='1' || curr->vers[0].prob<220 )
			{ // restore bad sybmol
              set_bad_cell(curr);
			}
		}
      }
    }

    for(curr=cell_f()->nextl;curr!=cell_l();curr=curr->nextl)
    {
    if( curr->nvers && curr->vers[0].let=='(' &&
        curr->next &&
        curr->next->nvers && curr->next->vers[0].let==')' )
        {
        clist[0]=curr;
        clist[1]=curr->next;
        compose_cell(2,clist,curr);
        curr->vers[0].let='0';
        curr->vers[1].prob=220;
        curr->nvers=1;
        }
    }

if( db_status && snap_activity('c') )
 {
 snap_show_text("DIG : Digital last context end");
 snap_monitor();
 }

 num_dig = 0;   // Nick 26.02.2001
 num = 0;
 for(curr=cell_f()->nextl;curr!=cell_l();curr=curr->nextl,num++)
 {
 // 21.05.2002 E.P.
 Bool likeDigit = isLikeDigit(curr->vers[0].let);

 if( curr->nvers<1 || curr->vers[0].prob<150 && likeDigit)
    return 0;  // bad symbols or small propability

  if( likeDigit )
	  num_dig++;
 }

 if( num_dig*2 <= num )  // Nick 26.02.2001
	 return 0;

 return 1;
}