14
15
16:- module(drs_utils, [
17 get_toplevel_object_referents/2
18 ]).
39get_toplevel_object_referents(ConditionList, toplevel(ReferentList, SubjectList, ObjectList, NamedList)) :-
40 get_toplevel_object_referents_x(
41 ConditionList,
42 toplevel(
43 -([], ReferentList),
44 -([], SubjectList),
45 -([], ObjectList),
46 -([], NamedList)
47 )
48 ).
56get_toplevel_object_referents_x([], toplevel(R-R, S-S, O-O, N-N)).
57
58get_toplevel_object_referents_x([Condition | ConditionList], toplevel(R1-R2, S1-S2, O1-O2, N1-N2)) :-
59 condition_referents(Condition, toplevel(R1-RT, S1-ST, O1-OT, N1-NT)),
60 get_toplevel_object_referents_x(ConditionList, toplevel(RT-R2, ST-S2, OT-O2, NT-N2)).
73condition_referents(object(Ref, Noun, Type, _, _Eq, na)-_, toplevel(R-[Ref | R], S-S, O-O, N-N)) :-
74 Noun \= na,
75 Type \= named,
76 Type \= mass,
77 !.
78
80condition_referents(object(Ref, na, _, _, _, _)-_, toplevel(R-[Ref | R], S-S, O-O, N1-[Ref | N1])) :- !.
81
83condition_referents(object(Ref, _, mass, _, _, _)-_, toplevel(R-[Ref | R], S-S, O-O, N1-[Ref | N1])) :- !.
84
86condition_referents(has_part(_, Ref)-_, toplevel(R-R, S-S, O-O, N1-[Ref | N1])) :- !.
87
89condition_referents(relation(Ref1, of, Ref2)-_, toplevel(R-R, S-S, O-O, N-[Ref1, Ref2 | N])) :- !.
90
92condition_referents(query(Ref, _)-_, toplevel(R-[Ref | R], S-S, O-O, N1-[Ref | N1])) :- !.
93
95
96condition_referents(predicate(_, _, Ref)-_, toplevel(R-R, S-[Ref | S], O-O, N-N)) :-
97 var(Ref),
98 !.
99
100condition_referents(predicate(_, _, Ref, O1)-_, toplevel(R-R, S-[Ref | S], O-[O1 | O], N-N)) :-
101 var(Ref), var(O1),
102 !.
103
104condition_referents(predicate(_, _, Ref, O1)-_, toplevel(R-R, S-[Ref | S], O-O, N-N)) :-
105 var(Ref), nonvar(O1),
106 !.
107
108condition_referents(predicate(_, _, Ref, O1)-_, toplevel(R-R, S-S, O-[O1 | O], N-N)) :-
109 nonvar(Ref), var(O1),
110 !.
111
112condition_referents(predicate(_, _, Ref, O1, O2)-_, toplevel(R-R, S-[Ref | S], O-[O1, O2 | O], N-N)) :-
113 var(Ref), var(O1), var(O2),
114 !.
115
116condition_referents(predicate(_, _, Ref, O1, O2)-_, toplevel(R-R, S-S, O-[O1, O2 | O], N-N)) :-
117 nonvar(Ref), var(O1), var(O2),
118 !.
119
120condition_referents(predicate(_, _, Ref, O1, O2)-_, toplevel(R-R, S-[Ref | S], O-[O2 | O], N-N)) :-
121 var(Ref), nonvar(O1), var(O2),
122 !.
123
124condition_referents(predicate(_, _, Ref, O1, O2)-_, toplevel(R-R, S-[Ref | S], O-[O1 | O], N-N)) :-
125 var(Ref), var(O1), nonvar(O2),
126 !.
127
128condition_referents(predicate(_, _, Ref, O1, O2)-_, toplevel(R-R, S-S, O-[O2 | O], N-N)) :-
129 nonvar(Ref), nonvar(O1), var(O2),
130 !.
131
132condition_referents(predicate(_, _, Ref, O1, O2)-_, toplevel(R-R, S-S, O-[O1 | O], N-N)) :-
133 nonvar(Ref), var(O1), nonvar(O2),
134 !.
135
136condition_referents(predicate(_, _, Ref, O1, O2)-_, toplevel(R-R, S-[Ref | S], O-O, N-N)) :-
137 var(Ref), nonvar(O1), nonvar(O2),
138 !.
139
140condition_referents(_, toplevel(R-R, S-S, O-O, N-N))
Attempto DRS utils
*/