aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala')
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala78
1 files changed, 11 insertions, 67 deletions
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala
index a0d567e..f67eca9 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala
@@ -635,9 +635,14 @@ class RSAOntology(
635 Logger.write(canonicalModel.rules.mkString("\n"), "canonical_model.dlog") 635 Logger.write(canonicalModel.rules.mkString("\n"), "canonical_model.dlog")
636 RDFoxUtil.addRules(data, this.canonicalModel.rules) 636 RDFoxUtil.addRules(data, this.canonicalModel.rules)
637 637
638 /* Finalise canonical model */
639 data.clearRulesAxiomsExplicateFacts()
640
638 RDFoxUtil.closeConnection(server, data) 641 RDFoxUtil.closeConnection(server, data)
639 642
640 (query => { 643 (query => {
644 Logger print s"Query ID: ${query.id}"
645
641 val (server, data) = RDFoxUtil.openConnection(RSAOntology.DataStore) 646 val (server, data) = RDFoxUtil.openConnection(RSAOntology.DataStore)
642 647
643 val filter = RSAOntology.filteringProgram(query) 648 val filter = RSAOntology.filteringProgram(query)
@@ -650,85 +655,24 @@ class RSAOntology(
650 ) 655 )
651 RDFoxUtil.addRules(data, filter.rules) 656 RDFoxUtil.addRules(data, filter.rules)
652 657
653 // TODO: We remove the rules, should we drop the tuple table as well?
654 //data.clearRulesAxiomsExplicateFacts()
655
656 /* Gather answers to the query */ 658 /* Gather answers to the query */
657 val answers = RDFoxUtil 659 val answers = RDFoxUtil
658 .submitQuery(data, filter.answerQuery, RSA.Prefixes) 660 .submitQuery(data, filter.answerQuery, RSA.Prefixes)
659 .map(new ConjunctiveQueryAnswers(query, query.variables, _)) 661 .map(new ConjunctiveQueryAnswers(query, query.variables, _))
660 .get 662 .get
661 663
664 /* Drop filtering named graph to avoid running out of memory */
665 data.clearRulesAxiomsExplicateFacts()
666 data.deleteTupleTable(filter.target.getIRI)
667
662 RDFoxUtil.closeConnection(server, data) 668 RDFoxUtil.closeConnection(server, data)
663 669
670 Logger print s"Number of answers: ${answers.length}"
671
664 answers 672 answers
665 }) 673 })
666 } 674 }
667 675
668 //def ask(query: ConjunctiveQuery): ConjunctiveQueryAnswers = Logger.timed(
669 // {
670 // val (server, data) = RDFoxUtil.openConnection(RSAOntology.DataStore)
671 // val canon = this.canonicalModel
672 // val filter = RSAOntology.filteringProgram(query)
673
674 // /* Upload data from data file */
675 // RDFoxUtil.addData(data, datafiles: _*)
676
677 // RDFoxUtil printStatisticsFor data
678
679 // /* Top / equality axiomatization */
680 // RDFoxUtil.addRules(data, topAxioms ++ equalityAxioms)
681
682 // /* Generate `named` predicates */
683 // RDFoxUtil.addFacts(data, (individuals ++ literals) map RSA.Named)
684 // data.evaluateUpdate(
685 // null, // the base IRI for the query (if null, a default is used)
686 // RSA.Prefixes,
687 // "INSERT { ?X a rsa:Named } WHERE { ?X a owl:Thing }",
688 // new java.util.HashMap[String, String]
689 // )
690
691 // /* Add canonical model */
692 // Logger print s"Canonical model rules: ${canon.rules.length}"
693 // RDFoxUtil.addRules(data, canon.rules)
694
695 // Logger print s"Canonical model facts: ${canon.facts.length}"
696 // RDFoxUtil.addFacts(data, canon.facts)
697
698 // RDFoxUtil printStatisticsFor data
699
700 // //{
701 // // import java.io.{PrintStream, FileOutputStream, File}
702 // // val rules1 = new FileOutputStream(new File("rules1-lubm200.dlog"))
703 // // val facts1 = new FileOutputStream(new File("facts1-lubm200.ttl"))
704 // // RDFoxUtil.export(data, rules1, facts1)
705 // // val rules2 = new PrintStream(new File("rules2-q34.dlog"))
706 // // rules2.print(filter.rules.mkString("\n"))
707 // //}
708
709 // /* Add filtering program */
710 // Logger print s"Filtering program rules: ${filter.rules.length}"
711 // RDFoxUtil.addRules(data, filter.rules)
712
713 // RDFoxUtil printStatisticsFor data
714
715 // /* Gather answers to the query */
716 // val answers = {
717 // val ans = filter.answerQuery
718 // RDFoxUtil
719 // .submitQuery(data, ans, RSA.Prefixes)
720 // .map(new ConjunctiveQueryAnswers(query, query.variables, _))
721 // .get
722 // }
723
724 // RDFoxUtil.closeConnection(server, data)
725
726 // answers
727 // },
728 // "Answers computation",
729 // Logger.DEBUG
730 //)
731
732 /** Query the RDFox data store used for query answering. 676 /** Query the RDFox data store used for query answering.
733 * 677 *
734 * @note This method does not add any facts or rules to the data 678 * @note This method does not add any facts or rules to the data