File: trans.c

package info (click to toggle)
juman 7.0-3.2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 40,220 kB
  • ctags: 1,474
  • sloc: sh: 10,168; ansic: 9,955; perl: 5,194; makefile: 745
file content (709 lines) | stat: -rw-r--r-- 19,081 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
/*
==============================================================================
	trans.c
		1990/11/12/Mon Yutaka MYOKI(Nagao Lab., KUEE)
==============================================================================
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include 	"makeint.h"

#define         MRPH_BUF_MAX   1000
#define         KEITAISO_NUM_MAX  20
/*
------------------------------------------------------------------------------
	GLOBAL:
	definition of global variables
------------------------------------------------------------------------------
*/

extern char	*ProgName;
extern char	CurPath[FILENAME_MAX];
extern char	JumanPath[FILENAME_MAX];
extern CLASS	Class[CLASSIFY_NO + 1][CLASSIFY_NO + 1];
extern TYPE	Type[TYPE_NO];
extern FORM	Form[TYPE_NO][FORM_NO];
extern int	LineNo;
extern int	LineNoForError;

/*
------------------------------------------------------------------------------
	LOCAL:
	definition of global variables
------------------------------------------------------------------------------
*/

static 	MRPH 		mrph;
static  MRPH            mrph_buffer[MRPH_BUF_MAX];
static  int             mrph_buffer_num;

enum	ErrorCode	{NotList, IllegalForm, ConflictGobi,
			   NoMidasi, LongMidasi, 
			   NoYomi,   LongYomi, 
			   NoKatuyou,IllegalWeight,
			   LongRengo,ShortRengo,
                           NoKatuyoukei,HankakuChr};

/*
------------------------------------------------------------------------------
	PROCEDURE:
	<init_mrph>:
------------------------------------------------------------------------------
*/

static void init_mrph(MRPH *mrph_p)
{
     mrph_p->hinsi    = 0;
     mrph_p->bunrui   = 0;
     mrph_p->katuyou1 = 0;
     mrph_p->katuyou2 = 0;
     mrph_p->weight   = 0;
     mrph_p->con_tbl  = 0;
}

/*
------------------------------------------------------------------------------
	PROCEDURE:
	<print_mrph>:
------------------------------------------------------------------------------
*/

static void output_mrph(FILE *fp, MRPH *mrph_p)
{
    long       imiptr;

    /*登録データのフォーマット
      [品詞,細分類,活用型,活用形,重み,アドレス,意味(後回し),読み] */
	
    numeral_encode(fp, mrph_p->hinsi);
    numeral_encode(fp, mrph_p->bunrui);
    numeral_encode(fp, mrph_p->katuyou1);
    numeral_encode(fp, mrph_p->katuyou2);
    numeral_encode(fp, mrph_p->weight);
    numeral_encode2(fp, mrph_p->con_tbl);
    hiragana_encode(fp, mrph_p->yomi);

    /* 意味情報の書き込み */
    if (!Null(mrph_p->imi))
	imi_print(fp, mrph_p->imi);
}

static void numeral_encode(FILE *fp, int num)
{
    if (num == atoi(RENGO_ID)) fputc(0xff, fp);
    else if (num < 0xf0-0x20) fputc(num+0x20, fp);
    else {
	fputc(num/(0xf0-0x20)+0xf0, fp);
	fputc(num%(0xf0-0x20)+0x20, fp);
    }
}

static void numeral_encode2(FILE *fp, int num)
{
    fputc((num+1)/(0x100-0x20)+0x20, fp);
    fputc((num+1)%(0x100-0x20)+0x20, fp);
}

static void hiragana_encode(FILE *fp, unsigned char *str)
{
    if (*str != '@') /* 空列でない場合 */
	fprintf(fp, "%s", str);
    fputc(0x20, fp);
}

static void imi_print(FILE *fp, CELL *cell)
{
    char buf[BUFSIZE];

    buf[0] = '\0';
    _imi_print(buf, cell);
    numeral_encode(fp, strlen(buf));
    fprintf(fp, "%s", buf);
}

