protected void processTriple(Triple triple) {
Node p = triple.getPredicate();
Node s = triple.getSubject();
Node o = triple.getObject();
BuiltinTerm builtinTerm = BuiltinTerm.find( p );
if( builtinTerm != null ) {
if( builtinTerm.isSyntax() ) {
return;
}
if( builtinTerm.equals( BuiltinTerm.RDF_type ) ) {
if( BuiltinTerm.find( o ) == null ) {
if( isLoadABox() ) {
ATermAppl ot = node2term( o );
if (!AnnotationClasses.contains(ot)) {
defineClass( ot );
ATermAppl st = node2term( s );
defineIndividual( st );
kb.addType( st, ot );
}
}
}
else if( !preprocessTypeTriples ) {
processType( triple );
}
return;
}
}
monitor.incrementProgress();
ATermAppl st = node2term( s );
ATermAppl ot = node2term( o );
if( builtinTerm == null ) {
ATermAppl pt = node2term( p );
Role role = kb.getProperty( pt );
PropertyType type = (role == null)
? PropertyType.UNTYPED
: role.getType();
if( type == PropertyType.ANNOTATION ) {
// Skip ontology annotations
if( graph.contains( s, RDF.type.asNode(), OWL.Ontology.asNode() ) ) {
return;
}
if( defineAnnotationProperty( pt ) ) {
kb.addAnnotation( st, pt, ot );
}
return;
}
if( PelletOptions.FREEZE_BUILTIN_NAMESPACES ) {
String nameSpace = p.getNameSpace();
if( nameSpace != null ) {
BuiltinNamespace builtin = BuiltinNamespace.find( nameSpace );
if( builtin != null ) {
addUnsupportedFeature( "Ignoring triple with unknown property from "
+ builtin + " namespace: " + triple );
return;
}
}
}
if( o.isLiteral() ) {
if( defineDatatypeProperty( pt ) ) {
String datatypeURI = ((ATermAppl) ot.getArgument( 2 )).getName();
if( defineIndividual( st ) ) {
defineDatatypeProperty( pt );
if( !datatypeURI.equals( "" ) ) {
defineDatatype( ATermUtils.makeTermAppl( datatypeURI ) );
}
kb.addPropertyValue( pt, st, ot );
}
else if( type == PropertyType.UNTYPED ) {
defineAnnotationProperty( pt );
}
else {
addUnsupportedFeature( "Ignoring ObjectProperty used with a class expression: "
+ triple );
}
}
else {
addUnsupportedFeature( "Ignoring literal value used with ObjectProperty : "
+ triple );
}
}
else {
if( !defineObjectProperty( pt ) ) {
addUnsupportedFeature( "Ignoring object value used with DatatypeProperty: "
+ triple );
}
else if( !defineIndividual( st ) ) {
addUnsupportedFeature( "Ignoring class expression used in subject position: "
+ triple );
}
else if( !defineIndividual( ot ) ) {
addUnsupportedFeature( "Ignoring class expression used in object position: "
+ triple );
}
else {
kb.addPropertyValue( pt, st, ot );
}
}
return;
}
switch ( builtinTerm ) {
case RDFS_subClassOf:
if( !defineClass( st ) ) {
addUnsupportedFeature( "Ignoring subClassOf axiom because the subject is not a class "
+ st + " rdfs:subClassOf " + ot );
}
else if( !defineClass( ot ) ) {
addUnsupportedFeature( "Ignoring subClassOf axiom because the object is not a class "
+ st + " rdfs:subClassOf " + ot );
}
else {
kb.addSubClass( st, ot );
}
break;
case RDFS_subPropertyOf:
ATerm subProp = null;
if( s.isBlank() ) {
Triple expr = getExpression( s );
if( expr == null ) {
addUnsupportedFeature( "Bnode in rdfs:subProperty axioms is not a valid property expression" );
}
else if( expr.getPredicate().equals( OWL2.inverseOf.asNode() ) ) {
if( defineObjectProperty( (ATermAppl) st.getArgument( 0 ) )
&& defineObjectProperty( ot ) ) {
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() );