aboutsummaryrefslogtreecommitdiff
path: root/src/org/semanticweb/karma2/profile/ELHOProfile.java
diff options
context:
space:
mode:
authorFederico Igne <federico.igne@cs.ox.ac.uk>2022-05-10 18:17:06 +0100
committerFederico Igne <federico.igne@cs.ox.ac.uk>2022-05-11 12:34:47 +0100
commit17bd9beaf7f358a44e5bf36a5855fe6727d506dc (patch)
tree47e9310a0cff869d9ec017dcb2c81876407782c8 /src/org/semanticweb/karma2/profile/ELHOProfile.java
parent8651164cd632a5db310b457ce32d4fbc97bdc41c (diff)
downloadACQuA-17bd9beaf7f358a44e5bf36a5855fe6727d506dc.tar.gz
ACQuA-17bd9beaf7f358a44e5bf36a5855fe6727d506dc.zip
[pagoda] Move project to Scala
This commit includes a few changes: - The repository still uses Maven to manage dependency but it is now a Scala project. - The code has been ported from OWLAPI 3.4.10 to 5.1.20 - A proof of concept program using both RSAComb and PAGOdA has been added.
Diffstat (limited to 'src/org/semanticweb/karma2/profile/ELHOProfile.java')
-rw-r--r--src/org/semanticweb/karma2/profile/ELHOProfile.java281
1 files changed, 0 insertions, 281 deletions
diff --git a/src/org/semanticweb/karma2/profile/ELHOProfile.java b/src/org/semanticweb/karma2/profile/ELHOProfile.java
deleted file mode 100644
index fb68b05..0000000
--- a/src/org/semanticweb/karma2/profile/ELHOProfile.java
+++ /dev/null
@@ -1,281 +0,0 @@
1package org.semanticweb.karma2.profile;
2
3import java.util.HashSet;
4import java.util.Iterator;
5import java.util.Set;
6
7import org.semanticweb.owlapi.model.AxiomType;
8import org.semanticweb.owlapi.model.IRI;
9import org.semanticweb.owlapi.model.OWLAxiom;
10import org.semanticweb.owlapi.model.OWLClassExpression;
11import org.semanticweb.owlapi.model.OWLDataHasValue;
12import org.semanticweb.owlapi.model.OWLDataIntersectionOf;
13import org.semanticweb.owlapi.model.OWLDataOneOf;
14import org.semanticweb.owlapi.model.OWLDataProperty;
15import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom;
16import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom;
17import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom;
18import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom;
19import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom;
20import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom;
21import org.semanticweb.owlapi.model.OWLHasKeyAxiom;
22import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom;
23import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom;
24import org.semanticweb.owlapi.model.OWLObjectHasSelf;
25import org.semanticweb.owlapi.model.OWLObjectMinCardinality;
26import org.semanticweb.owlapi.model.OWLObjectOneOf;
27import org.semanticweb.owlapi.model.OWLOntology;
28import org.semanticweb.owlapi.model.OWLOntologyCreationException;
29import org.semanticweb.owlapi.model.OWLOntologyManager;
30import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom;
31import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom;
32import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom;
33import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom;
34import org.semanticweb.owlapi.profiles.OWL2ELProfile;
35import org.semanticweb.owlapi.profiles.OWLProfile;
36import org.semanticweb.owlapi.profiles.OWLProfileReport;
37import org.semanticweb.owlapi.profiles.OWLProfileViolation;
38import org.semanticweb.owlapi.profiles.UseOfDataOneOfWithMultipleLiterals;
39import org.semanticweb.owlapi.profiles.UseOfIllegalAxiom;
40import org.semanticweb.owlapi.profiles.UseOfIllegalClassExpression;
41import org.semanticweb.owlapi.profiles.UseOfObjectOneOfWithMultipleIndividuals;
42import org.semanticweb.owlapi.util.OWLObjectPropertyManager;
43import org.semanticweb.owlapi.util.OWLOntologyWalker;
44import org.semanticweb.owlapi.util.OWLOntologyWalkerVisitor;
45import uk.ac.ox.cs.pagoda.util.Utility;
46
47public class ELHOProfile implements OWLProfile {
48
49 public OWLOntology getFragment(OWLOntology ontology) {
50 OWLOntologyManager manager = ontology.getOWLOntologyManager();
51 OWLOntology elhoOntology = null;
52 try {
53 Utility.logDebug("OntologyID: " + ontology.getOntologyID());
54 try {
55 String ontologyIRI = ontology.getOntologyID().getOntologyIRI().toString();
56 if (ontologyIRI.contains(".owl"))
57 ontologyIRI = ontologyIRI.replace(".owl", "-elho.owl");
58 else
59 ontologyIRI = ontologyIRI + "elho";
60 elhoOntology = manager.createOntology(IRI.create(ontologyIRI));
61 } catch (NullPointerException e) {
62// e.printStackTrace();
63 elhoOntology = manager.createOntology();
64 }
65
66 } catch (OWLOntologyCreationException e) {
67 e.printStackTrace();
68 }
69 for (OWLOntology onto: ontology.getImportsClosure())
70 manager.addAxioms(elhoOntology, onto.getAxioms());
71
72 // TODO to be checked ...
73 manager.removeAxioms(elhoOntology, elhoOntology.getAxioms(AxiomType.DIFFERENT_INDIVIDUALS));
74
75 OWLProfileReport report = checkOntology(elhoOntology);
76
77 for (OWLProfileViolation violation: report.getViolations()) {
78 OWLAxiom axiom = violation.getAxiom();
79 manager.removeAxiom(elhoOntology, axiom);
80 }
81 Utility.logDebug("ELHO fragment extracted ... ");
82
83 return elhoOntology;
84 }
85
86 @Override
87 public OWLProfileReport checkOntology(OWLOntology ontology) {
88 OWL2ELProfile profile = new OWL2ELProfile();
89 OWLProfileReport report = profile.checkOntology(ontology);
90 Set<OWLProfileViolation> violations = new HashSet<OWLProfileViolation>();
91 violations.addAll(report.getViolations());
92 MyOWLOntologyWalker ontologyWalker = new MyOWLOntologyWalker(ontology.getImportsClosure());
93 ELHOProfileObjectVisitor visitor = new ELHOProfileObjectVisitor(ontologyWalker, ontology.getOWLOntologyManager());
94 ontologyWalker.walkStructure(visitor);
95
96 for (Iterator<OWLProfileViolation> iter = violations.iterator(); iter.hasNext(); ) {
97 OWLProfileViolation vio = iter.next();
98 if (vio instanceof UseOfIllegalClassExpression) {
99 OWLClassExpression exp = ((UseOfIllegalClassExpression) vio).getOWLClassExpression();
100 if (exp instanceof OWLObjectMinCardinality && ((OWLObjectMinCardinality) exp).getCardinality() == 1)
101 iter.remove();
102 }
103 }
104
105 violations.addAll(visitor.getProfileViolations());
106 return new OWLProfileReport(this, violations);
107 }
108
109 @Override
110 public String getName() {
111 return "ELHO";
112 }
113
114 protected class ELHOProfileObjectVisitor extends OWLOntologyWalkerVisitor<Object> {
115
116 private final OWLOntologyManager man;
117
118 private OWLObjectPropertyManager propertyManager;
119
120 private final Set<OWLProfileViolation> profileViolations = new HashSet<OWLProfileViolation>();
121
122 public ELHOProfileObjectVisitor(OWLOntologyWalker walker, OWLOntologyManager man) {
123 super(walker);
124 this.man = man;
125 }
126
127 public Set<OWLProfileViolation> getProfileViolations() {
128 return new HashSet<OWLProfileViolation>(profileViolations);
129 }
130
131 @SuppressWarnings("unused")
132 private OWLObjectPropertyManager getPropertyManager() {
133 if (propertyManager == null) {
134 propertyManager = new OWLObjectPropertyManager(man, getCurrentOntology());
135 }
136 return propertyManager;
137 }
138
139
140
141 @Override
142 public Object visit(OWLDataProperty p) {
143 profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom()));
144 return null;
145 }
146
147
148 @Override
149 public Object visit(OWLObjectOneOf desc) {
150 if (desc.getIndividuals().size() != 1) {
151 profileViolations.add(new UseOfObjectOneOfWithMultipleIndividuals(getCurrentOntology(), getCurrentAxiom(), desc));
152 }
153 return null;
154 }
155
156 @Override
157 public Object visit(OWLDataHasValue desc) {
158 profileViolations.add(new UseOfIllegalClassExpression(getCurrentOntology(), getCurrentAxiom(), desc));
159 return null;
160 }
161
162 @Override
163 public Object visit(OWLDataSomeValuesFrom desc) {
164 profileViolations.add(new UseOfIllegalClassExpression(getCurrentOntology(), getCurrentAxiom(), desc));
165 return null;
166 }
167
168 @Override
169 public Object visit(OWLDataIntersectionOf desc) {
170 profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom()));
171 return null;
172 }
173
174 @Override
175 public Object visit(OWLSubDataPropertyOfAxiom desc) {
176 profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom()));
177 return null;
178 }
179
180 @Override
181 public Object visit(OWLEquivalentDataPropertiesAxiom desc) {
182 profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom()));
183 return null;
184 }
185
186 @Override
187 public Object visit(OWLTransitiveObjectPropertyAxiom desc) {
188 profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom()));
189 return null;
190 }
191
192 @Override
193 public Object visit(OWLReflexiveObjectPropertyAxiom desc) {
194 profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom()));
195 return null;
196 }
197
198 @Override
199 public Object visit(OWLDataPropertyDomainAxiom desc) {
200 profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom()));
201 return null;
202 }
203
204 @Override
205 public Object visit(OWLDataPropertyRangeAxiom desc) {
206 profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom()));
207 return null;
208 }
209
210
211
212 @Override
213 public Object visit(OWLDataPropertyAssertionAxiom desc) {
214 profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom()));
215 return null;
216 }
217
218 @Override
219 public Object visit(OWLNegativeDataPropertyAssertionAxiom desc) {
220 profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom()));
221 return null;
222 }
223
224 @Override
225 public Object visit(OWLNegativeObjectPropertyAssertionAxiom desc) {
226 profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom()));
227 return null;
228 }
229
230 @Override
231 public Object visit(OWLFunctionalDataPropertyAxiom desc) {
232 profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom()));
233 return null;
234 }
235
236 @Override
237 public Object visit(OWLHasKeyAxiom desc) {
238 profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom()));
239 return null;
240 }
241
242
243
244
245 @Override
246 public Object visit(OWLObjectHasSelf node) {
247 profileViolations.add(new UseOfIllegalClassExpression(getCurrentOntology(), getCurrentAxiom(), node));
248 return null;
249 }
250
251
252 @Override
253 public Object visit(OWLDataOneOf node) {
254 profileViolations.add(new UseOfDataOneOfWithMultipleLiterals(getCurrentOntology(), getCurrentAxiom(), node));
255 return null;
256 }
257
258
259
260 @Override
261 public Object visit(OWLSubPropertyChainOfAxiom axiom) {
262 profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom()));
263
264 return null;
265 }
266
267 @Override
268 public Object visit(OWLOntology ontology) {
269 propertyManager = null;
270 return null;
271 }
272 }
273
274 @Override
275 public IRI getIRI() {
276 return null;
277 }
278
279
280}
281