forked from conceptsinmotion/thea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
owl2_classifier.pl
84 lines (55 loc) · 1.71 KB
/
owl2_classifier.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
/* -*- Mode: Prolog -*- */
:- module(owl2_classifier,
[
generate_class_expressions/0,
optimal_description/1
]).
:- use_module(owl2_model).
:- use_module(owl2_basic_reasoner).
% failure-driven loop to avoid stack overflow
generate_class_expressions :-
generate_class_expression(C),
\+ generated(C),
format('~q.~n',[C]),
assert(generated(C)),
fail.
generate_class_expressions :-
format('%% done.~n').
generate_class_expression( intersectionOf(XC,someValuesFrom(P,YC)) ):-
property_assertion_least_common_ancestor(P,_,_,XC,YC).
%% EVERYTHING BELOW HERE IS OLD
description_instance(D,I) :-
entailed(classAssertion(D,I)).
description_instances(D,IL) :-
setof(I,description_instance(D,I),IL).
candidate_description(intersectionOf([X,someValuesFrom(P,Y)])) :-
propertyAssertion(P,XI,YI),
classAssertion(XC,XI),
classAssertion(YC,YI),
entailed(subClassOf(XC,X)),
class(X),
entailed(subClassOf(YC,Y)), % TODO : subProp
class(Y).
optimal_description(D) :-
specific_description(D),
\+ ((entailed(subClassOf(D,Z)), % TODO: add to reasoner
entailed(subClassOf(Z,D)))).
specific_description(D) :-
candidate_description(D),
description_instances(D,DIL),
\+ ((candidate_description(D2),
entailed(subClassOf(D2,D)),
D2\=D,
description_instances(D2,DIL))),
writeln(D-DIL).
/** <module> Various classifierity predicates for OWL ontologies
---+ Synopsis
==
:- use_module(bio(owl2_classifier)).
%
demo:-
nl.
==
---+ Details
---+ Additional Information
*/