Package com.hp.hpl.jena.ontology

Examples of com.hp.hpl.jena.ontology.ObjectProperty


    String ns = "http://www.example.org/family#";

    OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC, null );
    model.read( base + "family.owl" );

    ObjectProperty hasBrother = model.getObjectProperty( ns + "hasBrother" );
    ObjectProperty hasSon = model.getObjectProperty( ns + "hasSon" );
    ObjectProperty hasFather = model.getObjectProperty( ns + "hasFather" );
    ObjectProperty hasParent = model.getObjectProperty( ns + "hasParent" );
    ObjectProperty hasChild = model.getObjectProperty( ns + "hasChild" );
    ObjectProperty hasMother = model.getObjectProperty( ns + "hasMother" );
    ObjectProperty hasDaughter = model.getObjectProperty( ns + "hasDaughter" );
    ObjectProperty hasAncestor = model.getObjectProperty( ns + "hasAncestor" );
    ObjectProperty likes = model.getObjectProperty( ns + "likes" );
    ObjectProperty isMarriedTo = model.getObjectProperty( ns + "isMarriedTo" );
    ObjectProperty dislikes = model.getObjectProperty( ns + "dislikes" );
    ObjectProperty hasSister = model.getObjectProperty( ns + "hasSister" );
    ObjectProperty hasDescendant = model.getObjectProperty( ns + "hasDescendant" );
    ObjectProperty hasSibling = model.getObjectProperty( ns + "hasSibling" );
    OntClass Child = model.getOntClass( ns + "Child" );
    OntClass Person = model.getOntClass( ns + "Person" );
    OntClass PersonWithAtLeastTwoMaleChildren = model.getOntClass( ns
        + "PersonWithAtLeastTwoMaleChildren" );
    OntClass PersonWithAtLeastTwoFemaleChildren = model.getOntClass( ns
View Full Code Here


    OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC, null );
    model.read( base + "dl-safe.owl" );

    // ObjectProperty father = model.getObjectProperty( ns + "father" );
    ObjectProperty hates = model.getObjectProperty( ns + "hates" );
    ObjectProperty sibling = model.getObjectProperty( ns + "sibling" );

    OntClass BadChild = model.getOntClass( ns + "BadChild" );
    OntClass Child = model.getOntClass( ns + "Child" );
    // OntClass GoodChild = model.getOntClass( ns + "GoodChild" );
    OntClass Grandchild = model.getOntClass( ns + "Grandchild" );
View Full Code Here

    String ns = "urn:test:";

    OntModel reasoner = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );

    ObjectProperty p = reasoner.createObjectProperty( ns + "p" );
    ObjectProperty subP = reasoner.createObjectProperty( ns + "subP" );
    ObjectProperty subSubP = reasoner.createObjectProperty( ns + "subSubP" );
   
    DatatypeProperty q = reasoner.createDatatypeProperty( ns + "q" );
    DatatypeProperty subQ = reasoner.createDatatypeProperty( ns + "subQ" );
    DatatypeProperty subSubQ = reasoner.createDatatypeProperty( ns + "subSubQ" );
   
   
    // create assertions in one RDF model
    Model assertions = ModelFactory.createDefaultModel();
    assertions.add( subP, RDFS.subPropertyOf, p );
    assertions.add( subSubP, RDFS.subPropertyOf, subP );
    assertions.add( subQ, RDFS.subPropertyOf, q );
    assertions.add( subSubQ, RDFS.subPropertyOf, subQ );

    // load the assertions to the reasoner
    reasoner.add( assertions );

    // create the inferences for testing in a separate RDF model
    Model inferences = ModelFactory.createDefaultModel();
    // all assertions should be inferred
    inferences.add( assertions );
    // rdfs:subPropertyOf is reflexive
    for( Property op : new Property[] { p, subP, subSubP, q, subQ, subSubQ } ) {
      inferences.add( op, RDFS.subPropertyOf, op );
    }
    // All object properties are a sub property of topObjectProperty
    for( Property op : new Property[] { p, subP, subSubP, OWL2.topObjectProperty, OWL2.bottomObjectProperty } ) {
      inferences.add( op, RDFS.subPropertyOf, OWL2.topObjectProperty );
      inferences.add( OWL2.bottomObjectProperty, RDFS.subPropertyOf, op );
    }
    // All data properties are a sub property of topDataProperty
    for( Property dp: new Property[] { q, subQ, subSubQ, OWL2.topDataProperty, OWL2.bottomDataProperty } ) {
      inferences.add( dp, RDFS.subPropertyOf, OWL2.topDataProperty );
      inferences.add( OWL2.bottomDataProperty, RDFS.subPropertyOf, dp );
    }
    // the real inferred relations
    inferences.add( subSubP, RDFS.subPropertyOf, p );
    inferences.add( subSubQ, RDFS.subPropertyOf, q );
    // check if all inferences hold
    assertPropertyValues( reasoner, RDFS.subPropertyOf, inferences );

    // check for direct sub-properties
    assertIteratorValues( p.listSubProperties( true ), new RDFNode[] { subP } );
    assertIteratorValues( subP.listSuperProperties( true ), new RDFNode[] { p } );
    assertIteratorValues( subP.listSubProperties( true ), new RDFNode[] { subSubP } );
    assertIteratorValues( subSubP.listSuperProperties( true ), new RDFNode[] { subP } );

    assertIteratorValues( q.listSubProperties( true ), new RDFNode[] { subQ } );
    assertIteratorValues( subQ.listSuperProperties( true ), new RDFNode[] { q } );
    assertIteratorValues( subQ.listSubProperties( true ), new RDFNode[] { subSubQ } );
    assertIteratorValues( subSubQ.listSuperProperties( true ), new RDFNode[] { subQ } );
