-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0131047
commit 2ea7322
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
components-core/src/main/java/org/dllearner/reasoning/OWLPunningDetector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* | ||
*/ | ||
package org.dllearner.reasoning; | ||
|
||
import org.dllearner.core.owl.NamedClass; | ||
import org.dllearner.core.owl.ObjectProperty; | ||
import org.semanticweb.owlapi.model.IRI; | ||
import org.semanticweb.owlapi.model.OWLOntology; | ||
|
||
/** | ||
* @author Lorenz Buehmann | ||
* | ||
*/ | ||
public class OWLPunningDetector { | ||
|
||
/** | ||
* This object property is used to connect individuals with classes that are also individuals, thus, lead to punning. | ||
*/ | ||
public static final ObjectProperty punningProperty = new ObjectProperty("http://dl-learner.org/punning/relatedTo"); | ||
|
||
/** | ||
* Checks whether the same IRI denotes both a class and an individual in the ontology. | ||
* @param ontology | ||
* @param iri | ||
* @return | ||
*/ | ||
public static boolean hasPunning(OWLOntology ontology, NamedClass cls){ | ||
return hasPunning(ontology, IRI.create(cls.getName())); | ||
} | ||
|
||
/** | ||
* Checks whether the same IRI denotes both a class and an individual in the ontology. | ||
* @param ontology | ||
* @param iri | ||
* @return | ||
*/ | ||
public static boolean hasPunning(OWLOntology ontology, IRI iri){ | ||
boolean isClass = ontology.getClassesInSignature().contains(ontology.getOWLOntologyManager().getOWLDataFactory().getOWLClass(iri)); | ||
boolean isIndividual = ontology.getIndividualsInSignature().contains(ontology.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(iri)); | ||
return isClass && isIndividual; | ||
} | ||
|
||
/** | ||
* Checks whether the same IRI denotes both a class and an individual in the ontology. | ||
* @param ontology | ||
* @param iri | ||
* @return | ||
*/ | ||
public static boolean hasPunning(OWLOntology ontology, String iri){ | ||
return hasPunning(ontology, IRI.create(iri)); | ||
} | ||
|
||
} |