Skip to content

Commit

Permalink
no strings in Ontology classes
Browse files Browse the repository at this point in the history
  • Loading branch information
kontchakov committed Jun 19, 2019
1 parent f2e59ec commit 9630c41
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 115 deletions.
Expand Up @@ -8,6 +8,8 @@
import org.apache.commons.rdf.simple.SimpleRDF;
import org.junit.Test;

import static it.unibz.inf.ontop.owlapi.OWL2QLTranslatorTest.getIRI;
import static it.unibz.inf.ontop.owlapi.OWL2QLTranslatorTest.loadOntologyFromFileAndClassify;
import static org.junit.Assert.assertEquals;


Expand All @@ -24,12 +26,12 @@ public class ClassifiedTBoxTest {
@Test
public void test_top_property() throws Exception {

ClassifiedTBox ontology = OWL2QLTranslatorTest.loadOntologyFromFileAndClassify("src/test/resources/ontology/ontology_with_top.owl");
ClassifiedTBox ontology = loadOntologyFromFileAndClassify("src/test/resources/ontology/ontology_with_top.owl");
Equivalences<ClassExpression> top = ontology.classesDAG().getVertex(ClassImpl.owlThing);
assertEquals(3, top.getMembers().size());
OntologyBuilder builder = OntologyBuilderImpl.builder(new SimpleRDF());
OClass percorso = builder.declareClass("http://my.org/navi#Percorso");
OClass linee = builder.declareClass("http://my.org/navi#LineeDiPercorso");
OClass percorso = builder.declareClass(getIRI("http://my.org/navi#", "Percorso"));
OClass linee = builder.declareClass(getIRI("http://my.org/navi#", "LineeDiPercorso"));
assertEquals(ImmutableSet.of(ClassImpl.owlThing, percorso, linee), top.getMembers());
}

Expand Down
Expand Up @@ -407,20 +407,20 @@ public void test_R5() throws Exception {
public void test_R6() {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);

ObjectPropertyExpression top = builder.declareObjectProperty("http://www.w3.org/2002/07/owl#topObjectProperty");
ObjectPropertyExpression top = builder.declareObjectProperty(rdfFactory.createIRI("http://www.w3.org/2002/07/owl#topObjectProperty"));
ObjectPropertyExpression topInv = top.getInverse();
ObjectPropertyExpression topInvInv = topInv.getInverse();
assertTrue(topInv == topInvInv);

ObjectPropertyExpression top2 = builder.declareObjectProperty("http://www.w3.org/2002/07/owl#topObjectProperty");
ObjectPropertyExpression top2 = builder.declareObjectProperty(rdfFactory.createIRI("http://www.w3.org/2002/07/owl#topObjectProperty"));
assertEquals(top2, topInv);

ObjectPropertyExpression bot = builder.declareObjectProperty("http://www.w3.org/2002/07/owl#bottomObjectProperty");
ObjectPropertyExpression bot = builder.declareObjectProperty(rdfFactory.createIRI("http://www.w3.org/2002/07/owl#bottomObjectProperty"));
ObjectPropertyExpression botInv = bot.getInverse();
ObjectPropertyExpression botInvInv = botInv.getInverse();
assertTrue(botInv == botInvInv);

ObjectPropertyExpression bot2 = builder.declareObjectProperty("http://www.w3.org/2002/07/owl#bottomObjectProperty");
ObjectPropertyExpression bot2 = builder.declareObjectProperty(rdfFactory.createIRI("http://www.w3.org/2002/07/owl#bottomObjectProperty"));
assertEquals(bot2, botInv);

assertFalse(bot.equals(top));
Expand Down
Expand Up @@ -3,6 +3,7 @@
import it.unibz.inf.ontop.model.term.Constant;
import it.unibz.inf.ontop.model.term.ObjectConstant;
import it.unibz.inf.ontop.model.term.ValueConstant;
import org.apache.commons.rdf.api.IRI;

public interface OntologyBuilder {

Expand All @@ -20,17 +21,17 @@ public interface OntologyBuilder {
/**
* declare an entity
*
* @param uri
* @param iri
* @return entity object
*/

OClass declareClass(String uri);
OClass declareClass(IRI iri);

ObjectPropertyExpression declareObjectProperty(String uri);
ObjectPropertyExpression declareObjectProperty(IRI iri);

DataPropertyExpression declareDataProperty(String uri);
DataPropertyExpression declareDataProperty(IRI iri);

AnnotationProperty declareAnnotationProperty(String uri);
AnnotationProperty declareAnnotationProperty(IRI iri);



Expand Down
Expand Up @@ -154,23 +154,23 @@ OntologyImpl.ImmutableOntologyVocabularyCategoryImpl<T> getImmutableCopy() {


@Override
public OClass declareClass(String uri) {
return classes.create(rdfFactory.createIRI(uri));
public OClass declareClass(IRI iri) {
return classes.create(iri);
}

@Override
public ObjectPropertyExpression declareObjectProperty(String uri) {
return objectProperties.create(rdfFactory.createIRI(uri));
public ObjectPropertyExpression declareObjectProperty(IRI iri) {
return objectProperties.create(iri);
}

@Override
public DataPropertyExpression declareDataProperty(String uri) {
return dataProperties.create(rdfFactory.createIRI(uri));
public DataPropertyExpression declareDataProperty(IRI uri) {
return dataProperties.create(uri);
}

@Override
public AnnotationProperty declareAnnotationProperty(String uri) {
return annotationProperties.create(rdfFactory.createIRI(uri));
public AnnotationProperty declareAnnotationProperty(IRI iri) {
return annotationProperties.create(iri);
}

@Override
Expand Down
Expand Up @@ -16,7 +16,7 @@ public class TopBotInClassifiedTBoxTest {
@Test
public void topClass() throws InconsistentOntologyException {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);
OClass a = builder.declareClass("http://a");
OClass a = builder.declareClass(rdfFactory.createIRI("http://a"));
builder.addSubClassOfAxiom(ClassImpl.owlThing, a);
Ontology ontology = builder.build();

Expand All @@ -29,7 +29,7 @@ public void topClass() throws InconsistentOntologyException {
@Test
public void bottomClass() throws InconsistentOntologyException {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);
OClass a = builder.declareClass("http://a");
OClass a = builder.declareClass(rdfFactory.createIRI("http://a"));
builder.addSubClassOfAxiom(a, ClassImpl.owlNothing);
Ontology ontology = builder.build();

Expand All @@ -42,8 +42,8 @@ public void bottomClass() throws InconsistentOntologyException {
@Test
public void noTopBottomClass() throws InconsistentOntologyException {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);
OClass a = builder.declareClass("http://a");
OClass b = builder.declareClass("http://b");
OClass a = builder.declareClass(rdfFactory.createIRI("http://a"));
OClass b = builder.declareClass(rdfFactory.createIRI("http://b"));
builder.addSubClassOfAxiom(b, a);
Ontology ontology = builder.build();

Expand All @@ -58,7 +58,7 @@ public void noTopBottomClass() throws InconsistentOntologyException {
@Test
public void topObjectProperty() throws InconsistentOntologyException {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);
ObjectPropertyExpression a = builder.declareObjectProperty("http://a");
ObjectPropertyExpression a = builder.declareObjectProperty(rdfFactory.createIRI("http://a"));
builder.addSubPropertyOfAxiom(ObjectPropertyExpressionImpl.owlTopObjectProperty, a);
Ontology ontology = builder.build();

Expand All @@ -72,8 +72,8 @@ public void topObjectProperty() throws InconsistentOntologyException {
@Test
public void topObjectPropertyDomain() throws InconsistentOntologyException {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);
OClass a = builder.declareClass("http://a");
OClass b = builder.declareClass("http://b");
OClass a = builder.declareClass(rdfFactory.createIRI("http://a"));
OClass b = builder.declareClass(rdfFactory.createIRI("http://b"));
builder.addSubClassOfAxiom(ObjectPropertyExpressionImpl.owlTopObjectProperty.getDomain(), a);
Ontology ontology = builder.build();

Expand All @@ -89,7 +89,7 @@ public void topObjectPropertyDomain() throws InconsistentOntologyException {
@Test
public void topObjectPropertyRange() throws InconsistentOntologyException {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);
OClass a = builder.declareClass("http://a");
OClass a = builder.declareClass(rdfFactory.createIRI("http://a"));
builder.addSubClassOfAxiom(ObjectPropertyExpressionImpl.owlTopObjectProperty.getRange(), a);
Ontology ontology = builder.build();

Expand All @@ -102,7 +102,7 @@ public void topObjectPropertyRange() throws InconsistentOntologyException {
@Test
public void botObjectProperty() throws InconsistentOntologyException {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);
ObjectPropertyExpression a = builder.declareObjectProperty("http://a");
ObjectPropertyExpression a = builder.declareObjectProperty(rdfFactory.createIRI("http://a"));
builder.addSubPropertyOfAxiom(ObjectPropertyExpressionImpl.owlBottomObjectProperty, a);
Ontology ontology = builder.build();

Expand All @@ -114,7 +114,7 @@ public void botObjectProperty() throws InconsistentOntologyException {
@Test
public void botObjectPropertyDomain() throws InconsistentOntologyException {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);
OClass a = builder.declareClass("http://a");
OClass a = builder.declareClass(rdfFactory.createIRI("http://a"));
builder.addSubClassOfAxiom(a, ObjectPropertyExpressionImpl.owlBottomObjectProperty.getDomain());
Ontology ontology = builder.build();

Expand All @@ -127,7 +127,7 @@ public void botObjectPropertyDomain() throws InconsistentOntologyException {
@Test
public void botObjectPropertyRange() throws InconsistentOntologyException {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);
OClass a = builder.declareClass("http://a");
OClass a = builder.declareClass(rdfFactory.createIRI("http://a"));
builder.addSubClassOfAxiom(a, ObjectPropertyExpressionImpl.owlBottomObjectProperty.getRange());
Ontology ontology = builder.build();

Expand All @@ -141,8 +141,8 @@ public void botObjectPropertyRange() throws InconsistentOntologyException {
@Test
public void noTopBottomObjectProperty() throws InconsistentOntologyException {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);
ObjectPropertyExpression a = builder.declareObjectProperty("http://a");
ObjectPropertyExpression b = builder.declareObjectProperty("http://b");
ObjectPropertyExpression a = builder.declareObjectProperty(rdfFactory.createIRI("http://a"));
ObjectPropertyExpression b = builder.declareObjectProperty(rdfFactory.createIRI("http://b"));
builder.addSubPropertyOfAxiom(b, a);
Ontology ontology = builder.build();

Expand All @@ -161,7 +161,7 @@ public void noTopBottomObjectProperty() throws InconsistentOntologyException {
@Test
public void topDataProperty() throws InconsistentOntologyException {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);
DataPropertyExpression a = builder.declareDataProperty("http://a");
DataPropertyExpression a = builder.declareDataProperty(rdfFactory.createIRI("http://a"));
builder.addSubPropertyOfAxiom(DataPropertyExpressionImpl.owlTopDataProperty, a);
Ontology ontology = builder.build();

Expand All @@ -174,7 +174,7 @@ public void topDataProperty() throws InconsistentOntologyException {
@Test
public void topDataPropertyDomain() throws InconsistentOntologyException {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);
OClass a = builder.declareClass("http://a");
OClass a = builder.declareClass(rdfFactory.createIRI("http://a"));
builder.addSubClassOfAxiom(DataPropertyExpressionImpl.owlTopDataProperty.getDomainRestriction(rdfsLiteral), a);
Ontology ontology = builder.build();

Expand All @@ -187,7 +187,7 @@ public void topDataPropertyDomain() throws InconsistentOntologyException {
@Test
public void botDataProperty() throws InconsistentOntologyException {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);
DataPropertyExpression a = builder.declareDataProperty("http://a");
DataPropertyExpression a = builder.declareDataProperty(rdfFactory.createIRI("http://a"));
builder.addSubPropertyOfAxiom(DataPropertyExpressionImpl.owlBottomDataProperty, a);
Ontology ontology = builder.build();

Expand All @@ -199,7 +199,7 @@ public void botDataProperty() throws InconsistentOntologyException {
@Test
public void botDataPropertyDomain() throws InconsistentOntologyException {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);
OClass a = builder.declareClass("http://a");
OClass a = builder.declareClass(rdfFactory.createIRI("http://a"));
builder.addSubClassOfAxiom(a,
DataPropertyExpressionImpl.owlBottomDataProperty.getDomainRestriction(rdfsLiteral));
Ontology ontology = builder.build();
Expand All @@ -213,8 +213,8 @@ public void botDataPropertyDomain() throws InconsistentOntologyException {
@Test
public void noTopBottomDataProperty() throws InconsistentOntologyException {
OntologyBuilder builder = OntologyBuilderImpl.builder(rdfFactory);
DataPropertyExpression a = builder.declareDataProperty("http://a");
DataPropertyExpression b = builder.declareDataProperty("http://b");
DataPropertyExpression a = builder.declareDataProperty(rdfFactory.createIRI("http://a"));
DataPropertyExpression b = builder.declareDataProperty(rdfFactory.createIRI("http://b"));
builder.addSubPropertyOfAxiom(b, a);
Ontology ontology = builder.build();

Expand Down

0 comments on commit 9630c41

Please sign in to comment.