forked from apertium/apertium-smj-nob
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapertium-smj-nob.smj-nob.t2x
1212 lines (1161 loc) · 42.9 KB
/
apertium-smj-nob.smj-nob.t2x
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
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copied from apertium-sme-nob -->
<!--
This is the second pass. Responsibilities of this file include:
* Simple anaphora resolution; we keep track of gender of p3 sg
subjects using the variables "ana_m_f" and "ana_gen", applying
this to GD-tagged SN's and all FV's.
* See rule: FV, SN
* Note: this only applies gender in a forward direction, applying gender
from the noun to pronoun in 'Pron is N' constructions happens in t3x
* Keeping track of verb temps for eg. Actio.Ess
(which is tagged TD) using the variable "ana_temps"
* See rule: FV, V.TD
* Co-ordination
* Removes superfluous prepositions
* See rule: SN CNP SN, FV CVP FV
* Moving postpositions
* See rule: SN ADPOS -> ADPOS SN
* Removing prepositions when case is governed by adpositions
* See rule: PR SN_RPOST adpos
* Removing essive caseprep ('som') after vcop
* See rule: vcop-FV caseprep-PR.ess
* Removing Pcle.qst and putting the qst tag on the preceding chunk,
so that they're treated as if there were no space
* See rule: SN PCLE.qst
* PCLE.qst variants could probably be added to many of the other rules here too,
still TODO, but the most likely seem to be covered.
TODO:
* relatives (SN "who" SV SV* -> SN), both 'real' and those that started life as Agent Constructions
* 'adpos' covers both Pr and Po, tag them as such in t1x so that the rules here don't overgeneralise
DEF-CAT NAMING SCHEME:
chunklemma-CHUNKTAG_SYNTAG.tag.tag
where the SYNTAG part may have an l or r before or after to signify the arrow
(where l corresponds to ← and r to →).
So "det-SN_rOBJ.nom" would include chunks like det<SN><@→OBJ><p1><mf><du><nom>{...}
-->
<interchunk>
<section-def-cats>
<def-cat n="CLB">
<cat-item tags="CLB.*"/>
</def-cat>
<def-cat n="SA">
<cat-item tags="SA"/>
<cat-item tags="SA.*"/>
</def-cat>
<def-cat n="SN">
<cat-item tags="SN"/>
<cat-item tags="SN.*"/>
</def-cat>
<def-cat n="SN_rN">
<cat-item tags="SN.@→N.*"/>
</def-cat>
<def-cat n="SN.nom">
<cat-item tags="SN.*.nom"/>
</def-cat>
<def-cat n="V">
<cat-item tags="SV.*"/>
</def-cat>
<def-cat n="lADVL">
<cat-item lemma="adv" tags="@←ADVL"/>
</def-cat>
<def-cat n="prn-lADVL">
<cat-item lemma="prn" tags="SN.@←ADVL.*"/>
</def-cat>
<def-cat n="PR">
<cat-item tags="PR"/>
<cat-item tags="PR.*"/>
</def-cat>
<def-cat n="caseprep-PR">
<cat-item lemma="caseprep" tags="PR"/>
<cat-item lemma="caseprep" tags="PR.*"/>
</def-cat>
<def-cat n="caseprep-PR.ess">
<cat-item lemma="caseprep" tags="PR.ess"/>
<cat-item lemma="caseprep" tags="PR.Ess"/>
</def-cat>
<def-cat n="SN_PREPl">
<cat-item tags="SN.@P←.*"/>
<cat-item lemma="ref" tags="@P←.*"/>
</def-cat>
<def-cat n="SN_rPOST">
<cat-item tags="SN.@→P.*"/>
<cat-item lemma="ref" tags="@→P.*"/>
</def-cat>
<def-cat n="SN_rADVL">
<cat-item tags="SN.@→ADVL.*"/>
</def-cat>
<def-cat n="adpos">
<cat-item lemma="adpos" tags="*"/>
</def-cat>
<def-cat n="lOBJ">
<cat-item tags="SV.@←OBJ.*"/>
<cat-item tags="SN.@←OBJ.*"/>
<cat-item tags="SA.@←OBJ.*"/>
</def-cat>
<def-cat n="CNP">
<cat-item lemma="conj" tags="@CNP.cnjcoo"/>
</def-cat>
<def-cat n="CVP">
<cat-item lemma="conj" tags="@CVP.cnjcoo"/>
</def-cat>
<def-cat n="FV">
<cat-item tags="SV.@+FMAINV"/>
<cat-item tags="SV.@+FMAINV.*"/>
<cat-item tags="SV.@+FAUXV"/>
<cat-item tags="SV.@+FAUXV.*"/>
</def-cat>
<def-cat n="vcop-FV">
<cat-item lemma="vcop" tags="SV.@+FMAINV"/>
<cat-item lemma="vcop" tags="SV.@+FMAINV.*"/>
<cat-item lemma="vcop" tags="SV.@+FAUXV"/>
<cat-item lemma="vcop" tags="SV.@+FAUXV.*"/>
</def-cat>
<def-cat n="V.TD">
<cat-item tags="SV.@←OBJ.TD.*"/>
</def-cat>
<def-cat n="SN_rN.gen">
<cat-item tags="SN.@→N.*.gen"/>
</def-cat>
<def-cat n="ADVL.loc">
<cat-item tags="SN.@ADVL.*.loc"/>
<cat-item tags="SN.@ADVL.*.loc.*"/>
<cat-item tags="SN.@←ADVL.*.loc"/>
<cat-item tags="SN.@←ADVL.*.loc.*"/>
<cat-item tags="SN.@ADVL→.*.loc"/>
<cat-item tags="SN.@ADVL→.*.loc.*"/>
<cat-item tags="SN.@-FADVL.*.loc"/>
<cat-item tags="SN.@-FADVL.*.loc.*"/>
<cat-item tags="SN.@-F←ADVL.*.loc"/>
<cat-item tags="SN.@-F←ADVL.*.loc.*"/>
<cat-item tags="SN.@-FADVL→.*.loc"/>
<cat-item tags="SN.@-FADVL→.*.loc.*"/>
</def-cat>
<def-cat n="PCLE.qst">
<cat-item tags="@PCLE.qst"/>
<cat-item tags="@PCLE.qst.*"/>
</def-cat>
</section-def-cats>
<section-def-attrs>
<def-attr n="a_sintagma">
<attr-item tags="SN"/>
<attr-item tags="SV"/>
<attr-item tags="SA"/>
</def-attr>
<def-attr n="gen">
<attr-item tags="m"/>
<attr-item tags="f"/>
<attr-item tags="mf"/>
<attr-item tags="nt"/>
<attr-item tags="GD"/>
<attr-item tags="GD_pers"/>
</def-attr>
<def-attr n="case">
<attr-item tags="nom"/>
<attr-item tags="acc"/>
<attr-item tags="gen"/>
<attr-item tags="com"/>
<attr-item tags="ess"/>
<attr-item tags="ill"/>
<attr-item tags="loc"/>
<attr-item tags="ine"/>
<attr-item tags="ela"/>
</def-attr>
<def-attr n="a_caseprep_verb">
<attr-item tags="ill-NIL"/>
<attr-item tags="ill-med"/>
<attr-item tags="ill-på"/>
<attr-item tags="ill-av"/>
<attr-item tags="loc-for"/>
<attr-item tags="loc-om"/>
<attr-item tags="loc-som"/>
<attr-item tags="loc-fra"/>
<attr-item tags="NC"/>
</def-attr>
<def-attr n="art">
<attr-item tags="def"/>
<attr-item tags="ind"/>
<attr-item tags="DD"/>
</def-attr>
<def-attr n="temps">
<attr-item tags="Prs"/>
<attr-item tags="Prt"/>
<attr-item tags="pres"/>
<attr-item tags="pret"/>
<attr-item tags="Inf"/>
<attr-item tags="inf"/>
<attr-item tags="Imprt"/>
<attr-item tags="imp"/>
<attr-item tags="PrfPrc"/>
<attr-item tags="pp"/>
<attr-item tags="TD"/>
</def-attr>
<def-attr n="voice">
<attr-item tags="pass"/>
</def-attr>
<def-attr n="pers">
<attr-item tags="p1"/>
<attr-item tags="p2"/>
<attr-item tags="p3"/>
</def-attr>
<def-attr n="nbr">
<attr-item tags="Sg"/>
<attr-item tags="Du"/>
<attr-item tags="Pl"/>
<attr-item tags="sg"/>
<attr-item tags="du"/>
<attr-item tags="pl"/>
<attr-item tags="ND"/>
<attr-item tags="sp"/>
</def-attr>
<def-attr n="neg">
<attr-item tags="ConNeg"/>
<attr-item tags="Neg"/>
</def-attr>
<def-attr n="mode">
<attr-item tags="qst"/>
</def-attr>
<def-attr n="modality">
<attr-item tags="Ind"/>
<attr-item tags="Cond"/>
<attr-item tags="Cond2"/>
<attr-item tags="Cond3"/>
<attr-item tags="Pot"/>
</def-attr>
<def-attr n="animacy">
<attr-item tags="impers"/>
<attr-item tags="pers"/>
</def-attr>
<def-attr n="syn_label">
<attr-item tags="@→A"/>
<attr-item tags="@A←"/>
<attr-item tags="@←ADVL"/>
<attr-item tags="@→ADVL"/>
<attr-item tags="@ADVL"/>
<attr-item tags="@ADVL←"/>
<attr-item tags="@ADVL→"/>
<attr-item tags="@ADVL→CS"/>
<attr-item tags="@ADVL←OBJ"/>
<attr-item tags="@ADVL→SUBJ"/>
<attr-item tags="@APP"/>
<attr-item tags="@APP-ADVL←"/>
<attr-item tags="@APP-N←"/>
<attr-item tags="@APP-Num←"/>
<attr-item tags="@APP-Pron←"/>
<attr-item tags="@APP→Pron"/>
<attr-item tags="@→CC"/>
<attr-item tags="@CNP"/>
<attr-item tags="@COMP-CS←"/>
<attr-item tags="@CVP"/>
<attr-item tags="@-F←ADVL"/>
<attr-item tags="@-FADVL"/>
<attr-item tags="@-FADVL→"/>
<attr-item tags="@-FAUXV"/>
<attr-item tags="@\+FAUXV"/>
<attr-item tags="@+FAUXV"/>
<attr-item tags="@-FMAINV"/>
<attr-item tags="@\+FMAINV"/>
<attr-item tags="@+FMAINV"/>
<attr-item tags="@-F←OBJ"/>
<attr-item tags="@-FOBJ"/>
<attr-item tags="@-FOBJ→"/>
<attr-item tags="@-F←OPRED"/>
<attr-item tags="@-FOPRED→"/>
<attr-item tags="@-F←SPRED"/>
<attr-item tags="@-FSPRED→"/>
<attr-item tags="@-FSUBJ→"/>
<attr-item tags="←hab→"/>
<attr-item tags="@HNOUN"/>
<attr-item tags="@INTERJ"/>
<attr-item tags="@→N"/>
<attr-item tags="@N←"/>
<attr-item tags="@N"/>
<attr-item tags="@→Num;"/>
<attr-item tags="@→Num"/>
<attr-item tags="@Num←"/>
<attr-item tags="@←OBJ"/>
<attr-item tags="@OBJ"/>
<attr-item tags="@OBJ→"/>
<attr-item tags="@OBJ→SPRED"/>
<attr-item tags="@-OPRED→"/>
<attr-item tags="@←OPRED"/>
<attr-item tags="@OPRED"/>
<attr-item tags="@OPRED→"/>
<attr-item tags="@→P"/>
<attr-item tags="@P←"/>
<attr-item tags="@PCLE"/>
<attr-item tags="@←PPRED"/>
<attr-item tags="@PPRED"/>
<attr-item tags="@→Pron"/>
<attr-item tags="@Pron←"/>
<attr-item tags="@-SPRED→"/>
<attr-item tags="@←SPRED"/>
<attr-item tags="@SPRED"/>
<attr-item tags="@SPRED→"/>
<attr-item tags="@SPRED←OBJ"/>
<attr-item tags="@←SUBJ"/>
<attr-item tags="@SUBJ"/>
<attr-item tags="@SUBJ→"/>
<attr-item tags="@SUBJ←ADVL"/>
<attr-item tags="@SUBJ←OBJ"/>
<attr-item tags="@VOC"/>
<attr-item tags="@X"/>
</def-attr>
</section-def-attrs>
<section-def-vars>
<def-var n="tmp"/>
<def-var n="caseprep_verb" c="For changing/removing prepositions based on verb argument structure"/>
<def-var n="caseprep" c="nob preposition (whole chunk) based on sme case, perhaps changed based on caseprep_verb"/>
<def-var n="c_name"/>
<def-var n="c_tags"/>
<def-var n="ana_temps" c="set by FV's, used on TD's"/>
<def-var n="ana_m_f" c="p3 sg gender (only m or f) set by SUBJ's, used on GD_pers's, stored in FV's for t3x pro insertion"/>
<def-var n="ana_m_f_pers" c="p3 sg gender (only m or f) set by pers-tagged chunks, used on GD_pers's, stored in pers-tagged FV's for t3x pro insertion"/>
<def-var n="ana_gen" c="p3 sg gender (m, f, or nt) set by SUBJ's, used on GD's, stored in FV's for t3x pro insertion"/>
<def-var n="ana_nbr" c="p3 number, set only if ana_gen is set, used on ND's."/>
</section-def-vars>
<section-def-macros>
<def-macro n="switch_cases" npar="2"
c="Simply switch the typographic cases (upper/lower/capital) of the two arguments.">
<let><var n="tmp"/><get-case-from pos="1"><clip pos="1" part="lemh"/></get-case-from></let>
<let><clip pos="1" part="lemh"/><get-case-from pos="2"><clip pos="1" part="lemh"/></get-case-from></let>
<modify-case><clip pos="2" part="lemh"/><var n="tmp"/></modify-case>
</def-macro>
<def-macro n="tag_qst" npar="1"
c="Add the qst tag, preferably after 'neg' or defnes tags.
TODO: perhaps it would be simpler to just explicitly re-set the chunk tags
instead of all this concatting.">
<choose>
<when>
<test><not><equal><clip pos="1" part="neg"/><lit v=""/></equal></not></test>
<let>
<clip pos="1" part="neg"/>
<concat><clip pos="1" part="neg"/><lit-tag v="qst"/></concat>
</let>
</when>
<when c="Unfortunately, 'clip' is case-insensitive so modality (Ind) conflicts with defnes (ind).
Using positive checks works around this.">
<test><or>
<equal><clip pos="1" part="art"/><lit-tag v="ind"/></equal>
<equal><clip pos="1" part="art"/><lit-tag v="def"/></equal>
<equal><clip pos="1" part="art"/><lit-tag v="DD"/></equal>
</or></test>
<let>
<clip pos="1" part="art"/>
<concat><clip pos="1" part="art"/><lit-tag v="qst"/></concat>
</let>
</when>
<when>
<test><not><equal><clip pos="1" part="syn_label"/><lit v=""/></equal></not></test>
<let>
<clip pos="1" part="syn_label"/>
<concat><clip pos="1" part="syn_label"/><lit-tag v="qst"/></concat>
</let>
</when>
<otherwise>
<let>
<clip pos="1" part="lemh"/>
<concat><clip pos="1" part="lemh"/><lit-tag v="qst"/></concat>
</let>
</otherwise>
</choose>
</def-macro>
<def-macro n="clean_SN_of_adpos" npar="1"
c="arg.1: SN, might be pronoun">
<choose>
<when>
<test><or>
<equal caseless="yes"><clip pos="1" part="lemh"/><lit v="prn"/></equal>
<equal caseless="yes"><clip pos="1" part="lemh"/><lit v="det"/></equal>
</or></test>
<let><clip pos="1" part="case"/><lit-tag v="acc"/></let>
</when>
<otherwise>
<let><clip pos="1" part="case"/><lit v=""/></let>
</otherwise>
</choose>
</def-macro>
<def-macro n="set_c_name3" npar="3" c="args should be given in order of output
Case of whole chunk is based on first element.">
<let>
<var n="c_name"/>
<concat>
<clip pos="1" part="lemh"/>
<lit v="_"/>
<clip pos="2" part="lemh"/>
<lit v="_"/>
<clip pos="3" part="lemh"/>
</concat>
</let>
<modify-case><var n="c_name"/><clip pos="1" part="lemh"/></modify-case>
</def-macro>
<def-macro n="set_c_tags2" npar="2"
c="For conjunctions.
We might get pronouns, which t1x doesn't give defnes tags;
in that case, just use the tags from the other conjunct.
(Might want to put defnes on pronouns in t1x?)">
<let><var n="c_tags"/><clip pos="2" part="tags"/></let>
<choose><when>
<test><not><equal><clip pos="1" part="art"/><lit v=""/></equal></not></test>
<choose><when>
<test><or>
<equal><clip pos="2" part="art"/><lit v=""/></equal>
<equal><clip pos="2" part="syn_label"/><lit v=""/></equal>
</or></test>
<let><var n="c_tags"/><clip pos="1" part="tags"/></let>
</when></choose>
</when></choose>
</def-macro>
<def-macro n="set_ana_temps" npar="1"
c="arg.1: verb">
<choose><when>
<test><not><equal><clip pos="1" part="temps"/><lit v=""/></equal></not></test>
<let><var n="ana_temps"/><clip pos="1" part="temps"/></let>
</when></choose>
</def-macro>
<def-macro n="apply_ana_temps" npar="1"
c="arg.1: verb">
<choose><when>
<test><and>
<not><equal><var n="ana_temps"/><lit v=""/></equal></not>
<equal><clip pos="1" part="voice"/><lit v=""/></equal>
</and></test>
<let><clip pos="1" part="temps"/><var n="ana_temps"/></let>
</when></choose>
</def-macro>
<def-macro n="set_caseprep" npar="1"
c="arg.1: verb">
<choose><when>
<test><not><equal><clip pos="1" part="a_caseprep_verb"/><lit v=""/></equal></not></test>
<let><var n="caseprep_verb"/><clip pos="1" part="a_caseprep_verb"/></let>
</when></choose>
</def-macro>
<def-macro n="modify_caseprep" npar="1"
c="arg.1: PR-caseprep">
<let><var n="tmp"/><lit v=""/></let>
<choose c="maybe let caseprep have the wanted preposition lemma">
<when>
<test><and>
<equal><var n="caseprep_verb"/><lit-tag v="ill-på"/></equal>
<equal><clip pos="1" part="case"/><lit-tag v="ill"/></equal>
</and></test>
<let><var n="tmp"/><lit v="på"/></let>
</when>
<when>
<test><and>
<equal><var n="caseprep_verb"/><lit-tag v="ill-med"/></equal>
<equal><clip pos="1" part="case"/><lit-tag v="ill"/></equal>
</and></test>
<let><var n="tmp"/><lit v="med"/></let>
</when>
<when>
<test><and>
<equal><var n="caseprep_verb"/><lit-tag v="ill-av"/></equal>
<equal><clip pos="1" part="case"/><lit-tag v="ill"/></equal>
</and></test>
<let><var n="tmp"/><lit v="av"/></let>
</when>
<when>
<test><and>
<equal><var n="caseprep_verb"/><lit-tag v="loc-for"/></equal>
<equal><clip pos="1" part="case"/><lit-tag v="loc"/></equal>
</and></test>
<let><var n="tmp"/><lit v="for"/></let>
</when>
<when>
<test><and>
<equal><var n="caseprep_verb"/><lit-tag v="loc-om"/></equal>
<equal><clip pos="1" part="case"/><lit-tag v="loc"/></equal>
</and></test>
<let><var n="tmp"/><lit v="om"/></let>
</when>
<when>
<test><and>
<equal><var n="caseprep_verb"/><lit-tag v="loc-som"/></equal>
<equal><clip pos="1" part="case"/><lit-tag v="loc"/></equal>
</and></test>
<let><var n="tmp"/><lit v="som"/></let>
</when>
<when>
<test><and>
<equal><var n="caseprep_verb"/><lit-tag v="loc-fra"/></equal>
<equal><clip pos="1" part="case"/><lit-tag v="loc"/></equal>
</and></test>
<let><var n="tmp"/><lit v="fra"/></let>
</when>
<when>
<test><and>
<equal><var n="caseprep_verb"/><lit-tag v="ill-NIL"/></equal>
<equal><clip pos="1" part="case"/><lit-tag v="ill"/></equal>
</and></test>
<let><var n="tmp"/><lit v="NIL"/></let>
</when>
</choose>
<choose>
<when c="No change">
<test><equal><var n="tmp"/><lit v=""/></equal></test>
<let>
<var n="caseprep"/>
<concat><lit v="^"/><clip pos="1" part="whole"/><lit v="$ "/></concat>
</let>
</when>
<when c="Remove completely">
<test><equal><var n="tmp"/><lit v="NIL"/></equal></test>
<let><var n="caseprep"/><lit v=""/></let>
</when>
<otherwise c="Enforce a certain preposition">
<let>
<var n="caseprep"/>
<concat>
<lit v="^"/><clip pos="1" part="tags"/><lit v="{^"/>
<var n="tmp"/><lit-tag v="pr"/>
<lit v="$}$ "/>
</concat>
</let>
</otherwise>
</choose>
</def-macro>
<def-macro n="apply_ana_gen" npar="1"
c="arg.1: SN or verb
-----
If 'ana_m_f' is set, apply it if tagged GD_pers or no gender tag (eg. if we have a verb).
If there's no gender tag, make sure we make one.
(If no tags at all, put it after lemh; if tags but no gen, put it after the tags.)
Else if 'ana_gen' is set, apply it if GD.
TODO: check that impers verbs still output nt pro's!">
<choose>
<when c="If this word is tagged pers and missing (pers) gender, use the gender from ana_m_f_pers">
<test><and>
<not><equal><var n="ana_m_f_pers"/><lit v=""/></equal></not>
<or>
<equal><clip pos="1" part="gen"/><lit v=""/></equal>
<equal><clip pos="1" part="gen"/><lit-tag v="GD_pers"/></equal>
</or>
<equal><clip pos="1" part="animacy"/><lit-tag v="pers"/></equal>
</and></test>
<let><clip pos="1" part="gen"/><var n="ana_m_f_pers"/></let>
<choose>
<when>
<test><equal><clip pos="1" part="tags"/><lit v=""/></equal></test>
<let><clip pos="1" part="lemh"/><concat><clip pos="1" part="lemh"/><var n="ana_m_f_pers"/></concat></let>
</when>
<when>
<test><equal><clip pos="1" part="gen"/><lit v=""/></equal></test>
<let><clip pos="1" part="tags"/><concat><clip pos="1" part="tags"/><var n="ana_m_f_pers"/></concat></let>
</when>
</choose>
</when>
<when c="else fall back on ana_m_f (might be from inanimates)">
<test><not><equal><var n="ana_m_f"/><lit v=""/></equal></not></test>
<choose>
<when>
<test><equal><clip pos="1" part="gen"/><lit-tag v="GD_pers"/></equal></test>
<let><clip pos="1" part="gen"/><var n="ana_m_f"/></let>
</when>
<when>
<test><equal><clip pos="1" part="tags"/><lit v=""/></equal></test>
<let><clip pos="1" part="lemh"/><concat><clip pos="1" part="lemh"/><var n="ana_m_f"/></concat></let>
</when>
<when>
<test><equal><clip pos="1" part="gen"/><lit v=""/></equal></test>
<let><clip pos="1" part="tags"/><concat><clip pos="1" part="tags"/><var n="ana_m_f"/></concat></let>
</when>
</choose>
</when>
</choose>
<choose><when>
<test><and>
<not><equal><var n="ana_gen"/><lit v=""/></equal></not>
<equal><clip pos="1" part="gen"/><lit-tag v="GD"/></equal>
</and></test>
<let><clip pos="1" part="gen"/><var n="ana_gen"/></let>
</when></choose>
<choose><when>
<test><and>
<not><equal><var n="ana_nbr"/><lit v=""/></equal></not>
<equal><clip pos="1" part="nbr"/><lit-tag v="ND"/></equal>
</and></test>
<let><clip pos="1" part="nbr"/><var n="ana_nbr"/></let>
</when></choose>
</def-macro>
<def-macro n="set_ana_gen" npar="1"
c="arg.1: SN or SV
-----
If we have a subject
- If not p1/p2/pl:
* If gender is m/f, store gender in 'ana_m_f' and 'ana_gen';
* If gender is nt or we're given a verb, store nt in 'ana_gen' only;
- If sg/pl: set 'ana_nbr'
Call 'apply_ana_gen' regardless (in case we have a GD).
Call 'set_caseprep' regardless">
<choose><when>
<test><and>
<equal><clip pos="1" part="animacy"/><lit-tag v="pers"/></equal>
<or>
<equal><clip pos="1" part="gen"/><lit-tag v="f"/></equal>
<equal><clip pos="1" part="gen"/><lit-tag v="m"/></equal>
</or>
</and></test>
<let><var n="ana_m_f_pers"/><clip pos="1" part="gen"/></let>
</when></choose>
<choose><when>
<test><or>
<equal><clip pos="1" part="syn_label"/><lit-tag v="@SUBJ→"/></equal>
<equal><clip pos="1" part="syn_label"/><lit-tag v="@←SUBJ"/></equal>
</or></test>
<choose><when>
<test><and>
<not><equal><clip pos="1" part="nbr"/><lit-tag v="pl"/></equal></not>
<not><equal><clip pos="1" part="pers"/><lit-tag v="p1"/></equal></not>
<not><equal><clip pos="1" part="pers"/><lit-tag v="p2"/></equal></not>
</and></test>
<choose><when>
<test><or>
<equal><clip pos="1" part="gen"/><lit-tag v="f"/></equal>
<equal><clip pos="1" part="gen"/><lit-tag v="m"/></equal>
</or></test>
<let><var n="ana_m_f"/><clip pos="1" part="gen"/></let>
<let><var n="ana_gen"/><clip pos="1" part="gen"/></let>
</when></choose>
<choose><when>
<test><or>
<equal><clip pos="1" part="gen"/><lit-tag v="nt"/></equal>
<equal><clip pos="1" part="a_sintagma"/><lit-tag v="SV"/></equal>
</or></test>
<let><var n="ana_gen"/><lit-tag v="nt"/></let>
</when></choose>
</when></choose>
<choose><when>
<test><or>
<equal><clip pos="1" part="nbr"/><lit-tag v="sg"/></equal>
<equal><clip pos="1" part="nbr"/><lit-tag v="pl"/></equal>
</or></test>
<let><var n="ana_nbr"/><clip pos="1" part="nbr"/></let>
</when></choose>
</when></choose>
<choose><when>
<test><equal><var n="ana_m_f"/><lit v=""/></equal></test>
<let><var n="ana_m_f"/><var n="ana_m_f_pers"/></let>
</when></choose>
<call-macro n="apply_ana_gen"><with-param pos="1"/></call-macro>
<call-macro n="set_caseprep"><with-param pos="1"/></call-macro>
</def-macro>
</section-def-macros>
<section-rules>
<!-- <rules: Coordination -->
<rule comment="REGLA: SA CNP SA">
<pattern>
<pattern-item n="SA"/>
<pattern-item n="CNP"/>
<pattern-item n="SA"/>
</pattern>
<action>
<!-- <exception><test><not><equal><clip pos="1" part="case"/><clip pos="3" part="case"/></equal></not></test></exception> -->
<call-macro n="apply_ana_gen"><with-param pos="1"/></call-macro>
<call-macro n="apply_ana_gen"><with-param pos="3"/></call-macro>
<call-macro n="set_c_name3"><with-param pos="1"/><with-param pos="2"/><with-param pos="3"/></call-macro>
<call-macro n="set_c_tags2"><with-param pos="1"/><with-param pos="3"/></call-macro>
<out>
<chunk>
<var n="c_name"/>
<var n="c_tags"/>
<lit v="{"/>
<clip pos="1" part="content"/>
<b pos="1"/>
<clip pos="2" part="content"/>
<b pos="2"/>
<clip pos="3" part="content"/>
<lit v="}"/>
<clip pos="1" part="lemq"/>
</chunk>
</out>
</action>
</rule>
<rule comment="REGLA: SN CNP SN
We assume CG only gives us SN CNP SN if they _should_ be coordinated.
For now only uses the case etc. of the first conjunct.
TODO: what should happen where we still have different cases? («i Norge og på Island»?)">
<pattern>
<pattern-item n="SN"/>
<pattern-item n="CNP"/>
<pattern-item n="SN"/>
</pattern>
<action>
<!-- <exception><test><not><equal><clip pos="1" part="case"/><clip pos="3" part="case"/></equal></not></test></exception> -->
<call-macro n="set_ana_gen"><with-param pos="3"/></call-macro>
<call-macro n="set_c_name3"><with-param pos="1"/><with-param pos="2"/><with-param pos="3"/></call-macro>
<call-macro n="set_c_tags2"><with-param pos="1"/><with-param pos="3"/></call-macro>
<out>
<chunk>
<var n="c_name"/>
<var n="c_tags"/>
<lit v="{"/>
<clip pos="1" part="content"/>
<b pos="1"/>
<clip pos="2" part="content"/>
<b pos="2"/>
<clip pos="3" part="content"/>
<lit v="}"/>
<clip pos="1" part="lemq"/>
</chunk>
</out>
</action>
</rule>
<rule comment="REGLA: PR SN CNP PR SN">
<pattern>
<pattern-item n="PR"/>
<pattern-item n="SN"/>
<pattern-item n="CNP"/>
<pattern-item n="PR"/>
<pattern-item n="SN"/>
</pattern>
<action>
<!-- <exception><test><not><equal><clip pos="1" part="case"/><clip pos="4" part="case"/></equal></not></test></exception> -->
<call-macro n="set_ana_gen"><with-param pos="5"/></call-macro>
<call-macro n="set_c_name3"><with-param pos="2"/><with-param pos="3"/><with-param pos="5"/></call-macro>
<call-macro n="set_c_tags2"><with-param pos="2"/><with-param pos="5"/></call-macro>
<out>
<chunk>
<clip pos="1" part="whole"/>
</chunk>
<b pos="1"/>
<chunk>
<var n="c_name"/>
<var n="c_tags"/>
<lit v="{"/>
<clip pos="2" part="content"/>
<b pos="2"/>
<clip pos="3" part="content"/>
<b pos="3"/>
<clip pos="5" part="content"/>
<lit v="}"/>
<clip pos="2" part="lemq"/>
</chunk>
</out>
<choose><when>
<test><not><equal><b pos="4"/><b/></equal></not></test>
<out><b pos="4"/></out>
</when></choose>
</action>
</rule>
<!-- <rules: Adpositions -->
<rule comment="REGLA: caseprep-PR SN-rADVL lADVL
-----
Islandas eret => fra Island
Don't output the PR since case was selected by the adverb anyway.">
<pattern>
<pattern-item n="caseprep-PR"/>
<pattern-item n="SN_rADVL"/>
<pattern-item n="lADVL"/>
</pattern>
<action>
<call-macro n="set_ana_gen"><with-param pos="2"/></call-macro>
<call-macro n="clean_SN_of_adpos"><with-param pos="2"/></call-macro>
<choose><when>
<test><not><equal><b pos="1"/><b/></equal></not></test>
<out><b pos="1"/></out>
</when></choose>
<out>
<chunk><clip pos="3" part="whole"/></chunk>
<b pos="2"/>
<chunk><clip pos="2" part="whole"/></chunk>
</out>
</action>
</rule>
<rule comment="REGLA: caseprep-PR SN_rPOST adpos
-----
garra dálkki geažil => på_grunn_av dårlig vær
dan geažil => på_grunn_av det
Don't output the PR since case was selected by the adpos anyway.">
<pattern>
<pattern-item n="caseprep-PR"/>
<pattern-item n="SN_rPOST"/>
<pattern-item n="adpos"/>
</pattern>
<action>
<call-macro n="set_ana_gen"><with-param pos="2"/></call-macro>
<call-macro n="clean_SN_of_adpos"><with-param pos="2"/></call-macro>
<choose><when>
<test><not><equal><b pos="1"/><b/></equal></not></test>
<out><b pos="1"/></out>
</when></choose>
<out>
<chunk><clip pos="3" part="whole"/></chunk>
<b pos="2"/>
<chunk><clip pos="2" part="whole"/></chunk>
</out>
</action>
</rule>
<rule comment="REGLA: SN-rPOST adpos
-----
Move postposition to front">
<pattern>
<pattern-item n="SN_rPOST"/>
<pattern-item n="adpos"/>
</pattern>
<action>
<call-macro n="switch_cases"><with-param pos="1"/><with-param pos="2"/></call-macro>
<call-macro n="set_ana_gen"><with-param pos="1"/></call-macro>
<call-macro n="clean_SN_of_adpos"><with-param pos="1"/></call-macro>
<out>
<chunk><clip pos="2" part="whole"/></chunk>
<b pos="1"/>
<chunk><clip pos="1" part="whole"/></chunk>
</out>
</action>
</rule>
<rule comment="REGLA: adpos PR SN_PREPl
-----
badjel ráji =1> over til grensen =2> over grensen
Don't output the PR since case was selected by the adpos anyway.">
<pattern>
<pattern-item n="adpos"/>
<pattern-item n="PR"/>
<pattern-item n="SN_PREPl"/>
</pattern>
<action>
<call-macro n="set_ana_gen"><with-param pos="2"/></call-macro>
<call-macro n="clean_SN_of_adpos"><with-param pos="3"/></call-macro>
<out>
<chunk><clip pos="1" part="whole"/></chunk>
<b pos="1"/>
<chunk><clip pos="3" part="whole"/></chunk>
</out>
<choose><when>
<test><not><equal><b pos="2"/><b/></equal></not></test>
<out><b pos="2"/></out>
</when></choose>
</action>
</rule>
<rule comment="REGLA: caseprep-PR SN
If the above rules didn't match, we keep the PR.
Then we have to switch (upper/lower) cases of PR and SN,
since a PR with lemh caseprep must've been added in t1x.">
<pattern>
<pattern-item n="caseprep-PR"/>
<pattern-item n="SN"/>
</pattern>
<action>
<call-macro n="switch_cases"><with-param pos="1"/><with-param pos="2"/></call-macro>
<call-macro n="modify_caseprep"><with-param pos="1"/></call-macro>
<out>
<var n="caseprep"/>
<chunk><clip pos="2" part="whole"/></chunk>
</out>
</action>
</rule>
<!-- <rules: →N ADVL -->
<rule comment="REGLA: SN_rN.gen caseprep-PR ADVL.loc
-----
(málet olbmuid) earenoamáš dáhpáhusaid oktavuođas => (male mennesker) i forbindelse med spesielle hendelser
Switch order, insert 'med'
TODO: case should be acc or something, not nil, when prn/det">
<pattern>
<pattern-item n="SN_rN.gen"/>
<pattern-item n="caseprep-PR"/>
<pattern-item n="ADVL.loc"/>
</pattern>
<action>
<call-macro n="clean_SN_of_adpos"><with-param pos="1"/></call-macro>
<out>
<chunk><clip pos="2" part="whole"/></chunk>
<b pos="1"/>
<chunk><clip pos="3" part="whole"/></chunk>
<b/>
<chunk>
<lit v="caseprep"/><lit-tag v="PR"/><lit v="{^med"/><lit-tag v="pr"/><lit v="$}"/>
</chunk>
<b pos="2"/>
<chunk><clip pos="1" part="whole"/></chunk>
</out>
</action>
</rule>
<!-- <rules: ditransitives (just switch order instead of removing caseprep) -->
<rule comment="REGLA: caseprep-PR SN lOBJ
-----
dutnje 60 000 ruvnnu =1> til deg 60 000 kroner =2> 60 000 kroner til deg">
<pattern>
<pattern-item n="caseprep-PR"/>
<pattern-item n="SN"/>
<pattern-item n="lOBJ"/>
</pattern>
<action>
<call-macro n="switch_cases"><with-param pos="1"/><with-param pos="3"/></call-macro>
<out>
<chunk><clip pos="3" part="whole"/></chunk>
<b pos="1"/>
<chunk><clip pos="1" part="whole"/></chunk>
<b pos="2"/>
<chunk><clip pos="2" part="whole"/></chunk>
</out>
</action>
</rule>
<!-- <rules: Verb coordination, set/use verb-anaphoric variables -->
<rule comment="REGLA: FV CVP FV
-----
set anaphoric temps variable
use anaphoric gen variable">
<pattern>
<pattern-item n="FV"/>
<pattern-item n="CVP"/>
<pattern-item n="FV"/>
</pattern>
<action>
<choose>
<when>
<test><and>
<equal><clip pos="1" part="temps"/><clip pos="3" part="temps"/></equal>
<equal><clip pos="1" part="nbr"/><clip pos="3" part="nbr"/></equal>
<equal><clip pos="1" part="pers"/><clip pos="3" part="pers"/></equal>
</and></test>
<call-macro n="set_ana_temps"><with-param pos="1"/></call-macro>
<call-macro n="apply_ana_gen"><with-param pos="1"/></call-macro>
<call-macro n="set_c_name3"><with-param pos="1"/><with-param pos="2"/><with-param pos="3"/></call-macro>
<call-macro n="set_c_tags2"><with-param pos="1"/><with-param pos="3"/></call-macro>
<out>
<chunk>
<var n="c_name"/>
<var n="c_tags"/>
<lit v="{"/>
<clip pos="1" part="content"/>
<clip pos="1" part="lemq"/>
<b pos="1"/>
<clip pos="2" part="content"/>
<clip pos="2" part="lemq"/>
<b pos="2"/>
<clip pos="3" part="content"/>
<clip pos="3" part="lemq"/>
<lit v="}"/>
</chunk>
</out>
</when>
<otherwise c="exception">
<call-macro n="apply_ana_gen"><with-param pos="1"/></call-macro>
<call-macro n="apply_ana_gen"><with-param pos="3"/></call-macro>
<call-macro n="set_ana_temps"><with-param pos="3"/></call-macro>
<out>
<chunk><clip pos="1" part="whole"/></chunk>
<b pos="1"/>
<chunk><clip pos="2" part="whole"/></chunk>
<b pos="2"/>
<chunk><clip pos="3" part="whole"/></chunk>
</out>
</otherwise>
</choose>
</action>
</rule>
<rule comment="REGLA: FV
-----
set anaphoric temps variable
use anaphoric gen variable">
<pattern>
<pattern-item n="FV"/>
</pattern>
<action>
<call-macro n="set_ana_temps"><with-param pos="1"/></call-macro>
<call-macro n="set_ana_gen"><with-param pos="1"/></call-macro>
<out>