static void _imi_print(char *buf, CELL *cell)
{
    if (Null(cell))
	strcat(buf, NILSYMBOL);
    else {
	switch (_Tag(cell)) {
	case CONS:
	    strcat(buf, "(");
	    _imi_print(buf, _Car(cell));
	    _imi_print_cdr(buf, _Cdr(cell));
	    strcat(buf, ")");
	    break;
	case ATOM:
	    strcat(buf, _Atom(cell));
	    break;
	default:
	    error(OtherError, "Illegal cell(in s_print)", EOA);
	}
    }
}

static void _imi_print_cdr(char *buf, CELL *cell)
{
     if (!Null(cell)) {
	 if (Consp(cell)) {
	     strcat(buf, " ");
	     _imi_print(buf, _Car(cell));
	     _imi_print_cdr(buf, _Cdr(cell));
	 } else {
	     strcat(buf, " ");
	     _imi_print(buf, cell);
	 }
     }
}

static void print_mrph(MRPH *mrph_p) /* by yamaji */
{
    mrph_buffer[mrph_buffer_num++] = *mrph_p;
    if (mrph_buffer_num == MRPH_BUF_MAX) error_in_trans(LongRengo , NULL);
}

static void print_mrph_loop(MRPH *mrph_p) /* by yamaji */
{
     int i;
     MRPH mrph_t;

     for ( i=1; Form[mrph_p->katuyou1][i].name; i++ ) {
	  if ( strlen(Form[mrph_p->katuyou1][i].gobi) ) {
	      mrph_t = *mrph_p;
	      mrph_t.katuyou2 = i;
	      strcpy(mrph_t.midasi , Form[mrph_p->katuyou1][i].gobi);
	      strcpy(mrph_t.yomi   , Form[mrph_p->katuyou1][i].gobi_yomi);
	      mrph_t.con_tbl += (i - 1);
	      print_mrph(&mrph_t);
	  }
     }
}

/*
------------------------------------------------------------------------------
	PROCEDURE:
	<error_in_trans>: local error processing
------------------------------------------------------------------------------
*/

static void error_in_trans(int n, void *c)
{
     fprintf(stderr, "\n%s: syntax error between line %d and %d.\n",
	     ProgName, LineNoForError, LineNo);
     switch (n) {
     case NotList:
	  fprintf(stderr, "\tis not list: ");
	  s_print(stderr, (CELL *)c);
	  break;
     case IllegalForm:
	  fprintf(stderr, "\tLIST for morpheme contains illegal form: ");
	  s_print(stderr, (CELL *)c);
	  break;
     case NoMidasi:
	  fprintf(stderr, 
		  "\tLIST for morpheme don't contain the list for MIDASI.\n");
	  s_print(stderr, (CELL *)c);
	  break;
     case LongMidasi:
	  fprintf(stderr, 
		  "\tMIDASI is too long: %s\n", (U_CHAR *)c);
	  break;
     case NoYomi:
	  fprintf(stderr, 
		  "\tLIST for morpheme don't contain the list for YOMI\n");
	  s_print(stderr, (CELL *)c);
	  break;
     case LongYomi:
	  fprintf(stderr,
		  "\tYOMI is too long: %s\n", (U_CHAR *)c);
	  break;
     case NoKatuyou:
	  fprintf(stderr, 
		  "\tLIST for morpheme don't contain the list for KATUYOU.\n");
	  s_print(stderr, (CELL *)c);
	  break;
     case ConflictGobi:
	  fprintf(stderr, 
		  "\tConflicting between <midasigo> and <katuyoukata>:");
	  fprintf(stderr, "%s\n", (U_CHAR *)c);
	  break;
     case IllegalWeight:
	  fprintf(stderr, 
		  "\t0.0 <= weight <= 25.6:");
	  s_print(stderr, (CELL *)c);
	  break;
     case LongRengo:
	  fprintf(stderr,
		  "\tRENGO is too long\n");
     case ShortRengo:
	  fprintf(stderr,
		  "\tRENGO is too short\n");
	  break;
     case NoKatuyoukei:
	  fprintf(stderr, 
		  "\tLIST for RENGO don't contain the list for KATUYOUKEI.:");
	  fprintf(stderr, "%s\n", (U_CHAR *)c);
	  break;
     case HankakuChr:
	  fprintf(stderr, "\tLIST for morpheme contains HANKAKU character: ");
	  fprintf(stderr, "%s\n", (U_CHAR *)c);
	  break;
     default:
	  error(ProgramError, "error_in_trans received an unexpected code.");
	  break;
     }

     my_exit(DicError);
}

