aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/scala/rsacomb/RDFoxClassExprConverter.scala4
-rw-r--r--src/main/scala/rsacomb/RSA.scala19
-rw-r--r--src/main/scala/rsacomb/RSAOntology.scala33
3 files changed, 21 insertions, 35 deletions
diff --git a/src/main/scala/rsacomb/RDFoxClassExprConverter.scala b/src/main/scala/rsacomb/RDFoxClassExprConverter.scala
index c1fd85a..b9d3ea2 100644
--- a/src/main/scala/rsacomb/RDFoxClassExprConverter.scala
+++ b/src/main/scala/rsacomb/RDFoxClassExprConverter.scala
@@ -108,8 +108,8 @@ class RDFoxClassExprConverter(
108 if (unsafe.contains(prop)) 108 if (unsafe.contains(prop))
109 ( 109 (
110 List( 110 List(
111 Atom.rdf(term, IRI.create(RSA.PredicatePE), c), 111 Atom.rdf(term, RSA.internal("PE"), c),
112 Atom.rdf(c, IRI.RDF_TYPE, IRI.create(RSA.PredicateU)) 112 Atom.rdf(c, IRI.RDF_TYPE, RSA.internal("U"))
113 ), 113 ),
114 List(), 114 List(),
115 c 115 c
diff --git a/src/main/scala/rsacomb/RSA.scala b/src/main/scala/rsacomb/RSA.scala
index 1fa0fc1..79617c7 100644
--- a/src/main/scala/rsacomb/RSA.scala
+++ b/src/main/scala/rsacomb/RSA.scala
@@ -2,17 +2,26 @@ package rsacomb
2 2
3/* Java imports */ 3/* Java imports */
4import java.io.File 4import java.io.File
5import java.util.Map
5 6
7import tech.oxfordsemantic.jrdfox.Prefixes
8import tech.oxfordsemantic.jrdfox.logic.IRI
6import org.semanticweb.owlapi.apibinding.OWLManager 9import org.semanticweb.owlapi.apibinding.OWLManager
7import org.semanticweb.owlapi.model.OWLOntology 10import org.semanticweb.owlapi.model.OWLOntology
8 11
9object RSA extends RSAOntology { 12object RSA extends RSAOntology {
10 13
11 val PrefixBase = "http://example.com/rsa_example.owl#" 14 val Prefixes = new Prefixes()
12 val PrefixInternal = "http://127.0.0.1/" 15 Prefixes.declarePrefix(":", "http://example.com/rsa_example.owl#")
13 val PredicatePE = PrefixInternal + "PE" 16 Prefixes.declarePrefix("internal:", "http://127.0.0.1/")
14 val PredicateU = PrefixInternal + "U" 17 Prefixes.declarePrefix("rdf:", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
15 val PredicateE = PrefixInternal + "E" 18 Prefixes.declarePrefix("rdfs:", "http://www.w3.org/2000/01/rdf-schema#")
19 Prefixes.declarePrefix("owl:", "http://www.w3.org/2002/07/owl#")
20
21 def internal(name: String): IRI =
22 IRI.create(
23 Prefixes.getPrefixIRIsByPrefixName.get("internal:").getIRI + name
24 )
16 25
17 // TODO: move this somewhere else... maybe an OntoUtils class or something. 26 // TODO: move this somewhere else... maybe an OntoUtils class or something.
18 def loadOntology(onto: File): OWLOntology = { 27 def loadOntology(onto: File): OWLOntology = {
diff --git a/src/main/scala/rsacomb/RSAOntology.scala b/src/main/scala/rsacomb/RSAOntology.scala
index 681dbb0..10f2fa4 100644
--- a/src/main/scala/rsacomb/RSAOntology.scala
+++ b/src/main/scala/rsacomb/RSAOntology.scala
@@ -9,7 +9,6 @@ import org.semanticweb.owlapi.model.OWLObjectPropertyExpression
9import org.semanticweb.owlapi.model.parameters.Imports 9import org.semanticweb.owlapi.model.parameters.Imports
10import org.semanticweb.owlapi.reasoner.structural.StructuralReasonerFactory 10import org.semanticweb.owlapi.reasoner.structural.StructuralReasonerFactory
11 11
12import tech.oxfordsemantic.jrdfox.Prefixes
13import tech.oxfordsemantic.jrdfox.logic.Variable 12import tech.oxfordsemantic.jrdfox.logic.Variable
14import tech.oxfordsemantic.jrdfox.client.UpdateType 13import tech.oxfordsemantic.jrdfox.client.UpdateType
15import tech.oxfordsemantic.jrdfox.logic.{Rule, Atom, Variable, IRI} 14import tech.oxfordsemantic.jrdfox.logic.{Rule, Atom, Variable, IRI}
@@ -74,38 +73,16 @@ trait RSAOntology {
74 println("\nDatalog roles:") 73 println("\nDatalog roles:")
75 datalog.foreach(println) 74 datalog.foreach(println)
76 75
77 // TODO: Define Prefixes in RSA object
78 val prefixes = new Prefixes()
79 prefixes.declarePrefix(":", RSA.PrefixBase)
80 prefixes.declarePrefix("internal:", RSA.PrefixInternal)
81 prefixes.declarePrefix(
82 "rdf:",
83 "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
84 )
85 prefixes.declarePrefix("rdfs:", "http://www.w3.org/2000/01/rdf-schema#")
86 prefixes.declarePrefix("owl:", "http://www.w3.org/2002/07/owl#")
87
88 // Open connection with RDFox 76 // Open connection with RDFox
89 val (server, data) = RDFoxUtil.openConnection("RSACheck") 77 val (server, data) = RDFoxUtil.openConnection("RSACheck")
90 // Add Data (hardcoded for now) 78 // Add Data (hardcoded for now)
91 data.importData(UpdateType.ADDITION, prefixes, ":a a :A .") 79 data.importData(UpdateType.ADDITION, RSA.Prefixes, ":a a :A .")
92
93 /* Add rules
94 *
95 * NOTE:
96 * - using the `addRules(...)` method in `DataStoreConnection` is not working as expected, complaining
97 * about missing TupleTable entries;
98 * - weirdly enough, the same error is returned when trying to pass the rules to the `importData` method,
99 * simply turning them into strings. It seems like the `toString` implementation of `Rule` uses parenthesis
100 * for predicate arguments (e.g., `<predicate>(?X,?Y)`) while the specification for the proprietary RDFox
101 * syntax uses squared brackets (e.g., `<preditate>[?X,?Y]`).
102 */
103 80
104 /* Add built-in rules 81 /* Add built-in rules
105 */ 82 */
106 data.importData( 83 data.importData(
107 UpdateType.ADDITION, 84 UpdateType.ADDITION,
108 prefixes, 85 RSA.Prefixes,
109 "<http://127.0.0.1/E>[?X,?Y] :- <http://127.0.0.1/PE>[?X,?Y], <http://127.0.0.1/U>[?X], <http://127.0.0.1/U>[?Y] ." 86 "<http://127.0.0.1/E>[?X,?Y] :- <http://127.0.0.1/PE>[?X,?Y], <http://127.0.0.1/U>[?X], <http://127.0.0.1/U>[?Y] ."
110 ) 87 )
111 88
@@ -117,17 +94,17 @@ trait RSAOntology {
117 println("\nQueries:") 94 println("\nQueries:")
118 RDFoxUtil.query( 95 RDFoxUtil.query(
119 data, 96 data,
120 prefixes, 97 RSA.Prefixes,
121 "SELECT ?X ?Y WHERE { ?X internal:PE ?Y }" 98 "SELECT ?X ?Y WHERE { ?X internal:PE ?Y }"
122 ) 99 )
123 RDFoxUtil.query( 100 RDFoxUtil.query(
124 data, 101 data,
125 prefixes, 102 RSA.Prefixes,
126 "SELECT ?X ?Y WHERE { ?X internal:E ?Y }" 103 "SELECT ?X ?Y WHERE { ?X internal:E ?Y }"
127 ) 104 )
128 RDFoxUtil.query( 105 RDFoxUtil.query(
129 data, 106 data,
130 prefixes, 107 RSA.Prefixes,
131 "SELECT ?X WHERE { ?X rdf:type owl:Thing }" 108 "SELECT ?X WHERE { ?X rdf:type owl:Thing }"
132 ) 109 )
133 110