;;; -*- Mode: tdl; Coding: utf-8; -*-

;;; Verbs: near-equivalence
;;
like_enjoy_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_like_v_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_enjoy_v_1_rel" ] !> ].

like_love_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_like_v_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_love_v_1_rel" ] !> ].

shower_bathe_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_shower_v_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_bathe_v_1_rel" ] !> ].

bathe_wash_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_bathe_v_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_wash_v_1_rel" ] !> ].

takeaway_steal_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_take_v_away_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_steal_v_from_rel" ] !> ].

takeaway_take_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_take_v_away_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_take_v_1_rel" ] !> ].

return_go_back_mt := word_hcons_mtr &
[ INPUT.RELS <! [ PRED "_return_v_1_rel" ] !>,
  OUTPUT [ RELS <! [ PRED "_go_v_1_rel", LBL handle & #h1, ARG0 event & #e2],
  	         [ PRED loc_nonsp_rel, LBL #h1, ARG1 #e2 ],
		 [ PRED place_n_rel, LBL handle & #h3, ARG0 #x4 & ref-ind ],
		 [ PRED def_implicit_q_rel, ARG0 #x4, RSTR handle & #h5 ],
		 [ PRED _back_p_rel, LBL #h3, ARG1 #x4 ] !>,
	   HCONS <! qeq & [ HARG #h5, LARG #h3 ] !> ] ].

;; Exclude conjoined NP subjects by constraining PRED value
agentless_passive_name_mt := agentless_passive_omtr &
[ INPUT.RELS.LIST < [ ], [ PRED named_rel ], ... > ].
agentless_passive_pron_mt := agentless_passive_omtr &
[ INPUT.RELS.LIST < [ ], [ PRED pron_rel ], ... > ].
agentless_passive_noun_mt := agentless_passive_omtr &
[ INPUT.RELS.LIST < [ ], [ PRED "~._n_" ], ... > ].

drop_cause_mt := causative-inchoative_omtr &
[ INPUT.RELS.LIST < [ PRED "_drop_v_cause_rel" ], ... >,
  OUTPUT.RELS <! [ PRED "_drop_v_1_rel" ] !> ].

break_cause_mt := causative-inchoative_omtr &
[ INPUT.RELS.LIST < [ PRED "_break_v_cause_rel" ], ... >,
  OUTPUT.RELS <! [ PRED "_break_v_1_rel" ] !> ].

drop_fall_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_drop_v_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_fall_v_1_rel" ] !> ].

travel_go_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_travel_v_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_go_v_1_rel" ] !> ].

drive_go_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_drive_v_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_go_v_1_rel" ] !> ].

eat_have_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_eat_v_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_have_v_1_rel" ] !> ].

buy_get_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_buy_v_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_get_v_1_rel" ] !> ].

house_home_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_house_n_of_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_home_n_of-n_rel" ] !> ].

pizza_food_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_pizza_n_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_food_n_1_rel", ARG0.SORT nonhuman ] !> ].

steak_meat_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_steak_n_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_meat_n_1_rel" ] !> ].

meat_food_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_meat_n_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_food_n_1_rel", ARG0.SORT nonhuman ] !> ].

cheese_food_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_cheese_n_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_food_n_1_rel", ARG0.SORT nonhuman ] !> ].

sailor_man_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_sailor_n_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_man_n_1_rel" ] !> ].


;;; Verbs - object restriction
;;
make_cook_br_mt := word_mtr &
[ CONTEXT.RELS <! [ PRED "_breakfast_n_1_rel", ARG0 #x1 ] !>,
  INPUT.RELS <! [ PRED "_make_v_1_rel", ARG2 #x1 ] !>,
  OUTPUT.RELS <! [ PRED "_cook_v_1_rel" ] !> ].

make_cook_dn_mt := word_mtr &
[ CONTEXT.RELS <! [ PRED "_dinner_n_1_rel", ARG0 #x1 ] !>,
  INPUT.RELS <! [ PRED "_make_v_1_rel", ARG2 #x1 ] !>,
  OUTPUT.RELS <! [ PRED "_cook_v_1_rel" ] !> ].

make_cook_steak_mt := word_mtr &
[ CONTEXT.RELS <! [ PRED "_steak_n_1_rel", ARG0 #x1 ] !>,
  INPUT.RELS <! [ PRED "_make_v_1_rel", ARG2 #x1 ] !>,
  OUTPUT.RELS <! [ PRED "_cook_v_1_rel" ] !> ].

make_build_fort_mt := word_mtr &
[ CONTEXT.RELS <! [ PRED "_fort_n_1_rel", ARG0 #x1 ] !>,
  INPUT.RELS <! [ PRED "_make_v_1_rel", ARG2 #x1 ] !>,
  OUTPUT.RELS <! [ PRED "_build_v_1_rel" ] !> ].

work-on_do_homework_mt := word_mtr &
[ CONTEXT.RELS <! [ PRED "_homework_n_1_rel", ARG0 #x1 ] !>,
  INPUT.RELS <! [ PRED "_work_v_on_rel", ARG2 #x1 ] !>,
  OUTPUT.RELS <! [ PRED "_do_v_1_rel" ] !> ].

feed_give_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_feed_v_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_give_v_1_rel" ] !> ].


;; "spicy food" => "food that is spicy"
;;
mod_word_rel_clause_mt := norm_monotonic_omtr &
[ CONTEXT.RELS <! [ LBL #lbl,
		    ARG0 #x1 & ref-ind ] !>,
  INPUT.RELS <! [ LBL #lbl,
		  PRED "~._a_",
                  ARG0 #e2 & event & [ E.TENSE untensed ],
                  ARG1 #x1, ARG2 event  ] !>,
  OUTPUT.RELS <! +copy+ & [ ARG0.E [ TENSE present, ASPECT [ PRF - ] ] ] !>,
  FLAGS.EQUAL < #e2, #lbl > ].

;; "small flower" => "flower"
;; "three flowers" => "flowers"
;;
;; DPF 2013-10-16 - The [ARG2 event] on the input rel is a trick to block
;; applicability to two-argument modifiers such as compound_rel, taking
;; advantage of there being no predications that take an ARG2 of type event.
;; The alternative would be to restrict by PRED value, somehow including
;; "*_a_*" and card_rel but excluding compound_rel.  Or have two or more
;; rules to enumerate the permissible PRED values.
;; 
mod_word_deletion_mt := norm_monotonic_omtr &
[ CONTEXT.RELS <! [ LBL #lbl, ARG0 #i1 & individual ] !>,
  INPUT.RELS <! [ LBL #lbl, ARG0 #e2 & event & [ E.TENSE untensed ],
                  ARG1 #i1, ARG2 event  ] !>,
  OUTPUT.RELS <! !>,
  FLAGS.EQUAL < #e2, #lbl > ].

;; "flower in the pot" => "flower"
;; "flower pot" => "pot"
mod_phrase_deletion_mt := np_deletion_omtr &
[ FILTER.RELS <! [ LBL #h1, ARG1 #x2 ] !>,
  CONTEXT.RELS <! [ LBL #lbl, ARG0 #i1 & individual ] !>,
  INPUT [ HOOK.INDEX #ind,
	  RELS <! [ LBL #h1, ARG0 #x2 & ref-ind ],
		[ PRED quant_rel, ARG0 #x2 ],
	        [ LBL #lbl & handle, ARG0 #e2 & [ E.TENSE untensed ], 
		  ARG1 #i1, ARG2 #x2 ] !> ],
  OUTPUT [ HOOK.INDEX #ind,
	   RELS <! !> ],
  FLAGS.SUBSUME < #x2, #h1 > ].

pet_animal_ch_deletion_mt := compound_head_deletion_omtr &
[ INPUT.RELS.LIST < [ PRED "_pet_n_1_rel" ], ... > ].

shepherd_boy_ch_deletion_mt := compound_head_deletion_omtr &
[ INPUT.RELS.LIST < [ PRED "_shepherd_n_1_rel" ], ... > ].

turkey_friend_ch_deletion_mt := compound_head_deletion_omtr &
[ INPUT.RELS.LIST < [ PRED "_turkey_n_1_rel" ], [ ], [ PRED "_friend_n_1_rel" ], ... > ].

mother_bear_ch_deletion_mt := compound_head_deletion_omtr &
[ INPUT.RELS.LIST < [ PRED "_mother_n_of_rel" ], ... >,
  OUTPUT.RELS <! [ ARG0.PNG.GEN fem ] !> ].

baby_bear_ch_deletion_mt := compound_head_deletion_omtr &
[ INPUT.RELS.LIST < [ PRED "_baby_n_1_rel" ], ... > ].

bear_cub_ch_deletion_mt := compound_head_deletion_omtr &
[ INPUT.RELS.LIST < [ PRED "_bear_n_1_rel" ], ... > ].

chile_plant_ch_deletion_mt := compound_head_deletion_omtr &
[ INPUT.RELS.LIST < [ PRED "_chile_n_1_rel" ], ... > ].

tomato_plant_ch_deletion_mt := compound_head_deletion_omtr &
[ INPUT.RELS.LIST < [ PRED "_tomato_n_1_rel" ], ... > ].

;; |Xhosa people| => |Xhosa|
named_people_ch_deletion_mt := compound_head_deletion_omtr &
[ INPUT.RELS.LIST < [ PRED named_rel, CARG #carg ], [ ],
		    [ PRED "_people_n_of_rel" ], ... >,
  OUTPUT.RELS <! [ CARG #carg ] !> ].

;; "Wednesday night" => "Wednesday"
morning_deletion_mt := day_part_deletion_omtr &
 [ INPUT.RELS.LIST.FIRST.PRED "_morning_n_of_rel" ].

afternoon_deletion_mt := day_part_deletion_omtr &
 [ INPUT.RELS.LIST.FIRST.PRED "_afternoon_n_of_rel" ].

evening_deletion_mt := day_part_deletion_omtr &
 [ INPUT.RELS.LIST.FIRST.PRED "_evening_n_of_rel" ].

night_deletion_mt := day_part_deletion_omtr &
 [ INPUT.RELS.LIST.FIRST.PRED "_night_n_of_rel" ].

poss_ppof_mt := possessive_ppof_omtr &
[ INPUT.HOOK.INDEX #ind,
  OUTPUT.HOOK.INDEX #ind ].

appos_2_deletion_mt := appos_deletion_omtr &
[ INPUT.RELS <! [ ], [ ], [ ] !>,
  OUTPUT.RELS <! !> ].

appos_1_deletion_mt := appos_1_deletion_omtr &
[ INPUT.RELS.LIST.FIRST.PRED  "~._n_",
  OUTPUT.RELS.LIST.FIRST.ARG0.PNG.GEN real_gender ].

appos_1_named_deletion_mt := appos_1_deletion_omtr &
[ INPUT.RELS.LIST.FIRST [ PRED named_rel, CARG #carg ],
  OUTPUT.RELS.LIST.FIRST.CARG #carg ].

;; |we baked Kim a cake.| => |we baked a cake.|
;;
dative_deletion_mt := dative_object_deletion_omtr &
[ INPUT.RELS.LIST < [ ARG2 #x2, ARG3 #x3 ], [ ARG0 #x3 ], ... >,
  OUTPUT.RELS <! [ ARG2 #x2 ] !> ].

;; This one seems dubious: don't want |we baked him|, |we sent her|
;; So block for now, and remind ourselves of where it is useful, if at all.
#|
dative_dobj_deletion_mt := dative_object_deletion_omtr &
[ INPUT.RELS.LIST < [ ARG2 #x2, ARG3 #x3 ], [ ARG0 #x2 ], ... >,
  OUTPUT.RELS <! [ ARG2 #x3 ] !> ].
|#

;; "the flowers" => "flowers"
determiner_deletion_pl_mt := quantifier_substitution_omtr &
[ INPUT [ HOOK.INDEX #ind,
	  RELS <! [ PRED explicit_q_rel, ARG0.PNG.PN 3p ] !> ],
  OUTPUT [ HOOK.INDEX #ind,
	   RELS <! [ PRED implicit_q_rel ] !> ] ].

determiner_deletion_ms_mt := quantifier_substitution_omtr &
[ INPUT [ HOOK.INDEX #ind,
	  RELS <! [ PRED explicit_q_rel, ARG0 [ PNG.PN 3s, IND - ] ] !> ],
  OUTPUT [ HOOK.INDEX #ind,
	   RELS <! [ PRED implicit_q_rel, ARG0.IND bool ] !> ] ].

;; "both flowers" => "the flowers"
;; ? "both flowers" => "both (of) the flowers"
;;
both_the_subst_mt := quantifier_substitution_omtr &
[ INPUT [ HOOK.INDEX #ind,
	  RELS <! [ PRED _both_q_rel ] !> ],
  OUTPUT [ HOOK.INDEX #ind,
	   RELS <! [ PRED _the_q_rel ] !> ] ].

the_a_subst_mt := quantifier_substitution_omtr &
[ INPUT [ HOOK.INDEX #ind,
	  RELS <! [ PRED _the_q_rel, ARG0 [ PNG.PN 3s, IND + ] ] !> ],
  OUTPUT [ HOOK.INDEX #ind,
	   RELS <! [ PRED _a_q_rel ] !> ] ].

;; "in the summer" => "in summer"
the_season_subst_mt := quantifier_substitution_omtr &
[ CONTEXT.RELS <! [ PRED season_rel ] !>,
  INPUT [ HOOK.INDEX #ind,
	  RELS <! [ PRED _the_q_rel ] !> ],
  OUTPUT [ HOOK.INDEX #ind,
	   RELS <! [ PRED udef_q_rel, ARG0.IND - ] !> ] ].

;; "the flowers" => "they", "the book" => "it"
;; DPF 2015-04-03 - Divided into two rules, one for singular that preserves
;; GEN, and one for plural that drops gender, so we can still generate with
;; |they, them, their| with GEN unspecified.
;;
pronoun_sg_subst_mt := pronoun_substitution_omtr &
[ INPUT.RELS.LIST < [ PRED "~._n_", ARG0.PNG.PN sg ], ... >,
  OUTPUT.RELS.LIST < [ ARG0.IND bool ], ... > ].

;; Drop gender for plurals
pronoun_pl_subst_mt := pronoun_substitution_omtr &
[ INPUT.RELS.LIST < [ PRED "~._n_", ARG0.PNG.PN pl ], ... >,
  OUTPUT.RELS.LIST < [ ARG0 [ PNG.GEN real_gender, IND bool ] ], ... > ].

;; family: they
pronoun_grp_subst_mt := pronoun_substitution_omtr &
[ INPUT.RELS.LIST < [ PRED "_family_n_of_rel", ARG0.PNG.PN sg ], ... >,
  OUTPUT.RELS.LIST < [ ARG0 [ PNG [ PN 3p, GEN real_gender ], IND bool ] ], ... > ].

pronoun_name_subst_mt := norm_monotonic_omtr &
[ FILTER.RELS <! [ PRED compound_rel, LBL #h1 ] !>,
  INPUT.RELS <! [ PRED gen_named_rel, LBL #h1, 
		  ARG0 #x1 & ref-ind & [ PNG.PN 3, PT std ] ],
                [ PRED quant_rel, LBL #h2 & handle, ARG0 #x1,
		  RSTR #h3 & handle, BODY #h4 & handle ] !>,
  OUTPUT.RELS <! [ PRED pron_rel, LBL #h1, ARG0 #x1 & [ PT std ] ],
                 [ PRED pronoun_q_rel, LBL #h2, ARG0 #x1, RSTR #h3, 
		   BODY #h4 ] !>,
  FLAGS.EQUAL < #h1 > ].

;; "are growing" => "are"
verb_ellipsis_mt := norm_monotonic_omtr &
[ INPUT.RELS <! [ PRED "~._[v|a]_", LBL #h1, ARG0 #e2, ARG1 #x3 ] !>,
  OUTPUT.RELS <! [ PRED ellipsis_ref_rel, LBL #h1, 
		   ARG0 #e2 & [ E.ASPECT.PROGR - ], ARG1 #x3 ] !>,
  FLAGS.EQUAL < #e2, #h1 > ].

;; "in the garden" => "there"
locative_anaphora_mt := norm_monotonic_omtr &
[ INPUT.RELS <! [ PRED nontemp_prep_rel, LBL #h1, ARG0 #e2, 
                  ARG1 #i3, ARG2 #x4 ],
                [ PRED "~._n_", LBL #h7, ARG0 #x4 ],
		[ PRED def_or_proper_q_rel, ARG0 #x4, RSTR #h5, BODY #h6 ] !>,
  OUTPUT.RELS <! [ PRED loc_nonsp_rel, LBL #h1, ARG0 #e2, ARG1 #i3, ARG2 #x8 ],
                [ PRED place_n_rel, LBL #h7, ARG0 #x8  ],
		[ PRED def_implicit_q_rel, ARG0 #x8, RSTR #h5, BODY #h6 ],
		[ PRED _there_a_1_rel, LBL #h7, 
		  ARG0 event & 
		       [ E [ TENSE untensed, ASPECT [ PROGR -, PRF - ] ] ],
		  ARG1 #x8 ] !> ].

prog_nonprog_mt := norm_monotonic_omtr &
[ INPUT.RELS <! [ PRED "~._v_", ARG0 #e2 & [ E.ASPECT.PROGR + ] ] !>,
  OUTPUT.RELS <! +copy+ & [ ARG0.E.ASPECT.PROGR - ] !>,
  FLAGS.EQUAL < #e2 > ].

coord_vp_prop_mt := coord_vp_named_mtr.
coord_vp_pron_mt := coord_vp_pron_mtr.
coord_vp_noun_mt := coord_vp_noun_mtr.

#|
;;; Verbs - full lexical congruence

start_commence_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_start_v_cause_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_commence_v_1_rel" ] !> ].

shower_bathe_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_shower_v_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_bathe_v_1_rel" ] !> ].

bathe_wash_mt := word_mtr &
[ INPUT.RELS <! [ PRED "_bathe_v_1_rel" ] !>,
  OUTPUT.RELS <! [ PRED "_wash_v_1_rel" ] !> ].

|#

and_reverse_mt := conj_reverse_mtr &
[ INPUT.RELS <! [ PRED _and_c_nrev_rel ] !>,
  OUTPUT.RELS <! [ PRED _and_c_rev_rel ] !> ].

or_reverse_mt := conj_reverse_mtr &
[ INPUT.RELS <! [ PRED _or_c_nrev_rel ] !>,
  OUTPUT.RELS <! [ PRED _or_c_rev_rel ] !> ].

but_reverse_mt := conj_reverse_mtr &
[ INPUT.RELS <! [ PRED _but_c_nrev_rel ] !>,
  OUTPUT.RELS <! [ PRED _but_c_rev_rel ] !> ].

pro_subj_noconj_mt := pro_subj_mtr.
pro_subj_conj_mt := conjnct_pro_coord_subj_mtr.