/*
------------------------------------------------------------------------------
	FUNCTION:	** not used now ** 1992/9/10
	<midasi>: sub-routine of <trans>
------------------------------------------------------------------------------
*/

static U_CHAR *midasi(CELL *x)
{
     CELL	*y;
     U_CHAR	*s;

     if (Null(y = assoc(tmp_atom((U_CHAR *)"見出し語"), x)))
	  error_in_trans(NoMidasi, x);
     if (!Atomp(car(cdr(y)))) 
	  error_in_trans(IllegalForm, y);

     s = (U_CHAR *)_Atom(car(cdr(y)));
     if (hankaku_check(s)) error_in_trans(HankakuChr, s);

     if (strlen(s) > MIDASI_MAX)
	  error_in_trans(LongMidasi, s);

     return s;
}

/*
------------------------------------------------------------------------------
	FUNCTION:
	<midasi_list>: sub-routine of <trans>
------------------------------------------------------------------------------
*/

static CELL *midasi_list(CELL *x)
{
     CELL	*y;
     U_CHAR	*s;

     if (Null(y = assoc(tmp_atom((U_CHAR *)"見出し語"), x)))
	  error_in_trans(NoMidasi, x);

     return cdr(y);
}

/*
------------------------------------------------------------------------------
	FUNCTION
	<yomi>: sub-routine of <trans>
------------------------------------------------------------------------------
*/

static U_CHAR *yomi(CELL *x)
{
     CELL	*y;
     U_CHAR	*s;

     if (Null(y = assoc(tmp_atom((U_CHAR *)"読み"), x)))
	  error_in_trans(NoYomi, x);
     if (!Atomp(car(cdr(y))))
	  error_in_trans(IllegalForm, y);

     s = (U_CHAR *)_Atom(car(cdr(y)));
     if (hankaku_check(s)) error_in_trans(HankakuChr, s);

     if (strlen(s) > YOMI_MAX)
	  error_in_trans(LongYomi, s);

     return s;
}

/*
------------------------------------------------------------------------------
	FUNCTION:
	<katuyou1>: sun-routine of <trans>
------------------------------------------------------------------------------
*/

static int katuyou1(CELL *x)
{
    CELL	*y;
    int	i;

    if (Null(y = assoc(tmp_atom((U_CHAR *)"活用型"), x)))
      error_in_trans(NoKatuyou, x);
    if (!Atomp(car(cdr(y))))
      error_in_trans(IllegalForm, y);
    
    return get_type_id(_Atom(car(cdr(y))));
}

/*
------------------------------------------------------------------------------
	FUNCTION:
	<katuyou2>: sun-routine of <trans>
------------------------------------------------------------------------------
*/

static int katuyou2(CELL *x , int type)
{
    CELL	*y;
    int	i;

    if (Null(y = assoc(tmp_atom((U_CHAR *)"活用形"), x)))
      error_in_trans(NoKatuyou, x);
    if (!Atomp(car(cdr(y))))
      error_in_trans(IllegalForm, y);
    
    return get_form_id(_Atom(car(cdr(y))) , type);
}

/* for EDRdic '94.Mar */
/*
------------------------------------------------------------------------------
        FUNCTION:
        <edrconnect>: sub-routine of <trans>
------------------------------------------------------------------------------
*/

static CELL *edrconnect(CELL *x)
{
     CELL       *y;

     y = assoc(tmp_atom((U_CHAR *)"連接属性"), x);
     return car(cdr(y));
}

/*
------------------------------------------------------------------------------
	FUNCTION:
	<imi>: sub-routine of <trans>
------------------------------------------------------------------------------
*/

static CELL *imi(CELL *x)
{
     CELL	*y;

     y = assoc(tmp_atom((U_CHAR *)"意味情報"), x);
     return car(cdr(y));
}

