diff options
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/reasoner/IterativeRefinement.java')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/reasoner/IterativeRefinement.java | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/IterativeRefinement.java b/src/uk/ac/ox/cs/pagoda/reasoner/IterativeRefinement.java deleted file mode 100644 index 7847e7c..0000000 --- a/src/uk/ac/ox/cs/pagoda/reasoner/IterativeRefinement.java +++ /dev/null | |||
| @@ -1,117 +0,0 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.reasoner; | ||
| 2 | |||
| 3 | import org.semanticweb.owlapi.model.OWLOntology; | ||
| 4 | import uk.ac.ox.cs.pagoda.constraints.BottomStrategy; | ||
| 5 | import uk.ac.ox.cs.pagoda.constraints.UpperUnaryBottom; | ||
| 6 | import uk.ac.ox.cs.pagoda.multistage.MultiStageQueryEngine; | ||
| 7 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | ||
| 8 | import uk.ac.ox.cs.pagoda.query.QueryRecord; | ||
| 9 | import uk.ac.ox.cs.pagoda.reasoner.light.BasicQueryEngine; | ||
| 10 | import uk.ac.ox.cs.pagoda.rules.GeneralProgram; | ||
| 11 | import uk.ac.ox.cs.pagoda.tracking.QueryTracker; | ||
| 12 | import uk.ac.ox.cs.pagoda.util.Utility; | ||
| 13 | |||
| 14 | import java.io.File; | ||
| 15 | |||
| 16 | public class IterativeRefinement { | ||
| 17 | |||
| 18 | private static final int depthLimit = 1; | ||
| 19 | |||
| 20 | QueryRecord m_record; | ||
| 21 | QueryTracker m_tracker; | ||
| 22 | BasicQueryEngine m_trackingStore; | ||
| 23 | QueryRecord[] botQueryRecords; | ||
| 24 | |||
| 25 | int m_depth = 0; | ||
| 26 | String tempDataFile = "temp.ttl"; | ||
| 27 | |||
| 28 | public IterativeRefinement(QueryRecord queryRecord, QueryTracker tracker, BasicQueryEngine trackingStore, QueryRecord[] botQueryRecords) { | ||
| 29 | m_record = queryRecord; | ||
| 30 | m_tracker = tracker; | ||
| 31 | m_trackingStore = trackingStore; | ||
| 32 | this.botQueryRecords = botQueryRecords; | ||
| 33 | } | ||
| 34 | |||
| 35 | public OWLOntology extractWithFullABox(String dataset, BottomStrategy upperBottom) { | ||
| 36 | GeneralProgram program; | ||
| 37 | boolean update; | ||
| 38 | while (m_depth < depthLimit) { | ||
| 39 | ++m_depth; | ||
| 40 | program = new GeneralProgram(m_record.getRelevantClauses(), m_record.getRelevantOntology()); | ||
| 41 | |||
| 42 | MultiStageQueryEngine tEngine = new MultiStageQueryEngine("query-tracking", true); | ||
| 43 | try { | ||
| 44 | tEngine.importRDFData("data", dataset); | ||
| 45 | if (tEngine.materialise4SpecificQuery(program, m_record, upperBottom) != 1) { | ||
| 46 | return m_record.getRelevantOntology(); | ||
| 47 | } | ||
| 48 | |||
| 49 | AnswerTuples ans = null; | ||
| 50 | try { | ||
| 51 | ans = tEngine.evaluate(m_record.getQueryText()); | ||
| 52 | update = m_record.updateUpperBoundAnswers(ans); | ||
| 53 | } finally { | ||
| 54 | if (ans != null) ans.dispose(); | ||
| 55 | } | ||
| 56 | } finally { | ||
| 57 | tEngine.dispose(); | ||
| 58 | } | ||
| 59 | |||
| 60 | if(m_record.isProcessed()) | ||
| 61 | return null; | ||
| 62 | |||
| 63 | if (!update) break; | ||
| 64 | |||
| 65 | m_record.updateSubID(); | ||
| 66 | m_tracker.extract(m_trackingStore, botQueryRecords, true); | ||
| 67 | } | ||
| 68 | |||
| 69 | return m_record.getRelevantOntology(); | ||
| 70 | } | ||
| 71 | |||
| 72 | public OWLOntology extract(UpperUnaryBottom upperBottom) { | ||
| 73 | GeneralProgram program; | ||
| 74 | boolean update; | ||
| 75 | while (m_depth < depthLimit) { | ||
| 76 | m_record.saveABoxInTurtle(tempDataFile); | ||
| 77 | program = new GeneralProgram(m_record.getRelevantClauses(), m_record.getRelevantOntology()); | ||
| 78 | |||
| 79 | MultiStageQueryEngine tEngine = new MultiStageQueryEngine("query-tracking", true); | ||
| 80 | try { | ||
| 81 | tEngine.importRDFData("fragment abox", tempDataFile); | ||
| 82 | if (tEngine.materialise4SpecificQuery(program, m_record, upperBottom) != 1) { | ||
| 83 | return m_record.getRelevantOntology(); | ||
| 84 | } | ||
| 85 | |||
| 86 | AnswerTuples ans = null; | ||
| 87 | try { | ||
| 88 | ans = tEngine.evaluate(m_record.getQueryText()); | ||
| 89 | update = m_record.updateUpperBoundAnswers(ans); | ||
| 90 | } finally { | ||
| 91 | if (ans != null) ans.dispose(); | ||
| 92 | } | ||
| 93 | } finally { | ||
| 94 | tEngine.dispose(); | ||
| 95 | } | ||
| 96 | |||
| 97 | if(m_record.isProcessed()) | ||
| 98 | return null; | ||
| 99 | |||
| 100 | if (!update) break; | ||
| 101 | |||
| 102 | m_record.updateSubID(); | ||
| 103 | m_tracker.extract(m_trackingStore, botQueryRecords, true); | ||
| 104 | } | ||
| 105 | |||
| 106 | return m_record.getRelevantOntology(); | ||
| 107 | } | ||
| 108 | |||
| 109 | public void dispose() { | ||
| 110 | File file = new File(tempDataFile); | ||
| 111 | if (file.exists()) { | ||
| 112 | file.delete(); | ||
| 113 | Utility.logDebug(file.getAbsolutePath() + " is deleted."); | ||
| 114 | } | ||
| 115 | } | ||
| 116 | |||
| 117 | } | ||
