diff options
| author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2022-05-10 18:17:06 +0100 |
|---|---|---|
| committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2022-05-11 12:34:47 +0100 |
| commit | 17bd9beaf7f358a44e5bf36a5855fe6727d506dc (patch) | |
| tree | 47e9310a0cff869d9ec017dcb2c81876407782c8 /src/uk/ac/ox/cs/pagoda/reasoner/ELHOQueryReasoner.java | |
| parent | 8651164cd632a5db310b457ce32d4fbc97bdc41c (diff) | |
| download | ACQuA-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/uk/ac/ox/cs/pagoda/reasoner/ELHOQueryReasoner.java')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/reasoner/ELHOQueryReasoner.java | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/ELHOQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/ELHOQueryReasoner.java deleted file mode 100644 index cc2c4c0..0000000 --- a/src/uk/ac/ox/cs/pagoda/reasoner/ELHOQueryReasoner.java +++ /dev/null | |||
| @@ -1,101 +0,0 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.reasoner; | ||
| 2 | |||
| 3 | import org.semanticweb.karma2.profile.ELHOProfile; | ||
| 4 | import org.semanticweb.owlapi.model.OWLOntology; | ||
| 5 | import uk.ac.ox.cs.pagoda.constraints.UnaryBottom; | ||
| 6 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | ||
| 7 | import uk.ac.ox.cs.pagoda.query.QueryRecord; | ||
| 8 | import uk.ac.ox.cs.pagoda.query.QueryRecord.Step; | ||
| 9 | import uk.ac.ox.cs.pagoda.reasoner.light.KarmaQueryEngine; | ||
| 10 | import uk.ac.ox.cs.pagoda.rules.LowerDatalogProgram; | ||
| 11 | import uk.ac.ox.cs.pagoda.util.Timer; | ||
| 12 | import uk.ac.ox.cs.pagoda.util.Utility; | ||
| 13 | import uk.ac.ox.cs.pagoda.util.disposable.DisposedException; | ||
| 14 | |||
| 15 | class ELHOQueryReasoner extends QueryReasoner { | ||
| 16 | |||
| 17 | LowerDatalogProgram program; | ||
| 18 | |||
| 19 | OWLOntology elho_ontology; | ||
| 20 | KarmaQueryEngine elLowerStore = null; | ||
| 21 | |||
| 22 | private Timer t = new Timer(); | ||
| 23 | |||
| 24 | public ELHOQueryReasoner() { | ||
| 25 | elLowerStore = new KarmaQueryEngine("el"); | ||
| 26 | } | ||
| 27 | |||
| 28 | @Override | ||
| 29 | public void evaluate(QueryRecord queryRecord) { | ||
| 30 | if(isDisposed()) throw new DisposedException(); | ||
| 31 | AnswerTuples elAnswer = null; | ||
| 32 | t.reset(); | ||
| 33 | try { | ||
| 34 | elAnswer = elLowerStore.evaluate(queryRecord.getQueryText(), queryRecord.getAnswerVariables()); | ||
| 35 | queryRecord.updateLowerBoundAnswers(elAnswer); | ||
| 36 | } finally { | ||
| 37 | if(elAnswer != null) elAnswer.dispose(); | ||
| 38 | } | ||
| 39 | queryRecord.addProcessingTime(Step.EL_LOWER_BOUND, t.duration()); | ||
| 40 | |||
| 41 | queryRecord.setDifficulty(Step.EL_LOWER_BOUND); | ||
| 42 | queryRecord.markAsProcessed(); | ||
| 43 | } | ||
| 44 | |||
| 45 | @Override | ||
| 46 | public void evaluateUpper(QueryRecord queryRecord) { | ||
| 47 | if(isDisposed()) throw new DisposedException(); | ||
| 48 | evaluate(queryRecord); | ||
| 49 | } | ||
| 50 | |||
| 51 | @Override | ||
| 52 | public void dispose() { | ||
| 53 | super.dispose(); | ||
| 54 | if(elLowerStore != null) elLowerStore.dispose(); | ||
| 55 | } | ||
| 56 | |||
| 57 | @Override | ||
| 58 | public void loadOntology(OWLOntology ontology) { | ||
| 59 | if(isDisposed()) throw new DisposedException(); | ||
| 60 | program = new LowerDatalogProgram(properties.getToClassify()); | ||
| 61 | program.load(ontology, new UnaryBottom()); | ||
| 62 | program.transform(); | ||
| 63 | |||
| 64 | importData(program.getAdditionalDataFile()); | ||
| 65 | |||
| 66 | elho_ontology = new ELHOProfile().getFragment(ontology); | ||
| 67 | elLowerStore.processOntology(elho_ontology); | ||
| 68 | } | ||
| 69 | |||
| 70 | @Override | ||
| 71 | public boolean preprocess() { | ||
| 72 | if(isDisposed()) throw new DisposedException(); | ||
| 73 | elLowerStore.importRDFData("data", getImportedData()); | ||
| 74 | String rlLowerProgramText = program.toString(); | ||
| 75 | // program.save(); | ||
| 76 | elLowerStore.materialise("lower program", rlLowerProgramText); | ||
| 77 | elLowerStore.initialiseKarma(); | ||
| 78 | |||
| 79 | if(!isConsistent()) { | ||
| 80 | Utility.logDebug("The dataset is not consistent with the ontology."); | ||
| 81 | return false; | ||
| 82 | } | ||
| 83 | return true; | ||
| 84 | } | ||
| 85 | |||
| 86 | @Override | ||
| 87 | public boolean isConsistent() { | ||
| 88 | if(isDisposed()) throw new DisposedException(); | ||
| 89 | String[] X = new String[]{"X"}; | ||
| 90 | AnswerTuples ans = null; | ||
| 91 | try { | ||
| 92 | ans = elLowerStore.evaluate(QueryRecord.botQueryText, X); | ||
| 93 | if(ans.isValid()) return false; | ||
| 94 | } finally { | ||
| 95 | if(ans != null) ans.dispose(); | ||
| 96 | } | ||
| 97 | |||
| 98 | return true; | ||
| 99 | } | ||
| 100 | |||
| 101 | } | ||