/*
------------------------------------------------------------------------------
	PROCEDURE:
	<trim_yomi_gobi> <trim_midasi_gobi>: sub-routine of <trans>
------------------------------------------------------------------------------
*/

static void trim_yomi_gobi(MRPH *mrph_p)
{
     U_CHAR	*str = (U_CHAR *)"基本形";
     int	i;

     for (i = 1; strcmp(Form[mrph_p->katuyou1][i].name, str); i++);

     mrph_p->yomi[strlen(mrph_p->yomi) - 
		  strlen(Form[mrph_p->katuyou1][i].gobi_yomi)]='\0';
}

static void trim_midasi_gobi(MRPH *mrph_p)
{
    U_CHAR	*str = (U_CHAR *)"基本形";
    int	i;
    
    for (i = 1; strcmp(Form[mrph_p->katuyou1][i].name, str); i++);
    
    if (compare_end_str(mrph_p->midasi, Form[mrph_p->katuyou1][i].gobi))
      mrph_p->midasi[strlen(mrph_p->midasi) - 
		    strlen(Form[mrph_p->katuyou1][i].gobi)]='\0';
    else
      error_in_trans(ConflictGobi, mrph_p->midasi);
}

/*
------------------------------------------------------------------------------
	FUNCTION:
	<hankaku_check>: sub-routine of <trans>
------------------------------------------------------------------------------
*/

int hankaku_check(U_CHAR *s)
{
#ifdef IO_ENCODING_SJIS
    return(0);
#else
    while (*s) {
	if (*s < 0x80) return(1);
	s++;
    }
    return(0);
#endif
}

/*
------------------------------------------------------------------------------
	PROCEDURE:
	<trans>: translate from <fp_in> to <fp_out>
------------------------------------------------------------------------------
*/

