diff options
Diffstat (limited to 'src/main/scala/rsacomb/RSAOntology.scala')
| -rw-r--r-- | src/main/scala/rsacomb/RSAOntology.scala | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/main/scala/rsacomb/RSAOntology.scala b/src/main/scala/rsacomb/RSAOntology.scala index 0acf2a6..e4348d8 100644 --- a/src/main/scala/rsacomb/RSAOntology.scala +++ b/src/main/scala/rsacomb/RSAOntology.scala | |||
| @@ -46,12 +46,13 @@ trait RSAOntology { | |||
| 46 | .toList | 46 | .toList |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | private lazy val roles: Set[OWLObjectPropertyExpression] = | 49 | private val roles: Set[OWLObjectPropertyExpression] = { |
| 50 | ontology | 50 | ontology |
| 51 | .rboxAxioms(Imports.INCLUDED) | 51 | .rboxAxioms(Imports.INCLUDED) |
| 52 | .collect(Collectors.toSet()) | 52 | .collect(Collectors.toSet()) |
| 53 | .asScala | 53 | .asScala |
| 54 | .flatMap(_.objectPropertyExpressionsInSignature) | 54 | .flatMap(_.objectPropertyExpressionsInSignature) |
| 55 | } | ||
| 55 | 56 | ||
| 56 | // OWLAPI reasoner for same easier tasks | 57 | // OWLAPI reasoner for same easier tasks |
| 57 | private val reasoner = | 58 | private val reasoner = |
| @@ -199,6 +200,37 @@ trait RSAOntology { | |||
| 199 | (unsafe1 ++ unsafe2).toList | 200 | (unsafe1 ++ unsafe2).toList |
| 200 | } | 201 | } |
| 201 | 202 | ||
| 203 | lazy val canonicalModel: List[Rule] = { | ||
| 204 | // Compute program to generate canonical model | ||
| 205 | val tbox = | ||
| 206 | ontology | ||
| 207 | .tboxAxioms(Imports.INCLUDED) | ||
| 208 | .collect(Collectors.toList()) | ||
| 209 | .asScala | ||
| 210 | .toList | ||
| 211 | val rbox = | ||
| 212 | ontology | ||
| 213 | .rboxAxioms(Imports.INCLUDED) | ||
| 214 | .collect(Collectors.toList()) | ||
| 215 | .asScala | ||
| 216 | .toList | ||
| 217 | val axioms = tbox ++ rbox | ||
| 218 | val varX = Variable.create("X") | ||
| 219 | val visitor = ProgramGenerator(ontology, varX, unsafeRoles) | ||
| 220 | val facts = ProgramGenerator.NIs(individuals) | ||
| 221 | val rules1 = ProgramGenerator.generateRoleRules( | ||
| 222 | axioms | ||
| 223 | .flatMap( | ||
| 224 | _.objectPropertiesInSignature.collect(Collectors.toSet()).asScala | ||
| 225 | ) | ||
| 226 | .toSet | ||
| 227 | ) | ||
| 228 | val rules2 = axioms.flatMap(_.accept(visitor)) | ||
| 229 | |||
| 230 | rules1 ++ rules2 | ||
| 231 | // Call RDFox to generate the canonical model | ||
| 232 | } | ||
| 233 | |||
| 202 | private def rsaGraph( | 234 | private def rsaGraph( |
| 203 | data: DataStoreConnection | 235 | data: DataStoreConnection |
| 204 | ): Graph[Resource, UnDiEdge] = { | 236 | ): Graph[Resource, UnDiEdge] = { |
