Skip to content

Commit

Permalink
make class and property definition lookup functions
Browse files Browse the repository at this point in the history
  • Loading branch information
BalduinLandolt committed Dec 22, 2024
1 parent 287600d commit 70e3ea9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final case class OntologyInferencer(
case None => knownSubClasses
case Some(relevantOntologyIris) =>
// filter the known subclasses against the relevant ontologies
knownSubClasses.filter(cache.classDefinedInOntology.get(_).exists(relevantOntologyIris.contains(_)))
knownSubClasses.filter(cache.classDefinedInOntology(_).exists(relevantOntologyIris.contains(_)))
}

// Searches for a `?v a <subClassIRI>`, or if multiple subclasses are present, then
Expand All @@ -68,7 +68,7 @@ final case class OntologyInferencer(
// if provided, limit the child properties to those that belong to relevant ontologies
val subProps = limitInferenceToOntologies match {
case Some(ontologyIris) =>
knownSubProps.filter(cache.propertyDefinedInOntology.get(_).exists(ontologyIris.contains(_)))
knownSubProps.filter(cache.propertyDefinedInOntology(_).exists(ontologyIris.contains(_)))
case None => knownSubProps
}
// Searches for a `?v <propertyIRI> ?b`, or if multiple propertyIRIs are present, then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ case class OntologyCacheData(
classToSubclassLookup: Map[SmartIri, Set[SmartIri]],
subPropertyOfRelations: Map[SmartIri, Set[SmartIri]],
superPropertyOfRelations: Map[SmartIri, Set[SmartIri]],
classDefinedInOntology: Map[SmartIri, SmartIri],
propertyDefinedInOntology: Map[SmartIri, SmartIri],
private val classDefinedInOntology: Map[SmartIri, SmartIri],
private val propertyDefinedInOntology: Map[SmartIri, SmartIri],
private val entityDefinedInOntology: Map[SmartIri, SmartIri],
private val standoffProperties: Set[SmartIri],
) {
Expand All @@ -44,7 +44,9 @@ case class OntologyCacheData(
def getAllStandoffPropertyEntities: Map[SmartIri, ReadPropertyInfoV2] =
ontologies.values.flatMap(_.properties.view.filterKeys(standoffProperties)).toMap

def entityDefinedInOntology(propertyIri: SmartIri): Option[SmartIri] = entityDefinedInOntology.get(propertyIri)
def entityDefinedInOntology(propertyIri: SmartIri): Option[SmartIri] = entityDefinedInOntology.get(propertyIri)
def classDefinedInOntology(classIri: SmartIri): Option[SmartIri] = classDefinedInOntology.get(classIri)
def propertyDefinedInOntology(propertyIri: SmartIri): Option[SmartIri] = propertyDefinedInOntology.get(propertyIri)
}
object OntologyCacheData {
val Empty = OntologyCacheData(
Expand Down

0 comments on commit 70e3ea9

Please sign in to comment.