void trans(FILE *fp_in, FILE *fp_out)
{
    CELL	*cell,*cell1;
    int         keitaiso_num;
    int         keitaiso_p[KEITAISO_NUM_MAX],keitaiso_c[KEITAISO_NUM_MAX];
    int         i,f;
    float	float_weight;
    int 	int_weight;
    MRPH        *mrph_p;
    U_CHAR      str_midasi[MIDASI_MAX*10];
    U_CHAR      str_yomi[YOMI_MAX*10];
    int         rengo_con_tbl;

/*    fprintf(fp_out, I_FILE_ID);*/
    
    LineNo = 1;
    while (! s_feof(fp_in)) {
	LineNoForError = LineNo;

	lisp_alloc_push();
	cell = s_read(fp_in);
	  
	if (Atomp(cell)) error_in_trans(NotList, cell);
	if (!Atomp(car(cell))) error_in_trans(IllegalForm, car(cell));
	
	if (get_hinsi_id(_Atom(car(cell))) == atoi(RENGO_ID)) {
            /* 連語の場合 */
	    keitaiso_num = mrph_buffer_num = 0;
	    cell1 = car(cdr(cell));
	    while (!Null(car(cell1))) {  /* 形態素情報を全て読み込む */
		keitaiso_p[keitaiso_num] = mrph_buffer_num;
		_trans(car(cell1) , TRUE);
		if (++keitaiso_num >= KEITAISO_NUM_MAX)
		    error_in_trans(LongRengo , NULL);
		cell1 = cdr(cell1);
	    }
	    keitaiso_p[keitaiso_num] = mrph_buffer_num;
	    if (keitaiso_num <= 1) error_in_trans(ShortRengo , NULL);

	    if (Null(cdr(cdr(cell)))) {
		int_weight = (int)(RENGO_DEFAULT_WEIGHT * 10 + 0.1);
	    } else {
		if (sscanf((char *)_Atom(car(cdr(cdr(cell)))),"%f",
			   &float_weight) == 0)
		    error_in_trans(IllegalForm, cell);
		int_weight = (int)(float_weight * 10 + 0.1);
		if (int_weight < 0 || int_weight > 256)
		    error_in_trans(IllegalWeight, cell);
	    }

	    /* 連語情報を出力する */
	    for (i = 0; i < keitaiso_num; i++) keitaiso_c[i] = keitaiso_p[i];
	    f = 1;
	    while (f) {
		str_midasi[0] = str_yomi[0] = '\0';
		for (i = 0 ; i < keitaiso_num ; i++) {
		    mrph_p = &mrph_buffer[keitaiso_c[i]];
		    if (strcmp(mrph_p->midasi , "@")) {
			strcat(str_midasi , mrph_p->midasi);
			strcat(str_yomi , mrph_p->yomi);
		    } /* 語幹なしなら何もつけない */
		    if (Class[mrph_p->hinsi][mrph_p->bunrui].kt) { /* 活用有 */
			if (mrph_p->katuyou2 == 0) {
			    if (i < keitaiso_num-1)
				error_in_trans(NoKatuyoukei , mrph_p->midasi);
			} else {
			    strcat(str_midasi , Form[mrph_p->katuyou1]
				   [mrph_p->katuyou2].gobi);
			    strcat(str_yomi ,   Form[mrph_p->katuyou1]
				   [mrph_p->katuyou2].gobi_yomi);
			}
		    }
		    if (strlen(str_midasi) > MIDASI_MAX)
			error_in_trans(LongMidasi, str_midasi);
		    if (strlen(str_yomi) > YOMI_MAX)
			error_in_trans(LongYomi, str_yomi);
		}

		/* 連語として連接規則が記述されているか調べる */
		mrph_p = &mrph_buffer[keitaiso_c[keitaiso_num-1]];
		mrph.katuyou1 = mrph_p->katuyou1;
		strcpy(mrph.midasi , str_midasi);
		if (Class[mrph_p->hinsi][mrph_p->bunrui].kt != 0 &&
		    mrph_p->katuyou2 == 0) {
		    for (i = 1;
			 strcmp(Form[mrph_p->katuyou1][i].name,"基本形");i++);
		    strcat(mrph.midasi , Form[mrph_p->katuyou1][i].gobi);
		}
		check_table_for_rengo(&mrph);

		fprintf(fp_out, "%s\t", str_midasi);
		numeral_encode(fp_out, atoi(RENGO_ID));
		numeral_encode(fp_out, keitaiso_num);
		numeral_encode(fp_out, 0);
		numeral_encode(fp_out, 0);
		numeral_encode(fp_out, int_weight);
		numeral_encode2(fp_out, mrph.con_tbl);
		hiragana_encode(fp_out, str_yomi);

		/* 中身の形態素情報を出力する */
		for (i = 0 ; i < keitaiso_num ; i++) {
		    if (!strcmp(mrph_buffer[keitaiso_c[i]].midasi, "@"))
			fprintf(fp_out, "  ");
		    else
			fprintf(fp_out, " %s ",
				mrph_buffer[keitaiso_c[i]].midasi);
		    output_mrph(fp_out , &mrph_buffer[keitaiso_c[i]]);
		}
		fprintf(fp_out, "\n");
		
		i = 0;
		while (1) { /* 次の組み合わせ方で連語を構成する */
		    if (++keitaiso_c[i] == keitaiso_p[i+1]) {
			keitaiso_c[i] = keitaiso_p[i];
			if (++i == keitaiso_num) {f = 0; break;}
		    } else break;
		}
	    }
	} else {
            /* 形態素の場合 */
	    mrph_buffer_num = 0;
	    _trans(cell , FALSE);
	    for (i = 0 ; i < mrph_buffer_num ; i++) {
		fprintf(fp_out, "%s\t", mrph_buffer[i].midasi);
		output_mrph(fp_out , &mrph_buffer[i]);
		fprintf(fp_out, "\n");
	    }
	}
	lisp_alloc_pop();
    }
}
	  
