-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathaxiom_sentencelist.pl
113 lines (91 loc) · 3.35 KB
/
axiom_sentencelist.pl
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
% This file is part of the OWL verbalizer.
% Copyright 2008-2011, Kaarel Kaljurand <[email protected]>.
%
% The OWL verbalizer is free software: you can redistribute it and/or modify it
% under the terms of the GNU Lesser General Public License as published by the
% Free Software Foundation, either version 3 of the License, or (at your option) any later version.
%
% The OWL verbalizer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
% without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% See the GNU Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public License along with the
% OWL verbalizer. If not, see http://www.gnu.org/licenses/.
:- module(owlfss_acetext, [
axiomlist_sentencelist/2,
axiom_sentencelist/2
]).
/** <module> OWL 2 verbalizer
@author Kaarel Kaljurand
@version 2011-06-13
*/
:- use_module(table_1, [
table_1/2
]).
:- use_module(rewrite_subclassof, [
rewrite_subclassof/2
]).
:- use_module(owlace_dcg, [
owl_ace/2
]).
%% axiomlist_sentencelist(+AxiomList:list, -AxiomSentenceList:list) is det.
%
% @param AxiomList is a list of OWL axioms
% @param AxiomSentenceList is a list of Axiom-SentenceList pairs
%
axiomlist_sentencelist([], []).
axiomlist_sentencelist([Axiom | AxiomList], [Axiom-SentenceList | AxiomSentenceList]) :-
axiom_sentencelist(Axiom, SentenceList),
axiomlist_sentencelist(AxiomList, AxiomSentenceList).
%% axiom_sentencelist(+Axiom:term, -SentenceList:list) is det.
%
% Maps the given axiom to its verbalization (list of ACE sentences).
% If the axiom is non-logical then returns 'ignored', if the verbalization
% fails then returns 'unsupported'.
%
% @param Axiom is an OWL axiom
% @param SentenceList is a list of ACE sentences
%
% @bug instead of returning atoms throw exceptions instead
%
axiom_sentencelist(Axiom, ignored) :-
is_ignore(Axiom),
!.
axiom_sentencelist(Axiom, SentenceList) :-
table_1(Axiom, EquivalentAxioms),
!,
axiomlist_sentencelist_x(EquivalentAxioms, SentenceList).
axiom_sentencelist(_Axiom, unsupported).
%% axiomlist_sentencelist_x(+AxiomList:list, -SentenceList:list) is det.
%
% @param AxiomList is a list of OWL axioms
% @param SentenceList is a list of ACE sentences
%
axiomlist_sentencelist_x([], []).
axiomlist_sentencelist_x([Axiom | AxiomList], [Sentence | SentenceList]) :-
rewrite_subclassof(Axiom, RewrittenAxiom),
owl_ace(RewrittenAxiom, Sentence),
!,
axiomlist_sentencelist_x(AxiomList, SentenceList).
axiomlist_sentencelist_x([UnsupportedAxiom | AxiomList], [ErrorMessage | SentenceList]) :-
with_output_to(atom(ErrorMessage), format("/* BUG: axiom too complex: ~w */", [UnsupportedAxiom])),
axiomlist_sentencelist_x(AxiomList, SentenceList).
%% is_ignore(+Axiom:term) is det.
%
% Certain non-logical axioms are ignored.
%
% Note that we experimentally ignored the SubClassOf-axioms
% where the super class is owl:Thing as this is the case without saying.
% However, this does not seem to be a good idea in the context of synchronizing in ACE View.
%
% @param Axiom is an OWL axiom
%
is_ignore('Declaration'(_)).
is_ignore('Prefix'(_, _)).
is_ignore('AnnotationAssertion'(_, _, _)).
is_ignore('Import'(_)).
%is_ignore('SubClassOf'(_, 'Class'('owl:Thing'))).
% @deprecated
is_ignore('EntityAnnotation'(_, _)).
is_ignore('Annotation'(_, _)).
is_ignore('Imports'(_)).