14
15
16:- module(drs_to_owlswrl, [
17 drs_to_owlswrl/2,
18 drs_to_owlswrl/4
19 ]). 20
21:- use_module(drs_to_owlswrl_core, [
22 condlist_to_dlquery/2,
23 condition_oneof/3,
24 condlist_axiomlist_with_cheat/3
25 ]). 26
27:- use_module('../drs_to_drslist', [
28 drs_to_drslist/2
29 ]). 30
31:- use_module('../drs_to_sdrs', [
32 drs_to_sdrs/2
33 ]). 34
35:- use_module('../../logger/error_logger', [
36 add_error_message/4,
37 clear_messages/1
38 ]). 39
40:- use_module(drs_to_owldrs, [
41 drs_to_owldrs/2
42 ]). 43
44:- use_module(transform_anonymous, [
45 transform_anonymous/2
46 ]).
122
123
125:- op(400, fx, -). 126:- op(500, xfx, =>). 127:- op(500, xfx, v).
144drs_to_owlswrl(Drs, Owl) :-
145 ontology_iri(IRI),
146 drs_to_owlswrl(Drs, IRI, Owl).
147
148drs_to_owlswrl(Drs, IRI, Owl) :-
149 drs_to_owlswrl(Drs, IRI, 'Ontology from an ACE text.', Owl).
150
151drs_to_owlswrl(Drs, IRI, Comment, 'Ontology'(IRI, Axioms)) :-
152 debug(sentence, "ACE: ~w~n", [Comment]),
153 drs_to_drslist(Drs, DrsList),
154 maplist(drs_to_owlswrl_x, DrsList, AxiomList),
155 append(AxiomList, Axioms).
156
157drs_to_owlswrl(_, _, _, 'Ontology'('', [])).
158
159
160drs_to_owlswrl_x(Drs, Axioms) :-
161 copy_term(Drs, DrsCopy),
162 clear_messages(owl),
163 drs_to_sdrs(DrsCopy, SDrsCopy),
164 drs_to_owldrs(SDrsCopy, OwlDrs),
165 numbervars(OwlDrs, 1, _),
166 debug(owldrs, "OWL DRS: ~q~n", [OwlDrs]),
167 drs_to_axioms(OwlDrs, Axioms),
168 !.
169
170
172drs_to_axioms(Drs, Axioms) :-
173 process_question(Drs, Axioms).
174
176drs_to_axioms(Drs, Axioms) :-
177 findall(
178 ref_oneof(X, OneOf),
179 (
180 member(Condition, Drs),
181 condition_oneof(Condition, X, OneOf)
182 ),
183 RefList
184 ),
185 debug(sentence, "Toplevel: ~w~n", [RefList]),
186 condlist_axiomlist_with_cheat(Drs, RefList, AL),
187 transform_anonymous(AL, Axioms).
188
189
196process_question(Conds, AxiomList) :-
197 select(question(QConds), Conds, RConds),
198 !,
199 append(QConds, RConds, FlatConds),
200 debug(d, "~w~n", [FlatConds]),
201 clear_messages(owl),
202 catch(
203 (
204 condlist_to_dlquery(FlatConds, Class),
205 AxiomList = ['SubClassOf'(Class, owl:'Thing')]
206 ),
207 Catcher,
208 (
209 AxiomList = [],
210 parse_exception(Catcher, Message, Lemma, SId/TId),
211 add_error_message(owl, SId-TId, Lemma, Message)
212 )
213 ).
214
215parse_exception(error(Message, context(_Pred, query(_, Lemma)-Id)), Message, Lemma, Id) :- !.
216parse_exception(error(Message, context(_Pred, _Arg)), Message, '', ''/'').
223ontology_iri('http://attempto.ifi.uzh.ch/ontologies/owlswrl/test')
Attempto DRS to OWL 2/SWRL translator
Translate an Attempto DRS into Web Ontology Language (OWL 2), or if this fails then to Semantic Web Rule Language (SWRL).
If the translation fails then we search for errors by traversing the respective structure (e.g. implication) again. Note that the error capture is not completely implemented. Sometimes the translation simply fails and no explanatory messages are asserted.
TODO
:*/