View Full Code Here

  @Test
  public void testIncrementalABoxAddition() throws MalformedURLException {
    OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC, null );

    ObjectProperty p = model.createObjectProperty( "p" );
    ObjectProperty t = model.createObjectProperty( "t" );
    DatatypeProperty q = model.createDatatypeProperty( "q" );
    AnnotationProperty r = model.createAnnotationProperty( "r" );

    Individual a = model.createIndividual( "a", OWL.Thing );
    Individual b = model.createIndividual( "b", OWL.Thing );
View Full Code Here

  public void testInverse() {
    String ns = "http://www.example.org/test#";

    OntModel ont = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC, null );

    ObjectProperty p1 = ont.createObjectProperty( ns + "p1" );
    ObjectProperty p2 = ont.createObjectProperty( ns + "p2" );
    ObjectProperty p3 = ont.createObjectProperty( ns + "p3" );

    p2.addSubProperty( p1 );
    p2.addInverseOf( p3 );

    Individual s1 = ont.createIndividual( ns + "s1", OWL.Thing );
    Individual o1 = ont.createIndividual( ns + "o1", OWL.Thing );
    Individual s2 = ont.createIndividual( ns + "s2", OWL.Thing );
    Individual o2 = ont.createIndividual( ns + "o2", OWL.Thing );
    Individual s3 = ont.createIndividual( ns + "s3", OWL.Thing );
    Individual o3 = ont.createIndividual( ns + "o3", OWL.Thing );

    s1.addProperty( p1, o1 );
    s2.addProperty( p2, o2 );
    s3.addProperty( p3, o3 );

    Statement stmt = ont.createStatement( o1, p3, s1 );
    assertIteratorContains( o1.listPropertyValues( p3 ), s1 );
    assertTrue( ont.contains( stmt ) );
    assertIteratorContains( ont.listStatements( null, p3, (RDFNode) null ), stmt );
    assertIteratorContains( ont.listStatements( o1, null, (RDFNode) null ), stmt );
    assertIteratorContains( ont.listStatements(), stmt );
    assertFalse( ont.contains( o3, p1, s3 ) );

    assertTrue( p2.isInverseOf( p3 ) );
    assertIteratorValues( p2.listInverseOf(), new Property[] { p3 } );
    assertTrue( p3.isInverseOf( p2 ) );
    assertIteratorValues( p3.listInverseOf(), new Property[] { p2 } );
  }
View Full Code Here

    Individual ind6 = model.getIndividual( ns + "ind6" );
    Individual ind7 = model.getIndividual( ns + "ind7" );
    Individual ind8 = model.getIndividual( ns + "ind8" );

    DatatypeProperty dp = model.getDatatypeProperty( ns + "dp" );
    ObjectProperty p = model.getObjectProperty( ns + "p" );
    ObjectProperty r = model.getObjectProperty( ns + "r" );
    ObjectProperty invR = model.getObjectProperty( ns + "invR" );
    ObjectProperty ir = model.getObjectProperty( ns + "ir" );
    ObjectProperty as = model.getObjectProperty( ns + "as" );
    ObjectProperty d1 = model.getObjectProperty( ns + "d1" );
    ObjectProperty d2 = model.getObjectProperty( ns + "d2" );

    model.prepare();

    assertTrue( r.hasRDFType( OWL2.ReflexiveProperty ) );
    assertTrue( invR.hasRDFType( OWL2.ReflexiveProperty ) );
View Full Code Here

  public void testInvalidTransitivity() {
    OntModel ont = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );

    OntClass C = ont.createClass( "C" );

    ObjectProperty p1 = ont.createObjectProperty( "p1" );
    p1.addRDFType( OWL.TransitiveProperty );

    ObjectProperty p2 = ont.createObjectProperty( "p2" );

    Individual x = ont.createIndividual( OWL.Thing );
    Individual y = ont.createIndividual( OWL.Thing );
    Individual z = ont.createIndividual( OWL.Thing );
View Full Code Here

  public void testInvalidComplexSubRole() {
    OntModel ont = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );

    OntClass C = ont.createClass( "C" );

    ObjectProperty p1 = ont.createObjectProperty( "p1" );
    ObjectProperty p2 = ont.createObjectProperty( "p2" );

    RDFList pChain = ont.createList( new RDFNode[] { p1, p2 } );
    ont.add( p1, OWL2.propertyChainAxiom, pChain );

    Individual x = ont.createIndividual( OWL.Thing );
View Full Code Here

    Individual a = model.createIndividual( ns + "a", OWL.Thing );
    Individual b = model.createIndividual( ns + "b", OWL.Thing );
    Individual c = model.createIndividual( ns + "c", OWL.Thing );

    ObjectProperty op = model.createObjectProperty( ns + "op" );
    DatatypeProperty dp = model.createDatatypeProperty( ns + "dp" );
    dp.convertToInverseFunctionalProperty();

    a.addProperty( op, c );
View Full Code Here

    spec.setReasoner( new PelletReasoner() );

    OntModel model = ModelFactory.createOntologyModel( spec, null );

    OntClass X = model.createClass( ns + "X" );
    ObjectProperty hasX = model.createObjectProperty( ns + "hasX" );
    OntClass AllX = model.createAllValuesFromRestriction( null, hasX, X );
    OntClass Y = model.createIntersectionClass( ns + "Y", model.createList( new RDFNode[] {
        X, AllX } ) );

    assertTrue( "AllX is not a superclass of Y", Y.hasSuperClass( AllX ) );
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.ontology.ObjectProperty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.