aboutsummaryrefslogtreecommitdiff
path: root/src/uk/ac/ox/cs/pagoda/owl/OWLHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/owl/OWLHelper.java')
-rw-r--r--src/uk/ac/ox/cs/pagoda/owl/OWLHelper.java471
1 files changed, 471 insertions, 0 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/owl/OWLHelper.java b/src/uk/ac/ox/cs/pagoda/owl/OWLHelper.java
new file mode 100644
index 0000000..fd20f88
--- /dev/null
+++ b/src/uk/ac/ox/cs/pagoda/owl/OWLHelper.java
@@ -0,0 +1,471 @@
1package uk.ac.ox.cs.pagoda.owl;
2
3import java.io.File;
4import java.io.FileOutputStream;
5import java.io.IOException;
6import java.util.HashSet;
7import java.util.LinkedList;
8import java.util.List;
9import java.util.Set;
10
11import org.semanticweb.HermiT.model.Atom;
12import org.semanticweb.HermiT.model.AtomicConcept;
13import org.semanticweb.HermiT.model.AtomicRole;
14import org.semanticweb.HermiT.model.DLClause;
15import org.semanticweb.HermiT.model.Individual;
16import org.semanticweb.karma2.profile.ELHOProfile;
17import org.semanticweb.owlapi.apibinding.OWLManager;
18import org.semanticweb.owlapi.model.AddImport;
19import org.semanticweb.owlapi.model.IRI;
20import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom;
21import org.semanticweb.owlapi.model.OWLAnnotationSubject;
22import org.semanticweb.owlapi.model.OWLAnnotationValue;
23import org.semanticweb.owlapi.model.OWLAnonymousIndividual;
24import org.semanticweb.owlapi.model.OWLAxiom;
25import org.semanticweb.owlapi.model.OWLClass;
26import org.semanticweb.owlapi.model.OWLClassExpression;
27import org.semanticweb.owlapi.model.OWLDataFactory;
28import org.semanticweb.owlapi.model.OWLDataProperty;
29import org.semanticweb.owlapi.model.OWLDatatype;
30import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom;
31import org.semanticweb.owlapi.model.OWLIndividual;
32import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom;
33import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom;
34import org.semanticweb.owlapi.model.OWLObjectMaxCardinality;
35import org.semanticweb.owlapi.model.OWLObjectMinCardinality;
36import org.semanticweb.owlapi.model.OWLObjectProperty;
37import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom;
38import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom;
39import org.semanticweb.owlapi.model.OWLObjectPropertyExpression;
40import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom;
41import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom;
42import org.semanticweb.owlapi.model.OWLOntology;
43import org.semanticweb.owlapi.model.OWLOntologyCreationException;
44import org.semanticweb.owlapi.model.OWLOntologyManager;
45import org.semanticweb.owlapi.model.OWLOntologyStorageException;
46import org.semanticweb.owlapi.model.OWLSubClassOfAxiom;
47import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom;
48import org.semanticweb.owlapi.model.UnknownOWLOntologyException;
49import org.semanticweb.owlapi.profiles.OWL2RLProfile;
50import org.semanticweb.owlapi.profiles.OWLProfileReport;
51import org.semanticweb.owlapi.profiles.OWLProfileViolation;
52import org.semanticweb.owlapi.profiles.UseOfUndeclaredClass;
53import org.semanticweb.owlapi.profiles.UseOfUndeclaredDataProperty;
54import org.semanticweb.owlapi.profiles.UseOfUndeclaredObjectProperty;
55import org.semanticweb.owlapi.util.OWLOntologyMerger;
56
57import uk.ac.ox.cs.pagoda.approx.Clause;
58import uk.ac.ox.cs.pagoda.approx.Clausifier;
59import uk.ac.ox.cs.pagoda.hermit.DLClauseHelper;
60import uk.ac.ox.cs.pagoda.util.Namespace;
61import uk.ac.ox.cs.pagoda.util.Utility;
62
63public class OWLHelper {
64
65 public static OWLOntology loadOntology(OWLOntologyManager manager, String fileName) {
66 // TODO to be uncommented to set silent missing imports ...
67// manager.setSilentMissingImportsHandling(true);
68 OWLOntology ontology = null;
69 File file = new File(fileName);
70 try {
71 ontology = manager.loadOntologyFromOntologyDocument(file);
72 } catch (OWLOntologyCreationException e) {
73 e.printStackTrace();
74 } catch (UnknownOWLOntologyException e) {
75 e.printStackTrace();
76 }
77 return ontology;
78 }
79
80 public static OWLOntology loadOntology(String fileName) {
81 return loadOntology(OWLManager.createOWLOntologyManager(), fileName);
82
83 }
84
85 public static OWLOntology getImportedOntology(OWLOntology tbox, String... dataFiles) throws OWLOntologyCreationException, OWLOntologyStorageException, IOException {
86 if (dataFiles == null || dataFiles.length == 0 || dataFiles.length == 1 && (dataFiles[0] == null || dataFiles[0].isEmpty())) return tbox;
87
88 OWLOntologyManager manager = tbox.getOWLOntologyManager();
89 OWLOntology importedOntology = manager.createOntology();
90
91 for (String dataFile: dataFiles) {
92 File data = new File(dataFile);
93 if (!data.exists())
94 Utility.logError(dataFile.toString() + " doesn't exist.");
95
96// importDeclaration(manager, importedOntology, tbox.getOntologyID().getOntologyIRI().toString());
97 importDeclaration(manager, importedOntology, Utility.toFileIRI(getOntologyPath(tbox)));
98 if (data.isDirectory()) {
99 for (File file: data.listFiles()) {
100 importDeclaration(manager, importedOntology, Utility.toFileIRI(file.getCanonicalPath()));
101 }
102 }
103 else {
104 importDeclaration(manager, importedOntology, Utility.toFileIRI(new File(dataFile).getCanonicalPath()));
105 }
106 }
107
108 String path = "./imported.owl";
109 FileOutputStream out = new FileOutputStream(path);
110 manager.saveOntology(importedOntology, out);
111 out.close();
112
113 System.out.println("In the closure: " + importedOntology.getImportsClosure().size());
114 for (OWLOntology onto: importedOntology.getImportsClosure()) {
115 System.out.println(onto.getOntologyID().toString());
116 }
117 manager.removeOntology(importedOntology);
118 manager.removeOntology(tbox);
119 System.out.println("Removed imported and tbox ontology.");
120 OWLOntologyManager newManager = OWLManager.createOWLOntologyManager();
121 importedOntology = loadOntology(newManager, path);
122 newManager.setOntologyDocumentIRI(importedOntology, IRI.create(Utility.toFileIRI(new File(path).getCanonicalPath())));
123 System.out.println("In the closure: " + importedOntology.getImportsClosure().size());
124 for (OWLOntology onto: importedOntology.getImportsClosure()) {
125 System.out.println(onto.getOntologyID().toString());
126 }
127 return importedOntology;
128 }
129
130 public static OWLOntology getMergedOntology(String ontologyFile, String dataFile) throws OWLOntologyCreationException, IOException, OWLOntologyStorageException {
131 OWLOntology tbox = loadOntology(ontologyFile);
132 OWLOntologyManager manager = tbox.getOWLOntologyManager();
133 OWLOntology mergedOntology = new OWLOntologyMerger(manager).createMergedOntology(manager, null);
134 for (OWLOntology o: manager.getOntologies())
135 if (o != mergedOntology) {
136 for (OWLAxiom axiom: o.getAxioms())
137 manager.addAxiom(mergedOntology, axiom);
138 }
139 Utility.logDebug("loaded and merged the ontology and the dataset: ");
140 return mergedOntology;
141 }
142
143 public static boolean removeAnnotations(OWLOntology inputOntology) {
144 OWLOntologyManager manager = inputOntology.getOWLOntologyManager();
145 boolean updated = false;
146 for (OWLAxiom axiom: inputOntology.getAxioms())
147 if (axiom.toString().contains("Annotation")) {
148 manager.removeAxiom(inputOntology, axiom);
149 updated = true;
150 }
151 return updated;
152 }
153
154 public static boolean correctDataTypeRangeAxioms(OWLOntology inputOntology) {
155 OWLOntologyManager manager = inputOntology.getOWLOntologyManager();
156 OWLDataFactory factory = manager.getOWLDataFactory();
157 boolean updated = false;
158 OWLClass cls;
159 OWLDatatype datatype;
160 for (OWLOntology onto: inputOntology.getImportsClosure())
161 for (OWLAxiom axiom: onto.getAxioms())
162 if (axiom instanceof OWLObjectPropertyRangeAxiom) {
163 OWLObjectPropertyRangeAxiom a = (OWLObjectPropertyRangeAxiom) axiom;
164 if (a.getRange() instanceof OWLClass && a.getProperty() instanceof OWLObjectProperty && (cls = (OWLClass) a.getRange()).toString().contains("datatype")) {
165 manager.removeAxiom(onto, axiom);
166 manager.removeAxiom(onto, factory.getOWLDeclarationAxiom(cls));
167
168 datatype = factory.getOWLDatatype(cls.getIRI());
169 manager.addAxiom(onto, factory.getOWLDeclarationAxiom(datatype));
170 manager.addAxiom(onto, factory.getOWLDataPropertyRangeAxiom(
171 factory.getOWLDataProperty(((OWLObjectProperty) a.getProperty()).getIRI()),
172 datatype));
173 }
174 }
175
176 return updated;
177 }
178
179 private static void importDeclaration(OWLOntologyManager manager, OWLOntology ontology, String location) {
180 AddImport change = new AddImport(ontology, manager.getOWLDataFactory().getOWLImportsDeclaration(IRI.create(location)));
181 manager.applyChange(change);
182 }
183
184 public static OWLClassExpression getSimplifiedDisjunction(OWLDataFactory factory, Set<OWLClassExpression> set) {
185 if (set.size() == 0)
186 return factory.getOWLNothing();
187 else if (set.size() == 1)
188 return set.iterator().next();
189 else return factory.getOWLObjectUnionOf(set);
190 }
191
192 public static OWLClassExpression getSimplifiedConjunction(OWLDataFactory factory, Set<OWLClassExpression> set) {
193 if (set.size() == 0)
194 return factory.getOWLThing();
195 else if (set.size() == 1)
196 return set.iterator().next();
197 else return factory.getOWLObjectIntersectionOf(set);
198 }
199
200 public static OWLAxiom getOWLAxiom(OWLOntology ontology, DLClause dlClause) {
201 OWLAxiom owlAxiom;
202 OWLDataFactory factory = ontology.getOWLOntologyManager().getOWLDataFactory();
203
204 dlClause = DLClauseHelper.replaceOtherBottom(dlClause);
205
206 if (dlClause.isAtomicConceptInclusion()) {
207 OWLClass subClass = factory.getOWLClass(IRI.create(((AtomicConcept) dlClause.getBodyAtom(0).getDLPredicate()).getIRI()));
208 OWLClass superClass = factory.getOWLClass(IRI.create(((AtomicConcept) dlClause.getHeadAtom(0).getDLPredicate()).getIRI()));
209 return factory.getOWLSubClassOfAxiom(subClass, superClass);
210 }
211 else if (dlClause.isAtomicRoleInclusion()) {
212 OWLObjectProperty subProp = factory.getOWLObjectProperty(IRI.create(((AtomicRole) dlClause.getBodyAtom(0).getDLPredicate()).getIRI()));
213 OWLObjectProperty superProp = factory.getOWLObjectProperty(IRI.create(((AtomicRole) dlClause.getHeadAtom(0).getDLPredicate()).getIRI()));
214 return factory.getOWLSubObjectPropertyOfAxiom(subProp, superProp);
215 }
216 else if (dlClause.isAtomicRoleInverseInclusion()) {
217 OWLObjectProperty subProp = factory.getOWLObjectProperty(IRI.create(((AtomicRole) dlClause.getBodyAtom(0).getDLPredicate()).getIRI()));
218 OWLObjectProperty superProp = factory.getOWLObjectProperty(IRI.create(((AtomicRole) dlClause.getHeadAtom(0).getDLPredicate()).getIRI()));
219 return factory.getOWLSubObjectPropertyOfAxiom(subProp, superProp.getInverseProperty());
220 }
221 else if (dlClause.isFunctionalityAxiom()) {
222 OWLObjectProperty prop = factory.getOWLObjectProperty(IRI.create(((AtomicRole) dlClause.getBodyAtom(0).getDLPredicate()).getIRI()));
223 return factory.getOWLFunctionalObjectPropertyAxiom(prop);
224 }
225 else if (dlClause.isInverseFunctionalityAxiom()) {
226 OWLObjectProperty prop = factory.getOWLObjectProperty(IRI.create(((AtomicRole) dlClause.getBodyAtom(0).getDLPredicate()).getIRI()));
227 return factory.getOWLInverseFunctionalObjectPropertyAxiom(prop);
228 }
229 else if (DLClauseHelper.isFunctionalDataPropertyAxioms(dlClause)) {
230 OWLDataProperty prop = factory.getOWLDataProperty(IRI.create(((AtomicRole) dlClause.getBodyAtom(0).getDLPredicate()).getIRI()));
231 return factory.getOWLFunctionalDataPropertyAxiom(prop);
232 }
233 int flag;
234 if ((flag = DLClauseHelper.isRoleCompositionAxioms(dlClause)) >= 0) {
235 OWLObjectPropertyExpression R = factory.getOWLObjectProperty(IRI.create(((AtomicRole) dlClause.getBodyAtom(0).getDLPredicate()).getIRI()));
236 OWLObjectPropertyExpression S = factory.getOWLObjectProperty(IRI.create(((AtomicRole) dlClause.getBodyAtom(1).getDLPredicate()).getIRI()));
237 OWLObjectPropertyExpression T = factory.getOWLObjectProperty(IRI.create(((AtomicRole) dlClause.getHeadAtom(0).getDLPredicate()).getIRI()));
238
239 if (flag % 2 != 0) T = T.getInverseProperty(); flag /= 2;
240 if (flag % 2 != 0) S = S.getInverseProperty(); flag /= 2;
241 if (flag % 2 != 0) R = R.getInverseProperty();
242 if (R.equals(S) && S.equals(T))
243 return factory.getOWLTransitiveObjectPropertyAxiom(R);
244 else {
245 List<OWLObjectPropertyExpression> list = new LinkedList<OWLObjectPropertyExpression>();
246 list.add(R); list.add(S);
247 return factory.getOWLSubPropertyChainOfAxiom(list, T);
248 }
249 }
250 else {
251 Clausifier clausifier = Clausifier.getInstance(ontology);
252// if (dlClause.isGeneralConceptInclusion()) {
253
254 Clause myClause = new Clause(clausifier, dlClause);
255 owlAxiom = getSimplifiedGCI(factory, myClause.getSubClasses(), myClause.getSuperClasses());
256
257
258 if (owlAxiom == null)
259 Utility.logError("more kinds of DLClause: " + dlClause.toString());
260
261 return owlAxiom;
262 }
263
264 }
265
266 private static OWLAxiom getSimplifiedGCI(OWLDataFactory factory, Set<OWLClassExpression> subClasses, Set<OWLClassExpression> superClasses) {
267 if (superClasses.size() > 1) {
268 Set<OWLClassExpression> toRemoved = new HashSet<OWLClassExpression>();
269 for (OWLClassExpression cls: new HashSet<OWLClassExpression>(superClasses))
270 if (cls instanceof OWLObjectMaxCardinality) {
271 OWLObjectMaxCardinality maxCard = (OWLObjectMaxCardinality) cls;
272 OWLObjectMinCardinality minCard = factory.getOWLObjectMinCardinality(maxCard.getCardinality() + 1, maxCard.getProperty());
273 for (OWLClassExpression exp: subClasses)
274 if (isSubsumedByMinCard(exp, minCard))
275 toRemoved.add(exp);
276 subClasses.add(minCard);
277 superClasses.remove(maxCard);
278 }
279 subClasses.removeAll(toRemoved);
280 }
281
282 return factory.getOWLSubClassOfAxiom(getSimplifiedConjunction(factory, subClasses), getSimplifiedDisjunction(factory, superClasses));
283 }
284
285 public static OWLAxiom getABoxAssertion(OWLDataFactory factory, Atom atom) {
286 if (atom.getDLPredicate().toString().contains("internal:nom#"))
287 return null;
288 try {
289 if (atom.getArity() == 1)
290 return factory.getOWLClassAssertionAxiom(
291 factory.getOWLClass(IRI.create(((AtomicConcept) atom.getDLPredicate()).getIRI())),
292 factory.getOWLNamedIndividual(IRI.create(((Individual) atom.getArgument(0)).getIRI()))
293 );
294 else
295 return factory.getOWLObjectPropertyAssertionAxiom(
296 factory.getOWLObjectProperty(IRI.create(((AtomicRole) atom.getDLPredicate()).getIRI())),
297 factory.getOWLNamedIndividual(IRI.create(((Individual) atom.getArgument(0)).getIRI())),
298 factory.getOWLNamedIndividual(IRI.create(((Individual) atom.getArgument(1)).getIRI()))
299 );
300 } catch (Exception e) {
301 return null;
302 }
303 }
304
305 private static boolean isSubsumedByMinCard(OWLClassExpression exp, OWLObjectMinCardinality minCard) {
306 if (exp instanceof OWLObjectSomeValuesFrom) {
307 OWLObjectSomeValuesFrom someValuesFrom = (OWLObjectSomeValuesFrom) exp;
308 return minCard.getCardinality() > 0 &&
309 minCard.getProperty().equals(someValuesFrom.getProperty()) &&
310 minCard.getFiller().equals(someValuesFrom.getFiller());
311 }
312
313 if (exp instanceof OWLObjectMinCardinality) {
314 OWLObjectMinCardinality minCard2 = (OWLObjectMinCardinality) exp;
315 return minCard.getCardinality() >= minCard2.getCardinality() &&
316 minCard.getProperty().equals(minCard2.getProperty()) &&
317 minCard.getFiller().equals(minCard2.getFiller());
318 }
319 return false;
320 }
321
322 public static String removeAngles(String quotedString) {
323 if (quotedString.startsWith("<") && quotedString.endsWith(">"))
324 return quotedString.substring(1, quotedString.length() - 1);
325 else if (quotedString.contains(":"))
326 return quotedString;
327 else
328 Utility.logError("paused here due to the action to remove Angle in an unquotedString");
329 return quotedString;
330 }
331
332 public static String addAngles(String name) {
333 StringBuilder sb = new StringBuilder();
334 sb.append("<").append(name).append(">");
335 return sb.toString();
336 }
337
338 public static boolean isContradiction(OWLDataFactory factory, OWLAxiom axiom) {
339 if (!(axiom instanceof OWLSubClassOfAxiom))
340 return false;
341 OWLSubClassOfAxiom subClassAxiom = (OWLSubClassOfAxiom) axiom;
342 return subClassAxiom.getSubClass().equals(factory.getOWLThing()) && subClassAxiom.getSuperClass().equals(factory.getOWLNothing());
343 }
344
345 static MyHornAxiomVisitorEx visitor = new MyHornAxiomVisitorEx();
346
347 public static boolean isDisjunctiveAxiom(OWLAxiom axiom) {
348 boolean isHorn = false;
349 if (axiom instanceof OWLSubClassOfAxiom)
350 isHorn = visitor.visit((OWLSubClassOfAxiom) axiom);
351 else if (axiom instanceof OWLSubObjectPropertyOfAxiom)
352 isHorn = visitor.visit((OWLSubObjectPropertyOfAxiom) axiom);
353 else if (axiom instanceof OWLInverseObjectPropertiesAxiom)
354 isHorn = visitor.visit((OWLInverseObjectPropertiesAxiom) axiom);
355 else if (axiom instanceof OWLObjectPropertyDomainAxiom)
356 isHorn = visitor.visit((OWLObjectPropertyDomainAxiom) axiom);
357 else if (axiom instanceof OWLFunctionalObjectPropertyAxiom)
358 isHorn = visitor.visit((OWLFunctionalObjectPropertyAxiom) axiom);
359 else if (axiom instanceof OWLInverseFunctionalObjectPropertyAxiom)
360 isHorn = visitor.visit((OWLInverseFunctionalObjectPropertyAxiom) axiom);
361 else {
362 Utility.logError(axiom);
363 }
364
365 if (isHorn)
366 Utility.logDebug(axiom.toString() + " is NOT a disjunctive axiom.");
367 else
368 Utility.logDebug(axiom.toString() + " is a disjunctive axiom.");
369
370 return !isHorn;
371 }
372
373 public boolean isELHO(OWLOntology ontology) {
374 Utility.logDebug("checking whether ELHO ... ");
375 ELHOProfile profile = new ELHOProfile();
376 OWLProfileReport report = profile.checkOntology(ontology);
377 for (OWLProfileViolation v: report.getViolations())
378 if (v instanceof UseOfUndeclaredClass ||
379 v instanceof UseOfUndeclaredObjectProperty ||
380 v instanceof UseOfUndeclaredDataProperty);
381 else {
382 Utility.logDebug(v.toString(), "not ELHO");
383 return false;
384 }
385 return true;
386 }
387
388 public static void identifyAndChangeAnnotationAssertions(OWLOntology ontology) {
389 OWLOntologyManager manager = ontology.getOWLOntologyManager();
390 OWLDataFactory factory = manager.getOWLDataFactory();
391
392 Set<String> objectProperties = new HashSet<String>();
393 for (OWLOntology onto: ontology.getImportsClosure()) {
394 for (OWLObjectProperty prop: onto.getObjectPropertiesInSignature()) {
395 objectProperties.add(prop.toStringID());
396 }
397 }
398
399 Set<OWLAnnotationAssertionAxiom> toRemove = new HashSet<OWLAnnotationAssertionAxiom>();
400 Set<OWLObjectPropertyAssertionAxiom> toAdd = new HashSet<OWLObjectPropertyAssertionAxiom>();
401 OWLAnnotationAssertionAxiom assertion;
402 OWLAnnotationSubject anSub;
403 OWLAnnotationValue anValue;
404
405 OWLObjectPropertyAssertionAxiom newAssertion;
406 String property;
407 OWLIndividual sub, obj;
408
409 for (OWLOntology onto: ontology.getImportsClosure()) {
410 for (OWLAxiom axiom: onto.getAxioms())
411 if (axiom instanceof OWLAnnotationAssertionAxiom) {
412 assertion = (OWLAnnotationAssertionAxiom) axiom;
413 if (objectProperties.contains(property = assertion.getProperty().toStringID())) {
414 if ((anSub = assertion.getSubject()) instanceof OWLAnonymousIndividual)
415 sub = (OWLAnonymousIndividual) anSub;
416 else
417 sub = factory.getOWLNamedIndividual((IRI) anSub);
418
419 if ((anValue = assertion.getValue()) instanceof OWLAnonymousIndividual)
420 obj = (OWLAnonymousIndividual) anValue;
421 else if (anValue instanceof IRI)
422 obj = factory.getOWLNamedIndividual((IRI) anValue);
423 else
424 continue;
425
426 newAssertion = factory.getOWLObjectPropertyAssertionAxiom(
427 factory.getOWLObjectProperty(IRI.create(property)), sub, obj);
428 toRemove.add(assertion);
429 toAdd.add(newAssertion);
430 }
431 }
432 manager.removeAxioms(onto, toRemove);
433 manager.addAxioms(onto, toAdd);
434 }
435 }
436
437 public static String getOntologyPath(OWLOntology o) {
438 return getDocumentIRI(o).substring(5);
439 }
440
441 public static String getDocumentIRI(OWLOntology o) {
442 return o.getOWLOntologyManager().getOntologyDocumentIRI(o).toString();
443 }
444
445 public static boolean isInOWL2RL(OWLOntology o) {
446 OWL2RLProfile profile = new OWL2RLProfile();
447 return profile.checkOntology(o).isInProfile();
448 }
449
450 public static boolean isInELHO(OWLOntology o) {
451 ELHOProfile profile = new ELHOProfile();
452 return profile.checkOntology(o).isInProfile();
453 }
454
455 public static String getOriginalMarkProgram(OWLOntology ontology) {
456 String originalConcept = Namespace.PAGODA_ORIGINAL;
457 StringBuilder sb = new StringBuilder();
458 for (OWLDataProperty p: ontology.getDataPropertiesInSignature()) {
459 sb.append("<").append(originalConcept).append(">(?x) :- <").append(p.toStringID()).append(">(?x,?y) .\n");
460 sb.append("<").append(originalConcept).append(">(?y) :- <").append(p.toStringID()).append(">(?x,?y) .\n");
461 }
462 for (OWLObjectProperty p: ontology.getObjectPropertiesInSignature()) {
463 sb.append("<").append(originalConcept).append(">(?x) :- <").append(p.toStringID()).append(">(?x,?y) .\n");
464 sb.append("<").append(originalConcept).append(">(?y) :- <").append(p.toStringID()).append(">(?x,?y) .\n");
465 }
466 for (OWLClass c: ontology.getClassesInSignature())
467 sb.append("<").append(originalConcept).append(">(?x) :- <").append(c.toStringID()).append(">(?x) .\n");
468 return sb.toString();
469 }
470
471}