subProp = st;
}
}
else if( expr.getPredicate().equals( OWL2.propertyChain.asNode() ) ) {
subProp = createList( expr.getObject() );
ATermList list = (ATermList) subProp;
while( !list.isEmpty() ) {
if( !defineObjectProperty( (ATermAppl) list.getFirst() ) ) {
break;
}
list = list.getNext();
}
if( !list.isEmpty() || !defineObjectProperty( ot ) ) {
subProp = null;
}
}
else {
addUnsupportedFeature( "Bnode in rdfs:subProperty axioms is not a valid property expression" );
}
}
else if( defineProperties( st, ot ) ) {
subProp = st;
}
if( subProp != null ) {
kb.addSubProperty( subProp, ot );
}
else {
addUnsupportedFeature( "Ignoring subproperty axiom between " + st + " ("
+ kb.getPropertyType( st ) + "Property) and " + ot + " ("
+ kb.getPropertyType( ot ) + "Property)" );
}
break;
case RDFS_domain:
if( kb.isAnnotationProperty( st ) ) {
addUnsupportedFeature( "Ignoring domain axiom for AnnotationProperty " + st );
}
else {
defineProperty( st );
defineClass( ot );
kb.addDomain( st, ot );
}
break;
case RDFS_range:
if( kb.isAnnotationProperty( st ) ) {
addUnsupportedFeature( "Ignoring range axiom for AnnotationProperty " + st );
break;
}
if( kb.isDatatype( ot ) ) {
defineDatatypeProperty( st );
}
else if( kb.isClass( ot ) ) {
defineObjectProperty( st );
}
else {
defineProperty( st );
}
if( kb.isDatatypeProperty( st ) ) {
defineDatatype( ot );
}
else if( kb.isObjectProperty( st ) ) {
defineClass( ot );
}
kb.addRange( st, ot );
break;
case OWL_intersectionOf:
ATermList list = createList( o );
defineClass( st );
ATermAppl conjunction = ATermUtils.makeAnd( list );
kb.addEquivalentClass( st, conjunction );
break;
case OWL_unionOf:
list = createList( o );
defineClass( st );
ATermAppl disjunction = ATermUtils.makeOr( list );
kb.addEquivalentClass( st, disjunction );
break;
case OWL2_disjointUnionOf:
list = createList( o );
kb.addDisjointClasses( list );
defineClass( st );
disjunction = ATermUtils.makeOr( list );
kb.addEquivalentClass( st, disjunction );
break;
case OWL_complementOf:
if( !defineClass( st ) ) {
addUnsupportedFeature( "Ignoring complementOf axiom because the subject is not a class "
+ st + " owl:complementOf " + ot );
}
else if( !defineClass( ot ) ) {
addUnsupportedFeature( "Ignoring complementOf axiom because the object is not a class "
+ st + " owl:complementOf " + ot );
}
else {
kb.addComplementClass( st, ot );
}
break;
case OWL_equivalentClass:
if( kb.isDatatype( ot ) || anonDatatypes.contains( o ) ) {
if( !defineDatatype( st ) ) {
addUnsupportedFeature( "Ignoring equivalentClass axiom because the subject is not a datatype "
+ st + " owl:equivalentClass " + ot );
}
else {
kb.addDatatypeDefinition( st, ot );
}
}
else if( !defineClass( st ) ) {
addUnsupportedFeature( "Ignoring equivalentClass axiom because the subject is not a class "
+ st + " owl:equivalentClass " + ot );
}
else if( !defineClass( ot ) ) {
addUnsupportedFeature( "Ignoring equivalentClass axiom because the object is not a class "
+ st + " owl:equivalentClass " + ot );
}
else {
kb.addEquivalentClass( st, ot );
}
break;
case OWL_disjointWith:
if( !defineClass( st ) ) {
addUnsupportedFeature( "Ignoring disjointWith axiom because the subject is not a class "
+ st + " owl:disjointWith " + ot );
}
else if( !defineClass( ot ) ) {
addUnsupportedFeature( "Ignoring disjointWith axiom because the object is not a class "
+ st + " owl:disjointWith " + ot );
}
else {
kb.addDisjointClass( st, ot );
}
break;
case OWL2_propertyDisjointWith:
if( defineProperties( st, ot ) ) {
kb.addDisjointProperty( st, ot );
addSimpleProperty( st, DISJOINT );
addSimpleProperty( ot, DISJOINT );
}
else {
addUnsupportedFeature( "Ignoring disjoint property axiom between " + st + " ("
+ kb.getPropertyType( st ) + "Property) and " + ot + " ("
+ kb.getPropertyType( ot ) + "Property)" );
}
break;
case OWL2_propertyChainAxiom:
ATermAppl superProp = null;
if( s.isBlank() ) {
Triple expr = getExpression( s );
if( expr == null ) {
addUnsupportedFeature( "Bnode in owl:propertyChainAxiom axiom is not a valid property expression" );
}
else if( expr.getPredicate().equals( OWL2.inverseOf.asNode() ) ) {
if( defineObjectProperty( (ATermAppl) st.getArgument( 0 ) ) ) {
superProp = st;
}
}
else {
addUnsupportedFeature( "Bnode in owl:propertyChainAxiom axiom is not a valid property expression" );
}
}
else if( defineObjectProperty( st ) ) {
superProp = st;
}
subProp = createList( o );
list = (ATermList) subProp;
while( !list.isEmpty() ) {
if( !defineObjectProperty( (ATermAppl) list.getFirst() ) ) {
break;
}
list = list.getNext();
}
if( !list.isEmpty() ) {
subProp = null;
}
if( subProp != null && superProp != null ) {
kb.addSubProperty( subProp, superProp );
}
else {
addUnsupportedFeature( "Ignoring property chain axiom between " + st + " ("
+ kb.getPropertyType( st ) + "Property) and " + ot );
}
break;
case OWL_equivalentProperty:
if( defineProperties( st, ot ) ) {
kb.addEquivalentProperty( st, ot );
}
else {
addUnsupportedFeature( "Ignoring equivalent property axiom between " + st + " ("
+ kb.getPropertyType( st ) + "Property) and " + ot + " ("
+ kb.getPropertyType( ot ) + "Property)" );
}
break;
case OWL_inverseOf:
if( defineObjectProperty( st ) && defineObjectProperty( ot ) ) {
kb.addInverseProperty( st, ot );
}
else {
addUnsupportedFeature( "Ignoring inverseOf axiom between " + st + " ("
+ kb.getPropertyType( st ) + "Property) and " + ot + " ("
+ kb.getPropertyType( ot ) + "Property)" );
}
break;
case OWL_sameAs:
if( defineIndividual( st ) && defineIndividual( ot ) ) {
kb.addSame( st, ot );
}
else {
addUnsupportedFeature( "Ignoring sameAs axiom between " + st + " and " + ot );
}
break;
case OWL_differentFrom:
if( defineIndividual( st ) && defineIndividual( ot ) ) {
kb.addDifferent( st, ot );
}
else {
addUnsupportedFeature( "Ignoring differentFrom axiom between " + st + " and " + ot );
}
break;
case OWL_distinctMembers:
list = createList( o );
for( ATermList l = list; !l.isEmpty(); l = l.getNext() ) {
ATermAppl c = (ATermAppl) l.getFirst();
defineIndividual( c );
}
kb.addAllDifferent( list );
break;
case OWL_members:
BuiltinTerm entityType = null;
if( preprocessTypeTriples ) {
entityType = naryDisjoints.get( s );
}
else {
Node type = getObject( s, RDF.type.asNode() );
if( type != null ) {
entityType = BuiltinTerm.find( type );
}
}
if( entityType == null ) {
addUnsupportedFeature( "There is no valid rdf:type for an owl:members assertion: "
+ s );
}
else if( !OWL_MEMBERS_TYPES.contains( entityType ) ) {
addUnsupportedFeature( "The rdf:type for an owl:members assertion is not recognized: "
+ entityType );
}
else {
list = createList( o );
for( ATermList l = list; !l.isEmpty(); l = l.getNext() ) {
ATermAppl c = (ATermAppl) l.getFirst();
switch ( entityType ) {
case OWL_AllDifferent:
defineIndividual( c );
break;
case OWL2_AllDisjointClasses:
defineClass( c );
break;
case OWL2_AllDisjointProperties:
defineProperty( c );
break;
}
}
switch ( entityType ) {
case OWL_AllDifferent:
kb.addAllDifferent( list );
break;
case OWL2_AllDisjointClasses:
kb.addDisjointClasses( list );
break;
case OWL2_AllDisjointProperties:
kb.addDisjointProperties( list );
break;
}
}
break;
case OWL_oneOf:
ATermList resultList = ATermUtils.EMPTY_LIST;
if( kb.isDatatype( st ) ) {
return;
}
// assert the subject is a class
defineClass( st );
disjunction = null;
list = createList( o );
if( o.equals( RDF.nil.asNode() ) ) {
disjunction = ATermUtils.BOTTOM;
}
else {
for( ATermList l = list; !l.isEmpty(); l = l.getNext() ) {
ATermAppl c = (ATermAppl) l.getFirst();
if( PelletOptions.USE_PSEUDO_NOMINALS ) {
ATermAppl nominal = ATermUtils.makeTermAppl( c.getName() + "_nominal" );
resultList = resultList.insert( nominal );
defineClass( nominal );
defineIndividual( c );
kb.addType( c, nominal );
}
else {
defineIndividual( c );
resultList = resultList.insert( ATermUtils.makeValue( c ) );
}
}
disjunction = ATermUtils.makeOr( resultList );
}
kb.addEquivalentClass( st, disjunction );