From 17bd9beaf7f358a44e5bf36a5855fe6727d506dc Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Tue, 10 May 2022 18:17:06 +0100 Subject: [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. --- .../cs/pagoda/reasoner/light/RDFoxQueryEngine.java | 138 --------------------- 1 file changed, 138 deletions(-) delete mode 100644 src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxQueryEngine.java (limited to 'src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxQueryEngine.java') diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxQueryEngine.java b/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxQueryEngine.java deleted file mode 100644 index 8b22919..0000000 --- a/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxQueryEngine.java +++ /dev/null @@ -1,138 +0,0 @@ -package uk.ac.ox.cs.pagoda.reasoner.light; - -import org.semanticweb.owlapi.model.OWLOntology; -import org.semanticweb.owlapi.model.OWLOntologyCreationException; -import uk.ac.ox.cs.JRDFox.JRDFStoreException; -import uk.ac.ox.cs.JRDFox.Prefixes; -import uk.ac.ox.cs.JRDFox.store.DataStore; -import uk.ac.ox.cs.JRDFox.store.DataStore.StoreType; -import uk.ac.ox.cs.pagoda.MyPrefixes; -import uk.ac.ox.cs.pagoda.query.AnswerTuples; -import uk.ac.ox.cs.pagoda.reasoner.QueryEngine; -import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; -import uk.ac.ox.cs.pagoda.tracking.AnswerTuplesWriter; -import uk.ac.ox.cs.pagoda.util.Timer; -import uk.ac.ox.cs.pagoda.util.Utility; -import uk.ac.ox.cs.pagoda.util.disposable.DisposedException; - -import java.io.File; -import java.util.Collection; - -public abstract class RDFoxQueryEngine extends QueryEngine { - - public static final int matNoOfThreads = Runtime.getRuntime().availableProcessors() * 2; - protected String name; - protected Prefixes prefixes = MyPrefixes.PAGOdAPrefixes.getRDFoxPrefixes(); - - public RDFoxQueryEngine(String name) { - this.name = name; - } - - public static DataStore createDataStore() { - DataStore instance = null; - try { -// instance = new DataStore("par-head-n"); - instance = new DataStore(StoreType.NarrowParallelHead); - instance.setNumberOfThreads(matNoOfThreads); - instance.initialize(); - } catch(JRDFStoreException e) { - e.printStackTrace(); - } - return instance; - } - - public String getName() { - if(isDisposed()) throw new DisposedException(); - return name; - } - - public abstract DataStore getDataStore(); - - public void importRDFData(String fileName, String importedFile) { - if(isDisposed()) throw new DisposedException(); - if(importedFile == null || importedFile.isEmpty()) return; - Timer t = new Timer(); - DataStore store = getDataStore(); - try { - long oldTripleCount = store.getTriplesCount(), tripleCount; - for(String file : importedFile.split(QueryReasoner.ImportDataFileSeparator)) { - store.importTurtleFile(new File(file), prefixes); - } - tripleCount = store.getTriplesCount(); - Utility.logDebug(name + " store after importing " + fileName + ": " + tripleCount + " (" + (tripleCount - oldTripleCount) + " new)"); - store.clearRulesAndMakeFactsExplicit(); - } catch(JRDFStoreException e) { - e.printStackTrace(); - } - Utility.logDebug(name + " store finished importing " + fileName + " in " + t.duration() + " seconds."); - } - - public void importDataFromABoxOf(OWLOntology ontology) { - if(isDisposed()) throw new DisposedException(); - DataStore store = getDataStore(); - try { - long prevTriplesCount = store.getTriplesCount(); - store.importOntology(ontology.getOWLOntologyManager().createOntology(ontology.getABoxAxioms(true))); - long loadedTriples = store.getTriplesCount() - prevTriplesCount; - Utility.logDebug(name + ": loaded " + loadedTriples + " triples from " + ontology.getABoxAxioms(true) - .size() + " ABox axioms"); - } catch(JRDFStoreException | OWLOntologyCreationException e) { - e.printStackTrace(); - System.exit(1); - } - - } - - public void materialise(String programName, String programText) { - if(isDisposed()) throw new DisposedException(); - if(programText == null) return; - Timer t = new Timer(); - DataStore store = getDataStore(); - try { - long oldTripleCount = store.getTriplesCount(), tripleCount; -// store.addRules(new String[] {programText}); - store.importRules(programText); - store.applyReasoning(); - tripleCount = store.getTriplesCount(); - Utility.logDebug(name + " store after materialising " + programName + ": " + tripleCount + " (" + (tripleCount - oldTripleCount) + " new)"); - store.clearRulesAndMakeFactsExplicit(); - } catch(JRDFStoreException e) { - e.printStackTrace(); - } - Utility.logDebug(name + " store finished the materialisation of " + programName + " in " + t.duration() + " seconds."); - } - - @Override - public void evaluate(Collection queryTexts, String answerFile) { - if(isDisposed()) throw new DisposedException(); - if(queryTexts == null) - return; - - int queryID = 0; - AnswerTuplesWriter answerWriter = new AnswerTuplesWriter(answerFile); - AnswerTuples answerTuples; - Timer t = new Timer(); - try { - for(String query : queryTexts) { - t.reset(); - answerTuples = null; - try { - answerTuples = evaluate(query); - Utility.logDebug("time to answer Query " + ++queryID + ": " + t.duration()); - answerWriter.write(answerTuples.getAnswerVariables(), answerTuples); - } finally { - if(answerTuples != null) answerTuples.dispose(); - } - } - } finally { - answerWriter.close(); - } - - Utility.logDebug("done computing query answers by RDFox."); - } - - @Override - public void dispose() { - super.dispose(); - } -} -- cgit v1.2.3