aboutsummaryrefslogtreecommitdiff
path: root/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java')
-rw-r--r--src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java55
1 files changed, 30 insertions, 25 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java b/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java
index 97925fc..4dd11d8 100644
--- a/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java
+++ b/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java
@@ -77,7 +77,8 @@ public class HermitChecker implements Checker {
77 } 77 }
78 78
79 private int tag = 0; 79 private int tag = 0;
80 AnswerTuple topAnswerTuple = null, botAnswerTuple = null; 80// AnswerTuple topAnswerTuple = null;
81 AnswerTuple botAnswerTuple = null;
81 82
82 private void initialiseReasoner() { 83 private void initialiseReasoner() {
83 qGraph = new QueryGraph(queryClause.getBodyAtoms(), answerVariable[1], ontology); 84 qGraph = new QueryGraph(queryClause.getBodyAtoms(), answerVariable[1], ontology);
@@ -96,8 +97,9 @@ public class HermitChecker implements Checker {
96 manager.removeAxioms(ontology, axioms); 97 manager.removeAxioms(ontology, axioms);
97 hermit = new Reasoner(ontology); 98 hermit = new Reasoner(ontology);
98 } else { 99 } else {
99 if (topAnswerTuple != null && !check(topAnswerTuple)) tag = -1; 100// if (topAnswerTuple != null && !check(topAnswerTuple)) tag = -1;
100 else if (botAnswerTuple != null && check(botAnswerTuple)) tag = 1; 101// else
102 if (botAnswerTuple != null && check(botAnswerTuple)) tag = 1;
101 } 103 }
102 } 104 }
103 else 105 else
@@ -105,19 +107,22 @@ public class HermitChecker implements Checker {
105 } 107 }
106 108
107 private void addTopAndBotTuple(Set<OWLAxiom> axioms) { 109 private void addTopAndBotTuple(Set<OWLAxiom> axioms) {
108 String top_str = Namespace.PAGODA_ANONY + "top", bot_str = Namespace.PAGODA_ANONY + "bot"; 110// String top_str = Namespace.PAGODA_ANONY + "top";
109 topAnswerTuple = new AnswerTuple(new uk.ac.ox.cs.JRDFox.model.Individual[] { uk.ac.ox.cs.JRDFox.model.Individual.create(top_str) } ); 111 String bot_str = Namespace.PAGODA_ANONY + "bot";
112// topAnswerTuple = new AnswerTuple(new uk.ac.ox.cs.JRDFox.model.Individual[] { uk.ac.ox.cs.JRDFox.model.Individual.create(top_str) } );
110 botAnswerTuple = new AnswerTuple(new uk.ac.ox.cs.JRDFox.model.Individual[] { uk.ac.ox.cs.JRDFox.model.Individual.create(bot_str) } ); 113 botAnswerTuple = new AnswerTuple(new uk.ac.ox.cs.JRDFox.model.Individual[] { uk.ac.ox.cs.JRDFox.model.Individual.create(bot_str) } );
111 OWLIndividual top_ind = factory.getOWLNamedIndividual(IRI.create(top_str)), bot_ind = factory.getOWLNamedIndividual(IRI.create(bot_str)); 114// OWLIndividual top_ind = factory.getOWLNamedIndividual(IRI.create(top_str));
115 OWLIndividual bot_ind = factory.getOWLNamedIndividual(IRI.create(bot_str));
112 Map<OWLAxiom, Integer> counter = new HashMap<OWLAxiom, Integer>(); 116 Map<OWLAxiom, Integer> counter = new HashMap<OWLAxiom, Integer>();
113 117
114 Set<String> topAnswers = new HashSet<String>(), botAnswers = new HashSet<String>(); 118// Set<String> topAnswers = new HashSet<String>();
119 Set<String> botAnswers = new HashSet<String>();
115 OWLIndividual sub, obj; 120 OWLIndividual sub, obj;
116 if (dGraph.getExits().size() > 1) { 121// if (dGraph.getExits().size() > 1) {
117 for (Clique answerClique: dGraph.getExits()) 122// for (Clique answerClique: dGraph.getExits())
118 topAnswers.add(((uk.ac.ox.cs.JRDFox.model.Individual) answerClique.getRepresentative().getAnswerTuple().getGroundTerm(0)).getIRI()); 123// topAnswers.add(((uk.ac.ox.cs.JRDFox.model.Individual) answerClique.getRepresentative().getAnswerTuple().getGroundTerm(0)).getIRI());
119 } 124// }
120 else topAnswerTuple = null; 125// else topAnswerTuple = null;
121 126
122 if (dGraph.getEntrances().size() > 1) { 127 if (dGraph.getEntrances().size() > 1) {
123 for (Clique answerClique: dGraph.getEntrances()) 128 for (Clique answerClique: dGraph.getEntrances())
@@ -129,23 +134,23 @@ public class HermitChecker implements Checker {
129 if (axiom instanceof OWLClassAssertionAxiom) { 134 if (axiom instanceof OWLClassAssertionAxiom) {
130 OWLClassAssertionAxiom ca = (OWLClassAssertionAxiom) axiom; 135 OWLClassAssertionAxiom ca = (OWLClassAssertionAxiom) axiom;
131 sub = ca.getIndividual(); 136 sub = ca.getIndividual();
132 if (topAnswers.contains(sub.toStringID())) 137// if (topAnswers.contains(sub.toStringID()))
133 axioms.add(factory.getOWLClassAssertionAxiom(ca.getClassExpression(), top_ind)); 138// axioms.add(factory.getOWLClassAssertionAxiom(ca.getClassExpression(), top_ind));
134 if (botAnswers.contains(sub.toStringID())) 139 if (botAnswers.contains(sub.toStringID()))
135 inc(counter, factory.getOWLClassAssertionAxiom(ca.getClassExpression(), bot_ind)); 140 inc(counter, factory.getOWLClassAssertionAxiom(ca.getClassExpression(), bot_ind));
136 } 141 }
137 else if (axiom instanceof OWLObjectPropertyAssertionAxiom) { 142 else if (axiom instanceof OWLObjectPropertyAssertionAxiom) {
138 OWLObjectPropertyAssertionAxiom oa = (OWLObjectPropertyAssertionAxiom) axiom; 143 OWLObjectPropertyAssertionAxiom oa = (OWLObjectPropertyAssertionAxiom) axiom;
139 sub = oa.getSubject(); obj = oa.getObject(); 144 sub = oa.getSubject(); obj = oa.getObject();
140 if (topAnswers.contains(sub.toStringID())) 145//// if (topAnswers.contains(sub.toStringID()))
141 if (topAnswers.contains(obj.toStringID())) 146//// if (topAnswers.contains(obj.toStringID()))
142 axioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), top_ind, top_ind)); 147//// axioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), top_ind, top_ind));
143 else 148//// else
144 axioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), top_ind, obj)); 149//// axioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), top_ind, obj));
145 else { 150//// else {
146 if (topAnswers.contains(obj.toStringID())) 151//// if (topAnswers.contains(obj.toStringID()))
147 axioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), sub, top_ind)); 152//// axioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), sub, top_ind));
148 } 153//// }
149 154
150 if (botAnswers.contains(sub.toStringID())) 155 if (botAnswers.contains(sub.toStringID()))
151 if (botAnswers.contains(obj.toStringID())) 156 if (botAnswers.contains(obj.toStringID()))
@@ -161,8 +166,8 @@ public class HermitChecker implements Checker {
161 else if (axiom instanceof OWLDataPropertyAssertionAxiom) { 166 else if (axiom instanceof OWLDataPropertyAssertionAxiom) {
162 OWLDataPropertyAssertionAxiom da = (OWLDataPropertyAssertionAxiom) axiom; 167 OWLDataPropertyAssertionAxiom da = (OWLDataPropertyAssertionAxiom) axiom;
163 sub = da.getSubject(); 168 sub = da.getSubject();
164 if (topAnswers.contains(sub.toStringID())) 169// if (topAnswers.contains(sub.toStringID()))
165 axioms.add(factory.getOWLDataPropertyAssertionAxiom(da.getProperty(), top_ind, da.getObject())); 170// axioms.add(factory.getOWLDataPropertyAssertionAxiom(da.getProperty(), top_ind, da.getObject()));
166 171
167 if (botAnswers.contains(sub.toStringID())) 172 if (botAnswers.contains(sub.toStringID()))
168 inc(counter, factory.getOWLDataPropertyAssertionAxiom(da.getProperty(), bot_ind, da.getObject())); 173 inc(counter, factory.getOWLDataPropertyAssertionAxiom(da.getProperty(), bot_ind, da.getObject()));