static void _trans(CELL *cell , int rengo_p)
{
    CELL   *main_loop, *main_block, *sub_loop, *sub_block;
    MRPH   *mrph_p;

    mrph_p = &mrph;
    init_mrph(mrph_p);

    mrph_p->hinsi = get_hinsi_id(_Atom(car(cell)));	/* 形態品詞 */
	  
    main_loop = cdr(cell);
    while (!Null(main_block = car(main_loop))) {

	/* 細分類がある場合 */
	if (Atomp(car(main_block))) {
	    mrph_p->bunrui =
		get_bunrui_id(_Atom(car(main_block)), mrph_p->hinsi);
	    sub_loop = cdr(main_block);
	    while (!Null(sub_block = car(sub_loop))) {
		__trans(sub_block, mrph_p, rengo_p);
		sub_loop = cdr(sub_loop);
	    }
	} 

	/* 細分類がない場合 */
	else {
	    mrph_p->bunrui = 0;
	    __trans(main_block, mrph_p, rengo_p);
	}

	main_loop = cdr(main_loop);
    }
}

static void __trans(CELL *block, MRPH *mrph_p, int rengo_p)
{
    CELL 	*loop, *midasi_cell;
    U_CHAR 	*midasi_cp = NULL;
    float	float_weight;
    int 	int_weight;
    CELL        *connect_cell;                    /* EDRdic '94.Mar */

    strcpy(mrph_p->yomi, yomi(block))  ;		/* 読み     */
    mrph_p->imi = imi(block);				/* 意味情報 */
    if (Class[mrph_p->hinsi][mrph_p->bunrui].kt) {
	mrph_p->katuyou1 = katuyou1(block);		/* 活用型   */
	if (rengo_p) mrph_p->katuyou2 = katuyou2(block , mrph_p->katuyou1);
	else mrph_p->katuyou2 = 0;	             	/* 活用 */
    } else
	mrph_p->katuyou1 = 0;
    
    if (Class[mrph_p->hinsi][mrph_p->bunrui].kt)
	trim_yomi_gobi(mrph_p);

    loop = midasi_list(block);				/* 見出し語 */
    while (!Null(midasi_cell = car(loop))) {

	/* (見出し語 ×××) の場合 */
	if (Atomp(midasi_cell)) {
	    midasi_cp = _Atom(midasi_cell);
	    mrph_p->weight = MRPH_DEFAULT_WEIGHT;
	} 
	
	/* (見出し語 (××× weight)) の場合 */
	else if (Atomp(car(midasi_cell))) {
	    midasi_cp = _Atom(car(midasi_cell));

	    if (Null(cdr(midasi_cell)))
		mrph_p->weight = MRPH_DEFAULT_WEIGHT;
	    else if (Atomp(car(cdr(midasi_cell)))) {
		if (sscanf((char *)_Atom(car(cdr(midasi_cell))),"%f",
			   &float_weight) == 0)
		    error_in_trans(IllegalForm, midasi_cell);
		int_weight = (int)(float_weight * MRPH_DEFAULT_WEIGHT + 0.1);
		if (int_weight < 0 || int_weight > 256)
		    error_in_trans(IllegalWeight, midasi_cell);
		mrph_p->weight = (U_CHAR)int_weight;
	    }
	    else 
		error_in_trans(IllegalForm, midasi_cell);
	} else {
	    error_in_trans(IllegalForm, midasi_cell);	      
	}  

	if (hankaku_check(midasi_cp)) error_in_trans(HankakuChr, midasi_cp);
	if (strlen(midasi_cp) > MIDASI_MAX)
	    error_in_trans(LongMidasi, midasi_cp);
	strcpy(mrph_p->midasi, midasi_cp);

	if ( Null(connect_cell = edrconnect(block)) ){
            check_table(mrph_p);                            /* 連接情報 */
        }
        else {                                        /* for EDRdic '94.Mar */
            check_edrtable(mrph_p, connect_cell);
        }

	if (Class[mrph_p->hinsi][mrph_p->bunrui].kt) {
	    trim_midasi_gobi(mrph_p);
	    if ( strlen(mrph_p->midasi) )
		print_mrph(mrph_p);
	    else {
		if (rengo_p) {
		    strcpy(mrph_p->midasi , "@");
		    strcpy(mrph_p->yomi   , "@");
		    print_mrph(mrph_p);
		} else
		    print_mrph_loop(mrph_p);
		/* 語幹が無くなる場合は全ての活用形を登録 */
	    }
	} else
	    print_mrph(mrph_p);
	
	loop = cdr(loop);
    }
}