diff options
author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-10-09 19:15:27 +0200 |
---|---|---|
committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-10-09 19:15:27 +0200 |
commit | 733d962f27631cfb41de7b47d1fcec35b439537b (patch) | |
tree | cc59768eab97e28a19ef1b30ad6d32f3a5266ef7 | |
parent | 6d88de9bf58ddb499377a39b4d362e755fa379d2 (diff) | |
download | RSAComb-733d962f27631cfb41de7b47d1fcec35b439537b.tar.gz RSAComb-733d962f27631cfb41de7b47d1fcec35b439537b.zip |
Simplify ProgramGenerator constructor
If we pass the whole ontology there is no need to also provide the set
of unsafe roles.
-rw-r--r-- | src/main/scala/rsacomb/CanonicalModel.scala | 25 | ||||
-rw-r--r-- | src/main/scala/rsacomb/RDFoxUtil.scala | 15 | ||||
-rw-r--r-- | src/main/scala/rsacomb/RSA.scala | 6 | ||||
-rw-r--r-- | src/main/scala/rsacomb/RSAOntology.scala | 2 |
4 files changed, 32 insertions, 16 deletions
diff --git a/src/main/scala/rsacomb/CanonicalModel.scala b/src/main/scala/rsacomb/CanonicalModel.scala index 95eb556..a248d61 100644 --- a/src/main/scala/rsacomb/CanonicalModel.scala +++ b/src/main/scala/rsacomb/CanonicalModel.scala | |||
@@ -18,15 +18,15 @@ import tech.oxfordsemantic.jrdfox.logic.{ | |||
18 | Variable | 18 | Variable |
19 | } | 19 | } |
20 | import scala.collection.JavaConverters._ | 20 | import scala.collection.JavaConverters._ |
21 | import rsacomb.RSA._ | ||
21 | 22 | ||
22 | object ProgramGenerator { | 23 | object ProgramGenerator { |
23 | 24 | ||
24 | def apply( | 25 | def apply( |
25 | ontology: OWLOntology, | 26 | ontology: OWLOntology, |
26 | term: Term, | 27 | term: Term |
27 | unsafe: List[OWLObjectPropertyExpression] = List() | ||
28 | ): RDFoxAxiomConverter = | 28 | ): RDFoxAxiomConverter = |
29 | new ProgramGenerator(ontology, term, unsafe) | 29 | new ProgramGenerator(ontology, term) |
30 | 30 | ||
31 | def generateRoleRules( | 31 | def generateRoleRules( |
32 | roles: Set[OWLObjectProperty] | 32 | roles: Set[OWLObjectProperty] |
@@ -74,10 +74,13 @@ object ProgramGenerator { | |||
74 | 74 | ||
75 | class ProgramGenerator( | 75 | class ProgramGenerator( |
76 | ontology: OWLOntology, | 76 | ontology: OWLOntology, |
77 | term: Term, | 77 | term: Term |
78 | unsafe: List[OWLObjectPropertyExpression] | 78 | ) extends RDFoxAxiomConverter( |
79 | ) extends RDFoxAxiomConverter(term, unsafe, SkolemStrategy.None, RSASuffix.None) | 79 | term, |
80 | with RSAOntology | 80 | ontology.unsafeRoles, |
81 | SkolemStrategy.None, | ||
82 | RSASuffix.None | ||
83 | ) | ||
81 | with RSAAxiom { | 84 | with RSAAxiom { |
82 | 85 | ||
83 | import RDFoxUtil._ | 86 | import RDFoxUtil._ |
@@ -206,11 +209,11 @@ class ProgramGenerator( | |||
206 | // TODO: get role in T5 axiom | 209 | // TODO: get role in T5 axiom |
207 | // Assuming one role here | 210 | // Assuming one role here |
208 | val role = axiom.objectPropertyExpressionsInSignature(0) | 211 | val role = axiom.objectPropertyExpressionsInSignature(0) |
209 | if (unsafe.contains(role)) { | 212 | if (ontology.unsafeRoles.contains(role)) { |
210 | val visitor = | 213 | val visitor = |
211 | new RDFoxAxiomConverter( | 214 | new RDFoxAxiomConverter( |
212 | term, | 215 | term, |
213 | unsafe, | 216 | ontology.unsafeRoles, |
214 | SkolemStrategy.Standard(axiom.toString), | 217 | SkolemStrategy.Standard(axiom.toString), |
215 | RSASuffix.Forward | 218 | RSASuffix.Forward |
216 | ) | 219 | ) |
@@ -229,13 +232,13 @@ class ProgramGenerator( | |||
229 | val varY = Variable.create("Y") | 232 | val varY = Variable.create("Y") |
230 | val visitorF = new RDFoxAxiomConverter( | 233 | val visitorF = new RDFoxAxiomConverter( |
231 | term, | 234 | term, |
232 | unsafe, | 235 | ontology.unsafeRoles, |
233 | SkolemStrategy.None, | 236 | SkolemStrategy.None, |
234 | RSASuffix.Forward | 237 | RSASuffix.Forward |
235 | ) | 238 | ) |
236 | val visitorB = new RDFoxAxiomConverter( | 239 | val visitorB = new RDFoxAxiomConverter( |
237 | term, | 240 | term, |
238 | unsafe, | 241 | ontology.unsafeRoles, |
239 | SkolemStrategy.None, | 242 | SkolemStrategy.None, |
240 | RSASuffix.Backward | 243 | RSASuffix.Backward |
241 | ) | 244 | ) |
diff --git a/src/main/scala/rsacomb/RDFoxUtil.scala b/src/main/scala/rsacomb/RDFoxUtil.scala index b523d4e..8a144c6 100644 --- a/src/main/scala/rsacomb/RDFoxUtil.scala +++ b/src/main/scala/rsacomb/RDFoxUtil.scala | |||
@@ -12,14 +12,21 @@ import tech.oxfordsemantic.jrdfox.client.{ | |||
12 | } | 12 | } |
13 | import tech.oxfordsemantic.jrdfox.formats.SPARQLParser | 13 | import tech.oxfordsemantic.jrdfox.formats.SPARQLParser |
14 | 14 | ||
15 | import tech.oxfordsemantic.jrdfox.logic.{IRI => RDFox_IRI} | ||
16 | import org.semanticweb.owlapi.model.{IRI => OWL_IRI} | ||
17 | |||
15 | object RDFoxUtil { | 18 | object RDFoxUtil { |
16 | 19 | ||
17 | implicit def owlapi2rdfox(iri: org.semanticweb.owlapi.model.IRI): IRI = { | 20 | implicit def rdfox2owlapi(iri: RDFox_IRI): OWL_IRI = { |
18 | IRI.create(iri.getIRIString()) | 21 | OWL_IRI.create(iri.getIRI) |
22 | } | ||
23 | |||
24 | implicit def owlapi2rdfox(iri: OWL_IRI): RDFox_IRI = { | ||
25 | RDFox_IRI.create(iri.getIRIString()) | ||
19 | } | 26 | } |
20 | 27 | ||
21 | implicit def owlapi2rdfox(iri: String): IRI = { | 28 | implicit def owlapi2rdfox(iri: String): RDFox_IRI = { |
22 | IRI.create(iri) | 29 | RDFox_IRI.create(iri) |
23 | } | 30 | } |
24 | 31 | ||
25 | def openConnection( | 32 | def openConnection( |
diff --git a/src/main/scala/rsacomb/RSA.scala b/src/main/scala/rsacomb/RSA.scala index edabc6a..01982fc 100644 --- a/src/main/scala/rsacomb/RSA.scala +++ b/src/main/scala/rsacomb/RSA.scala | |||
@@ -39,6 +39,12 @@ object RSA extends RSAOntology { | |||
39 | Variable.create(f"I$counter%03d") | 39 | Variable.create(f"I$counter%03d") |
40 | } | 40 | } |
41 | 41 | ||
42 | def base(name: Any): IRI = | ||
43 | IRI.create( | ||
44 | Prefixes.getPrefixIRIsByPrefixName.get(":").getIRI | ||
45 | + name.toString | ||
46 | ) | ||
47 | |||
42 | def internal(name: Any): IRI = | 48 | def internal(name: Any): IRI = |
43 | IRI.create( | 49 | IRI.create( |
44 | Prefixes.getPrefixIRIsByPrefixName.get("internal:").getIRI | 50 | Prefixes.getPrefixIRIsByPrefixName.get("internal:").getIRI |
diff --git a/src/main/scala/rsacomb/RSAOntology.scala b/src/main/scala/rsacomb/RSAOntology.scala index e4348d8..05b6218 100644 --- a/src/main/scala/rsacomb/RSAOntology.scala +++ b/src/main/scala/rsacomb/RSAOntology.scala | |||
@@ -216,7 +216,7 @@ trait RSAOntology { | |||
216 | .toList | 216 | .toList |
217 | val axioms = tbox ++ rbox | 217 | val axioms = tbox ++ rbox |
218 | val varX = Variable.create("X") | 218 | val varX = Variable.create("X") |
219 | val visitor = ProgramGenerator(ontology, varX, unsafeRoles) | 219 | val visitor = ProgramGenerator(ontology, varX) |
220 | val facts = ProgramGenerator.NIs(individuals) | 220 | val facts = ProgramGenerator.NIs(individuals) |
221 | val rules1 = ProgramGenerator.generateRoleRules( | 221 | val rules1 = ProgramGenerator.generateRoleRules( |
222 | axioms | 222 | axioms |