-
Notifications
You must be signed in to change notification settings - Fork 0
/
Supertag.tcl
executable file
·1894 lines (1607 loc) · 52.1 KB
/
Supertag.tcl
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
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
# the next line restarts using wish \
exec /usr/bin/wish "$0" "$@"
set auto_path [linsert $auto_path 0 [pwd]]
package require Tk
package require Mk4tcl
package require tokenize
set sent_values {}
set skip 90
set xwidth [expr $skip/9]
# utf-8 character codes
set diamond "\u25c7"
# set diamond "<>"
set diamond0 "\u25c7\u2080"
set diamond1 "\u25c7\u2081"
set box "\u25a1"
# set box "[]"
set box0 "\u25a1\u2080"
set box1 "\u25a1\u2081"
set bs1 "\\\u2081"
set bullet "\u2022"
# set bullet "*"
set mode0 ""
# set mode0 "\u2080"
set spc "\u2006"
# set spc " "
set debug off
set debugstring ""
# set debugstring "fyx allbrackets"
# set debugstring "spy prob_parse"
# set debugstring "noregin nozeroheap"
set cvs_prefix [file normalize ".."]
set lefff_prefix [file normalize ".."]
set model_prefix [file normalize "../models"]
set grail_prefix [file normalize "../GrailLight"]
set grammar_prefix [file normalize "../Grail/grammars"]
set cnc_tagger_prefix /Users/moot/Software/candc-1.1/bin
set keras_tagger_prefix /Users/moot/checkout/DeepGrail
set keras_model_prefix /Users/moot/checkout/DeepGrail
set pos_model(dutch) "$model_prefix/best_dutch_pos_reduced"
set st_model(dutch) "$model_prefix/best_dutch_model"
set pos_model(dutchx) "$model_prefix/best_dutch_pos_reduced"
set st_model(dutchx) "$model_prefix/detailed_dutch_model"
set pos_model(french) "$model_prefix/french_pos_tt"
set pos_model(frenchx) "$model_prefix/extra_pos_tt"
set st_model(french) "$model_prefix/french_tt"
set st_model(frenchx) "$model_prefix/french_tt"
set postagger keras
set supertagger keras
set cnc_pos_cmd "$cnc_tagger_prefix/mpos"
set cnc_st_cmd "$cnc_tagger_prefix/msuper"
set keras_pos_cmd "$keras_tagger_prefix/best_pos/pos2.py"
set keras_st_cmd "$keras_tagger_prefix/best_super/super.py"
set keras_superpos_cmd "$keras_tagger_prefix/best_superpos/superpos.py"
set keras_pos_model "$keras_model_prefix/best_pos/small_pos.h5"
set keras_st_model "$keras_model_prefix/best_super/small_super.h5"
set keras_superpos_cmd "$keras_tagger_prefix/best_superpos/small_superpos.h5"
set grail_cmd "$grail_prefix/g3"
set tmp_dir "/Users/moot/Library/Supertagger"
set semantics drt
set postagset tt
set grail_exec "grail_light_nd.pl"
set stanford_parser_cmd "/Users/moot/Programs/stanford-parser-full-2016-10-31/lexparser-french.sh"
# set stanford_parser_cmd "/Users/moot/Programs/stanford-parser-full-2015-04-20/lexparser-french.sh"
set stanford_parser_length 30
set berkeley_parser_cmd "/usr/bin/java -jar /Users/moot/Software/BerkeleyParser/BerkeleyParser-1.7.jar -gr /Users/moot/Software/BerkeleyParser/fra_sm5.gr "
set bootstrap "berkeley"
set bw 1
# code snippet from robeadam / thommey
# found at
# http://tclhelp.net/unb/169
proc round {number {digits 0}} {
if { $digits} {
return [expr {round(pow(10,$digits)*$number)/pow(10,$digits)}]
} else {
return [ int [expr {round(pow(10,$digits)*$number)/pow(10,$digits)}]]
}
}
proc set_default_colors {bw} {
global st_conf_color st_other_color pos_conf_color pos_other_color
if {$bw} {
set st_conf_color gray20
set st_other_color gray80
set pos_conf_color gray40
set pos_other_color gray80
} else {
set st_conf_color blue
set st_other_color "#a6e4ff"
set pos_other_color "#c60207"
set pos_conf_color "#8d23f7"
}
}
set_default_colors $bw
proc st_dialog {} {
tk_dialog .about "About the supertagger/parser" "Interface script to the combined part-of-speech/supertaggers and the Grail parser" "" 0 "Ok"
}
proc latex_proofs {} {
global tmp_dir
set cur_dir [pwd]
cd $tmp_dir
exec /Library/TeX/texbin/pdflatex latex_proofs.tex
catch { exec open latex_proofs.pdf }
cd $cur_dir
}
proc update_models {} {
global postagset model_prefix lang
set pos_model($lang) "$model_prefix/$lang\_pos_$postagset"
set st_model($lang) "$model_prefix/best_$lang\_$postagset"
}
proc update_menus {} {
global lang postagset grail_parse
if {[string equal $lang "french"]} {
.mb.options.pos entryconfigure 0 -state normal
.mb.options.pos entryconfigure 1 -state normal
.mb.options.pos entryconfigure 2 -state normal
.mb.options.pos entryconfigure 3 -state normal
.mb.options.pos entryconfigure 4 -state disabled
.mb.options.pos entryconfigure 5 -state disabled
if {[string equal $postagset "detailed"] || [string equal $postagset "reduced"]} {
set postagset tt
update_models
}
} elseif {[string equal $lang "dutch"]} {
.mb.options.pos entryconfigure 0 -state disabled
.mb.options.pos entryconfigure 1 -state disabled
.mb.options.pos entryconfigure 2 -state disabled
.mb.options.pos entryconfigure 3 -state disabled
.mb.options.pos entryconfigure 4 -state normal
.mb.options.pos entryconfigure 5 -state normal
set postagger cnc
set supertagger cnc
.mb.options.postagger entryconfigure 0 -state normal
.mb.options.postagger entryconfigure 1 -state disabled
.mb.options.supertagger entryconfigure 0 -state normal
.mb.options.supertagger entryconfigure 1 -state disabled
if {![string equal $postagset "detailed"] && ![string equal $postagset "reduced"]} {
set postagset detailed
update_models
}
}
if {[string equal $grail_parse "chart_pos_lemma"]} {
.mb.options.par entryconfigure 0 -state disabled
.mb.options.par entryconfigure 1 -state disabled
.mb.options.link entryconfigure 0 -state disabled
.mb.options.link entryconfigure 1 -state disabled
.mb.options.link entryconfigure 2 -state disabled
.mb.options.link entryconfigure 3 -state disabled
.mb.options.debug entryconfigure 0 -state disabled
.mb.options.debug entryconfigure 1 -state disabled
.mb.options.bparser entryconfigure 0 -state normal
.mb.options.bparser entryconfigure 1 -state normal
.mb.options.bparser entryconfigure 2 -state normal
} else {
.mb.options.par entryconfigure 0 -state normal
.mb.options.par entryconfigure 1 -state normal
.mb.options.link entryconfigure 0 -state normal
.mb.options.link entryconfigure 1 -state normal
.mb.options.link entryconfigure 2 -state normal
.mb.options.link entryconfigure 3 -state normal
.mb.options.debug entryconfigure 0 -state normal
.mb.options.debug entryconfigure 1 -state normal
.mb.options.bparser entryconfigure 0 -state disabled
.mb.options.bparser entryconfigure 1 -state disabled
.mb.options.bparser entryconfigure 2 -state disabled
}
}
set grail_parse "chart_pos_lemma"
set log [open "$tmp_dir/log.txt" w]
puts $log [clock format [clock seconds] -format "%a %d %b %Y"]
close $log
if {![file exists $tmp_dir]} {
file mkdir $tmp_dir
}
mk::file open lefff $lefff_prefix/lefff.db -readonly
set morph [mk::view layout lefff.morph "wordpos lemma features"]
set beta 0.1
set algo fwdbwd
set link xpce
set par auto
set lang french
# French POS labels
# treetagger
set vertex(ABR) abbreviation
set vertex(ADJ) adjective
set vertex(ADV) adverb
set vertex(DET:ART) article
set vertex(DET:POS) [list possessive pronoun]
set vertex(INT) interjection
set vertex(KON) conjunction
set vertex(NAM) [list proper name]
set vertex(NOM) noun
set vertex(NUM) numeral
set vertex(PRO) pronoun
set vertex(PRO:DEM) [list demonstrative pronoun]
set vertex(PRO:IND) [list indefinite pronoun]
set vertex(PRO:PER) [list personal pronoun]
set vertex(PRO:POS) [list possessive pronoun]
set vertex(PRO:REL) [list relative pronoun]
set vertex(PRP) preposition
set vertex(PRP:det) [list preposition plus article]
set vertex(PUN) punctuation
set vertex(PUN:cit) [list punctuation citation]
set vertex(PUN:CIT) [list punctuation citation]
set vertex(SENT) [list sentence tag]
set vertex(SYM) symbol
set vertex(VER:cond) [list verb conditional]
set vertex(VER:futu) [list verb futur]
set vertex(VER:impe) [list verb imperative]
set vertex(VER:impf) [list verb imperfect]
set vertex(VER:infi) [list verb infinitive]
set vertex(VER:pres) [list verb present]
set vertex(VER:pper) [list verb past participle]
set vertex(VER:ppre) [list verb present participle]
set vertex(VER:simp) [list verb simple past]
set vertex(VER:subi) [list verb subjunctive imperfect]
set vertex(VER:subp) [list verb subjunctive present]
set vertex(VER:COND) [list verb conditional]
set vertex(VER:FUTU) [list verb futur]
set vertex(VER:IMPE) [list verb imperative]
set vertex(VER:IMPF) [list verb imperfect]
set vertex(VER:INFI) [list verb infinitive]
set vertex(VER:PRES) [list verb present]
set vertex(VER:PPER) [list verb past participle]
set vertex(VER:PPRE) [list verb present participle]
set vertex(VER:SIMP) [list verb simple past]
set vertex(VER:SUBI) [list verb subjunctive imperfect]
set vertex(VER:SUBP) [list verb subjunctive present]
set vertex(NC) [list common noun]
set vertex(NPP) [list proper noun]
set vertex(ADJ) [list adjective]
set vertex(ADV) [list adverb]
set vertex(NPP) [list proper noun]
set vertex(CC) [list coordination]
set vertex(CS) [list subordinate coordination]
set vertex(V) [list verb]
set vertex(VS) [list subjunctive verb]
set vertex(VPP) [list past participle]
set vertex(VPR) [list present participle]
set vertex(VINF) [list infinitive]
set vertex(VIMP) [list imperative]
# Dutch POS labels
set vertex(--) <dummy>
set vertex(UNKNOWN) <automatisch>
set vertex(WW1) WW(pv,ev)
set vertex(WW2) WW(pv,mv)
set vertex(WW3) WW(pv,met-t)
set vertex(WW4) WW(inf,vrij)
set vertex(WW5) WW(inf,prenom)
set vertex(WW6) WW(inf,nom)
set vertex(WW7) WW(vd,vrij)
set vertex(WW8) WW(vd,prenom)
set vertex(WW9) WW(vd,nom)
set vertex(WW10) WW(od,vrij)
set vertex(WW11) WW(od,prenom)
set vertex(WW12) WW(od,nom)
set vertex(WW13) WW(dial)
set vertex(LET) LET
set vertex(TW1) TW(hoofd)
set vertex(TW2) TW(rang)
set vertex(VNW1) VNW(pers,pron,nomin)
set vertex(VNW2) VNW(pers,pron,obl)
set vertex(VNW3) VNW(pers,pron,stan)
set vertex(VNW4) VNW(pers,pron,gen)
set vertex(VNW5) VNW(pers,pron,dial)
set vertex(VNW6) VNW(pr,pron)
set vertex(VNW7) VNW(refl,pron)
set vertex(VNW8) VNW(recip,pron,obl)
set vertex(VNW9) VNW(recip,pron,gen)
set vertex(VNW10) VNW(recip,pron,dial)
set vertex(VNW11) VNW(bez,det)
set vertex(VNW12) VNW(vrag,pron)
set vertex(VNW13) VNW(betr,pron)
set vertex(VNW14) VNW(vb,pron)
set vertex(VNW15) VNW(vb,adv-pron)
set vertex(VNW16) VNW(excl,pron)
set vertex(VNW17) VNW(vb,det)
set vertex(VNW18) VNW(excl,det)
set vertex(VNW19) VNW(aanw,pron)
set vertex(VNW20) VNW(aanw,adv-pron)
set vertex(VNW21) VNW(aanw,det)
set vertex(VNW22) VNW(onbep,pron)
set vertex(VNW23) VNW(onbep,adv-pron)
set vertex(VNW24) VNW(onbep,det,prenom)
set vertex(VNW25) VNW(onbep,det,nom)
set vertex(VNW26) VNW(onbep,det,vrij)
set vertex(VNW27) VNW(onbep,det,dial)
set vertex(TSW) TSW
set vertex(ADJ1) ADJ(prenom)
set vertex(ADJ2) ADJ(nom)
set vertex(ADJ3) ADJ(postnom)
set vertex(ADJ4) ADJ(vrij)
set vertex(ADJ5) ADJ(dial)
set vertex(SPEC) SPEC
set vertex(SPEC2) SPEC(afgebr)
set vertex(SPEC3) SPEC(onverst)
set vertex(SPEC4) SPEC(vreemd)
set vertex(SPEC5) SPEC(deeleigen)
set vertex(SPEC6) SPEC(meta)
set vertex(SPEC8) SPEC(achter)
set vertex(SPEC9) SPEC(comment)
set vertex(VZ1) VZ(init)
set vertex(VZ2) VZ(fin)
set vertex(VZ3) VZ(versm)
set vertex(LID) LID
set vertex(VG1) VG(neven)
set vertex(VG2) VG(onder)
set vertex(BW) BW
set vertex(N1) N(soort,ev,stan)
set vertex(N2) N(soort,ev,gen)
set vertex(N3) N(soort,mv)
set vertex(N4) N(soort,dial)
set vertex(N5) N(eigen,ev,stan)
set vertex(N6) N(eigen,ev,gen)
set vertex(N7) N(eigen,mv)
set vertex(N8) N(eigen,dial)
# ==================
# = morph2pos =
# ==================
# 320 morphology tags
set morph2pos(R001) TSW
set morph2pos(R101) N4
set morph2pos(R102) N8
set morph2pos(R201) ADJ12
set morph2pos(R301) WW13
set morph2pos(R401) TW1
set morph2pos(R402) TW2
set morph2pos(R501) VNW5
set morph2pos(R502) VNW7
set morph2pos(R503) VNW10
set morph2pos(R504) VNW11
set morph2pos(R505) VNW14
set morph2pos(R506) VNW17
set morph2pos(R507) VNW14
set morph2pos(R508) VNW27
set morph2pos(R509) VNW16
set morph2pos(R510) VNW18
set morph2pos(R511) VNW19
set morph2pos(R512) VNW21
set morph2pos(R513) VNW22
set morph2pos(R514) VNW27
set morph2pos(R601) LID
set morph2pos(R602) LID
set morph2pos(R701) VZ1
set morph2pos(R702) VZ2
set morph2pos(R801) VG1
set morph2pos(R802) VG2
set morph2pos(R901) BW
set morph2pos(T001) TSW
set morph2pos(T002) SPEC2
set morph2pos(T003) SPEC3
set morph2pos(T004) SPEC4
set morph2pos(T005) SPEC5
set morph2pos(T006) SPEC6
set morph2pos(T007) LET
set morph2pos(T008) SPEC8
set morph2pos(T009) SPEC9
set morph2pos(T101) N1
set morph2pos(T102) N1
set morph2pos(T103) N1
set morph2pos(T104) N2
set morph2pos(T105) N2
set morph2pos(T106) N1
set morph2pos(T107) N3
set morph2pos(T108) N3
set morph2pos(T109) N5
set morph2pos(T110) N5
set morph2pos(T111) N5
set morph2pos(T112) N6
set morph2pos(T113) N6
set morph2pos(T114) N1
set morph2pos(T115) N7
set morph2pos(T116) N7
set morph2pos(T201) ADJ1
set morph2pos(T202) ADJ1
set morph2pos(T203) ADJ1
set morph2pos(T204) ADJ2
set morph2pos(T205) ADJ2
set morph2pos(T206) ADJ2
set morph2pos(T207) ADJ3
set morph2pos(T208) ADJ3
set morph2pos(T209) ADJ3
set morph2pos(T210) ADJ4
set morph2pos(T211) ADJ4
set morph2pos(T212) ADJ4
set morph2pos(T213) ADJ4
set morph2pos(T214) ADJ4
set morph2pos(T215) ADJ5
set morph2pos(T216) ADJ5
set morph2pos(T217) ADJ5
set morph2pos(T218) ADJ5
set morph2pos(T219) ADJ6
set morph2pos(T220) ADJ6
set morph2pos(T221) ADJ6
set morph2pos(T222) ADJ6
set morph2pos(T223) ADJ7
set morph2pos(T224) ADJ7
set morph2pos(T225) ADJ8
set morph2pos(T226) ADJ8
set morph2pos(T227) ADJ9
set morph2pos(T228) ADJ10
set morph2pos(T229) ADJ11
set morph2pos(T230) ADJ9
set morph2pos(T301) WW1
set morph2pos(T302) WW2
set morph2pos(T303) WW3
set morph2pos(T304) WW1
set morph2pos(T305) WW2
set morph2pos(T306) WW3
set morph2pos(T309) WW1
set morph2pos(T310) WW5
set morph2pos(T311) WW5
set morph2pos(T312) WW6
set morph2pos(T314) WW4
set morph2pos(T315) WW8
set morph2pos(T316) WW8
set morph2pos(T317) WW9
set morph2pos(T318) WW9
set morph2pos(T320) WW7
set morph2pos(T321) WW11
set morph2pos(T322) WW11
set morph2pos(T323) WW12
set morph2pos(T324) WW12
set morph2pos(T326) WW10
set morph2pos(T401) TW1
set morph2pos(T402) TW1
set morph2pos(T403) TW1
set morph2pos(T404) TW1
set morph2pos(T405) TW1
set morph2pos(T406) TW1
set morph2pos(T407) TW1
set morph2pos(T408) TW2
set morph2pos(T409) TW2
set morph2pos(T410) TW2
set morph2pos(T411) TW2
set morph2pos(T501a) VNW1
set morph2pos(T501b) VNW1
set morph2pos(T501c) VNW1
set morph2pos(T501d) VNW1
set morph2pos(T501e) VNW1
set morph2pos(T501f) VNW1
set morph2pos(T501g) VNW1
set morph2pos(T501h) VNW1
set morph2pos(T501i) VNW1
set morph2pos(T501p) VNW1
set morph2pos(T501s) VNW1
set morph2pos(T501t) VNW1
set morph2pos(T502a) VNW2
set morph2pos(T502c) VNW2
set morph2pos(T504a) VNW4
set morph2pos(T504b) VNW4
set morph2pos(T504d) VNW4
set morph2pos(T510a) VNW11
set morph2pos(T510c) VNW11
set morph2pos(T510j) VNW11
set morph2pos(T511a) VNW11
set morph2pos(T511b) VNW11
set morph2pos(T511c) VNW11
set morph2pos(T511d) VNW11
set morph2pos(T511g) VNW11
set morph2pos(T511j) VNW11
set morph2pos(T511k) VNW11
set morph2pos(T513a) VNW11
set morph2pos(T513b) VNW11
set morph2pos(T513d) VNW11
set morph2pos(T513e) VNW11
set morph2pos(T516a) VNW13
set morph2pos(T525a) VNW19
set morph2pos(T525b) VNW19
set morph2pos(T530a) VNW21
set morph2pos(T530b) VNW21
set morph2pos(T532a) VNW21
set morph2pos(T533a) VNW21
set morph2pos(T540a) VNW24
set morph2pos(T541a) VNW24
set morph2pos(T541b) VNW24
set morph2pos(T544a) VNW25
set morph2pos(T546a) VNW25
set morph2pos(T601) LID
set morph2pos(T602) LID
set morph2pos(T603) LID
set morph2pos(T605) LID
set morph2pos(T606) LID
set morph2pos(T607) LID
set morph2pos(T609) LID
set morph2pos(T701) VZ1
set morph2pos(T702) VZ2
set morph2pos(T703) VZ3
set morph2pos(T801) VG1
set morph2pos(T802) VG2
set morph2pos(T901) BW
set morph2pos(U117) N1
set morph2pos(U118) N5
set morph2pos(U501j) VNW1
set morph2pos(U501k) VNW1
set morph2pos(U501l) VNW1
set morph2pos(U501m) VNW1
set morph2pos(U501n) VNW1
set morph2pos(U501o) VNW1
set morph2pos(U501q) VNW1
set morph2pos(U501r) VNW1
set morph2pos(U501u) VNW1
set morph2pos(U501v) VNW1
set morph2pos(U502b) VNW2
set morph2pos(U502d) VNW2
set morph2pos(U502e) VNW2
set morph2pos(U502f) VNW2
set morph2pos(U502g) VNW2
set morph2pos(U502h) VNW2
set morph2pos(U502i) VNW2
set morph2pos(U503a) VNW3
set morph2pos(U503b) VNW3
set morph2pos(U503c) VNW3
set morph2pos(U503d) VNW3
set morph2pos(U504c) VNW4
set morph2pos(U504e) VNW4
set morph2pos(U504f) VNW4
set morph2pos(U505a) VNW6
set morph2pos(U505b) VNW6
set morph2pos(U505c) VNW6
set morph2pos(U505d) VNW6
set morph2pos(U505e) VNW6
set morph2pos(U505f) VNW6
set morph2pos(U505g) VNW6
set morph2pos(U505h) VNW6
set morph2pos(U505i) VNW6
set morph2pos(U506a) VNW7
set morph2pos(U506b) VNW7
set morph2pos(U507a) VNW8
set morph2pos(U508a) VNW9
set morph2pos(U509a) VNW11
set morph2pos(U509b) VNW11
set morph2pos(U509c) VNW11
set morph2pos(U509d) VNW11
set morph2pos(U509e) VNW11
set morph2pos(U509f) VNW11
set morph2pos(U509g) VNW11
set morph2pos(U509h) VNW11
set morph2pos(U509i) VNW11
set morph2pos(U509j) VNW11
set morph2pos(U509k) VNW11
set morph2pos(U509l) VNW11
set morph2pos(U509m) VNW11
set morph2pos(U509n) VNW11
set morph2pos(U509o) VNW11
set morph2pos(U509p) VNW11
set morph2pos(U509q) VNW11
set morph2pos(U510b) VNW11
set morph2pos(U510d) VNW11
set morph2pos(U510e) VNW11
set morph2pos(U510f) VNW11
set morph2pos(U510g) VNW11
set morph2pos(U510h) VNW11
set morph2pos(U510i) VNW11
set morph2pos(U510k) VNW11
set morph2pos(U510l) VNW11
set morph2pos(U510m) VNW11
set morph2pos(U511e) VNW11
set morph2pos(U511f) VNW11
set morph2pos(U511h) VNW11
set morph2pos(U511i) VNW11
set morph2pos(U511l) VNW11
set morph2pos(U511m) VNW11
set morph2pos(U512h) VNW11
set morph2pos(U512i) VNW11
set morph2pos(U512j) VNW11
set morph2pos(U512k) VNW11
set morph2pos(U512l) VNW11
set morph2pos(U512m) VNW11
set morph2pos(U512n) VNW11
set morph2pos(U512o) VNW11
set morph2pos(U512p) VNW11
set morph2pos(U512q) VNW11
set morph2pos(U512r) VNW11
set morph2pos(U512s) VNW11
set morph2pos(U512t) VNW11
set morph2pos(U512u) VNW11
set morph2pos(U513c) VNW11
set morph2pos(U513f) VNW11
set morph2pos(U514a) VNW12
set morph2pos(U515a) VNW13
set morph2pos(U515b) VNW13
set morph2pos(U515c) VNW13
set morph2pos(U515d) VNW13
set morph2pos(U516b) VNW14
set morph2pos(U517a) VNW14
set morph2pos(U517b) VNW14
set morph2pos(U518a) VNW14
set morph2pos(U518b) VNW14
set morph2pos(U518c) VNW14
set morph2pos(U519a) VNW15
set morph2pos(U520a) VNW16
set morph2pos(U521a) VNW17
set morph2pos(U521b) VNW17
set morph2pos(U522a) VNW17
set morph2pos(U523a) VNW18
set morph2pos(U524a) VNW19
set morph2pos(U524b) VNW19
set morph2pos(U524c) VNW19
set morph2pos(U526a) VNW20
set morph2pos(U527a) VNW20
set morph2pos(U528a) VNW21
set morph2pos(U528b) VNW21
set morph2pos(U528c) VNW21
set morph2pos(U528d) VNW21
set morph2pos(U529a) VNW21
set morph2pos(U531b) VNW21
set morph2pos(U531c) VNW21
set morph2pos(U534a) VNW21
set morph2pos(U535a) VNW22
set morph2pos(U535b) VNW22
set morph2pos(U536a) VNW22
set morph2pos(U537a) VNW23
set morph2pos(U538a) VNW23
set morph2pos(U539a) VNW24
set morph2pos(U539b) VNW24
set morph2pos(U539c) VNW24
set morph2pos(U539d) VNW24
set morph2pos(U539e) VNW24
set morph2pos(U539f) VNW24
set morph2pos(U542a) VNW24
set morph2pos(U542b) VNW24
set morph2pos(U542c) VNW24
set morph2pos(U542d) VNW24
set morph2pos(U542e) VNW24
set morph2pos(U542f) VNW24
set morph2pos(U543a) VNW25
set morph2pos(U543b) VNW25
set morph2pos(U543c) VNW25
set morph2pos(U545a) VNW25
set morph2pos(U545b) VNW25
set morph2pos(U545d) VNW25
set morph2pos(U545e) VNW25
set morph2pos(U545f) VNW25
set morph2pos(U547a) VNW26
set morph2pos(U548a) VNW26
set morph2pos(U548b) VNW26
set morph2pos(U548c) VNW26
set morph2pos(U604) LID
set morph2pos(U608) LID
#
proc write_log {s} {
global tmp_dir
set log [open "$tmp_dir/log.txt" a]
puts $log $s
close $log
}
proc get_pos_dir {} {
global pos_model lang
set dir [tk_chooseDirectory -initialdir $pos_model($lang) -mustexist true -title "Select a POS model directory"]
if {$dir eq ""} {
return
}
if {[check_existing_files $dir [list attributes classes config contexts features info lexicon number_unknowns tagdict unknowns weights]] == 0} {
set pos_model($lang) $dir
}
}
proc get_st_dir {} {
global st_model lang
set dir [tk_chooseDirectory -initialdir $st_model($lang) -mustexist true -title "Select a supertag model directory"]
if {$dir eq ""} {
return
}
if {[check_existing_files $dir [list attributes classes config contexts features info lexicon posdict postags tagdict unknowns weights]] == 0} {
set st_model($lang) $dir
}
}
proc check_existing_files {dir list} {
set savedir [pwd]
cd $dir
set missing ""
set m 0
foreach f $list {
if {![file readable $f]} {
set missing "$missing - $f\n"
incr m
}
}
cd $savedir
if {$m > 0} {
tk_dialog .dialog "Missing Files" "Missing files:\n$missing\nDirectory change cancelled." error 0 Ok
}
return m
}
proc printmode {m} {
global mode0
if {[string equal $m "0"]} {
set m $mode0
} elseif {[string equal $m "1"]} {
set m "\u2081"
} elseif {[string equal $m "2"]} {
set m "\u2082"
} elseif {[string equal $m "3"]} {
set m "\u2083"
} elseif {[string equal $m "4"]} {
set m "\u2084"
}
return $m
}
proc printform {string} {
global mode0 spc bullet
set l [parseform $string]
if {[llength $l] == 1} {
return $string
} else {
set c [lindex $l 0]
set m [printmode [lindex $l 1]]
set s1 [printform1 [lindex $l 2]]
set s2 [printform1 [lindex $l 3]]
if {[string equal $c "dl"]} {
return "$s1$spc\\$m$spc$s2"
} elseif {[string equal $c "dr"]} {
return "$s1$spc/$m$spc$s2"
} elseif {[string equal $c "p"]} {
return "$s1$spc$bullet$m$spc$s2"
}
}
}
proc printform1 {l} {
global diamond box bullet mode0 spc
if {[llength $l] == 1} {
return $l
} elseif {[llength $l] == 3} {
set c [lindex $l 0]
set m [printmode [lindex $l 1]]
set s1 [printform1 [lindex $l 2]]
if {[string equal $c "dia"]} {
return "$diamond$m$s1"
} elseif {[string equal $c "box"]} {
return "$box$m$s1"
}
} elseif {[llength $l] == 4} {
set c [lindex $l 0]
set m [printmode [lindex $l 1]]
set s1 [printform1 [lindex $l 2]]
set s2 [printform1 [lindex $l 3]]
if {[string equal $c "dl"]} {
return "($s1$spc\\$m$spc$s2)"
} elseif {[string equal $c "dr"]} {
return "($s1$spc/$m$spc$s2)"
} elseif {[string equal $c "p"]} {
return "($s1$spc$bullet$m$spc$s2)"
}
}
}
# parseform
#
# transform a string containing a formula into a list
proc parseform {string} {
global res
set string [string trim $string]
set i [parseform1 $string 0]
if {$i != [string length $string]} {
puts stderr "$i [string length $string]"
puts stderr "Trailing material deleted! .[string range $string $i end].$res."
}
return $res
}
proc parseform1 {string begin} {
global arg1 arg2 index res
set i $begin
if {[string equal [string range $string $i [expr $i+2]] "dl("]} {
set i [parserest $string [expr $i+3]]
set res [list dl $index $arg1 $arg2]
} elseif {[string equal [string range $string $i [expr $i+2]] "dr("]} {
set i [parserest $string [expr $i+3]]
set res [list dr $index $arg1 $arg2]
} elseif {[string equal [string range $string $i [expr $i+1]] "p("]} {
set i [parserest $string [expr $i+2]]
set res [list p $index $arg1 $arg2]
} elseif {[string equal [string range $string $i [expr $i+3]] "dia("]} {
set i [parserest_u $string [expr $i+4]]
set res [list dia $index $arg1]
} elseif {[string equal [string range $string $i [expr $i+3]] "box("]} {
set i [parserest_u $string [expr $i+4]]
set res [list box $index $arg1]
} else {
# atomic formula
set j [string first "," $string $i]
set k [string first ")" $string $i]
if {$j < $k && $j != -1} {
set res [string range $string $begin [expr $j-1]]
set i $j
} elseif {$k != -1} {
set res [string range $string $begin [expr $k-1]]
set i $k
} else {
set res [string range $string $begin end]
set i [string length $string]
}
}
return $i
}
proc parserest {string i} {
global res arg1 arg2 index
set i [parseindex $string $i]
set thisindex $index
set i [parsecomma $string $i]
set i [parseform1 $string $i]
set thisarg1 $res
set i [parsecomma $string $i]
set i [parseform1 $string $i]
set thisarg2 $res
set i [parseparnc $string $i]
set index $thisindex
set arg1 $thisarg1
set arg2 $thisarg2
return $i
}
proc parserest_u {string i} {
global res arg1 index
set i [parseindex $string $i]
set thisindex $index
set i [parsecomma $string $i]
set i [parseform1 $string $i]
set thisarg1 $res
set i [parseparnc $string $i]
set index $thisindex
set arg1 $thisarg1
return $i
}
proc parsecomma {string i} {
if {[string equal [string range $string $i $i] ","]} {
return [expr $i+1]
} else {
puts stderr "Missing comma: [string range $string 0 $i]*HERE*[string range $string [expr $i+1] end]"
exit 1
}
}
proc parseparnc {string i} {
if {[string equal [string range $string $i $i] ")"]} {
return [expr $i+1]
} else {
puts stderr "Missing close parenthesis: [string range $string 0 $i]*HERE*[string range $string [expr $i+1] end]"
exit 1
}
}
proc parseindex {string i} {
global index
if {[set j [string first "," $string $i]] != -1} {
set index [string range $string $i [expr $j-1]]
return $j
} else {
puts stderr "Missing comma: $string"
exit 1
}
}
proc abbrev {x y string} {
if {[string length $string] > 13} {
set this [.c create text $x $y -tags $string -text "[string range $string 0 9]..."]
.c bind $this <Enter> {
printcomment [lindex [.c gettags current] 0]
}
.c bind $this <Leave> {
printcurrentcomment
}
} else {
.c create text $x $y -text $string
}
}
proc printst {x y list} {
global st_conf_color st_other_color xwidth
set skip -15
for {set i 0} {$i < [llength $list]} {incr i +2} {
set x0 [expr $x-10]
set xr [expr $x0+15]
set x1 [expr $x0+20]